Su 200943147

Dependencies:   Gamepad N5110 mbed

Committer:
GS00
Date:
Tue Apr 11 18:52:08 2017 +0000
Revision:
0:444b4d0a113d
Child:
1:4f00a4d5073c
Child:
2:84e6975dd4b2
Version1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GS00 0:444b4d0a113d 1 #include "Shape.h"
GS00 0:444b4d0a113d 2
GS00 0:444b4d0a113d 3
GS00 0:444b4d0a113d 4 Shape::shape()
GS00 0:444b4d0a113d 5 {
GS00 0:444b4d0a113d 6 }
GS00 0:444b4d0a113d 7
GS00 0:444b4d0a113d 8 void Shape::L_Shape(N5110 &lcd)
GS00 0:444b4d0a113d 9 {
GS00 0:444b4d0a113d 10 lcd.drawRect(x,y,2,4,FILL_BLACK);
GS00 0:444b4d0a113d 11 lcd.drawRect(x,y+4,4,2,FILL_BLACK);
GS00 0:444b4d0a113d 12 }
GS00 0:444b4d0a113d 13
GS00 0:444b4d0a113d 14 void Shape::O_Shape(N5110 &lcd)
GS00 0:444b4d0a113d 15 {
GS00 0:444b4d0a113d 16 lcd.drawRect(x,y,4,4,FILL_BLACK);
GS00 0:444b4d0a113d 17 }
GS00 0:444b4d0a113d 18
GS00 0:444b4d0a113d 19 void Shape::S_Shape(N5110 &lcd)
GS00 0:444b4d0a113d 20 {
GS00 0:444b4d0a113d 21 lcd.drawRect(x,y,2,4,FILL_BLACK);
GS00 0:444b4d0a113d 22 lcd.drawRect(x+2,y,2,2,FILL_BLACK);
GS00 0:444b4d0a113d 23 lcd.drawRect(x-2,y+2,2,2,FILL_BLACK);
GS00 0:444b4d0a113d 24 }
GS00 0:444b4d0a113d 25
GS00 0:444b4d0a113d 26 void Shape::Z_Shape(N5110 &lcd)
GS00 0:444b4d0a113d 27 {
GS00 0:444b4d0a113d 28 lcd.drawRect(x,y,2,4,FILL_BLACK);
GS00 0:444b4d0a113d 29 lcd.drawRect(x-2,y,2,2,FILL_BLACK);
GS00 0:444b4d0a113d 30 lcd.drawRect(x+2,y+2,2,2,FILL_BLACK);
GS00 0:444b4d0a113d 31 }
GS00 0:444b4d0a113d 32 void Shape::I_Shape(N5110 &lcd)
GS00 0:444b4d0a113d 33 {
GS00 0:444b4d0a113d 34 lcd.drawRect(x,y,2,8,FILL_BLACK);
GS00 0:444b4d0a113d 35 }
GS00 0:444b4d0a113d 36 void Shape::J_Shape(N5110 &lcd)
GS00 0:444b4d0a113d 37 {
GS00 0:444b4d0a113d 38 lcd.drawRect(x,y,2,4,FILL_BLACK);
GS00 0:444b4d0a113d 39 lcd.drawRect(x-2,y+4,4,2,FILL_BLACK);
GS00 0:444b4d0a113d 40 }
GS00 0:444b4d0a113d 41 void Shape::L_Shape(N5110 &lcd)
GS00 0:444b4d0a113d 42 {
GS00 0:444b4d0a113d 43 lcd.drawRect(x,y,2,4,FILL_BLACK);
GS00 0:444b4d0a113d 44 lcd.drawRect(x-2,y,2,2,FILL_BLACK);
GS00 0:444b4d0a113d 45 lcd.drawRect(x+2,y,2,2,FILL_BLACK);
GS00 0:444b4d0a113d 46 }
GS00 0:444b4d0a113d 47
GS00 0:444b4d0a113d 48 void Shape::L_Shape(N5110 &lcd)
GS00 0:444b4d0a113d 49 {
GS00 0:444b4d0a113d 50 lcd.drawRect(x,y,2,4,FILL_BLACK);
GS00 0:444b4d0a113d 51 lcd.drawRect(x-2,y,2,2,FILL_BLACK);
GS00 0:444b4d0a113d 52 lcd.drawRect(x+2,y,2,2,FILL_BLACK);
GS00 0:444b4d0a113d 53 }
GS00 0:444b4d0a113d 54
GS00 0:444b4d0a113d 55 void Shape::Movement(Direction d,float mag)
GS00 0:444b4d0a113d 56 {
GS00 0:444b4d0a113d 57 float mag = joystick.get_mag();
GS00 0:444b4d0a113d 58 Direction d = joystick.get_direction();
GS00 0:444b4d0a113d 59
GS00 0:444b4d0a113d 60 if(d == W) {
GS00 0:444b4d0a113d 61 x-=mag*10;
GS00 0:444b4d0a113d 62 } else if(d == E) {
GS00 0:444b4d0a113d 63 x+=mag*10;
GS00 0:444b4d0a113d 64 }
GS00 0:444b4d0a113d 65 }
GS00 0:444b4d0a113d 66
GS00 0:444b4d0a113d 67 void Shape::Drop()
GS00 0:444b4d0a113d 68 {
GS00 0:444b4d0a113d 69 y=y+1;
GS00 0:444b4d0a113d 70 }