Su 200943147

Dependencies:   Gamepad N5110 mbed

Shape/Shape.cpp

Committer:
GS00
Date:
2017-04-11
Revision:
0:444b4d0a113d
Child:
1:4f00a4d5073c
Child:
2:84e6975dd4b2

File content as of revision 0:444b4d0a113d:

#include "Shape.h"


Shape::shape()
{
}

void Shape::L_Shape(N5110 &lcd)
{
    lcd.drawRect(x,y,2,4,FILL_BLACK);
    lcd.drawRect(x,y+4,4,2,FILL_BLACK);
}

void Shape::O_Shape(N5110 &lcd)
{
    lcd.drawRect(x,y,4,4,FILL_BLACK);
}

void Shape::S_Shape(N5110 &lcd)
{
    lcd.drawRect(x,y,2,4,FILL_BLACK);
    lcd.drawRect(x+2,y,2,2,FILL_BLACK);
    lcd.drawRect(x-2,y+2,2,2,FILL_BLACK);
}

void Shape::Z_Shape(N5110 &lcd)
{
    lcd.drawRect(x,y,2,4,FILL_BLACK);
    lcd.drawRect(x-2,y,2,2,FILL_BLACK);
    lcd.drawRect(x+2,y+2,2,2,FILL_BLACK);
}
void Shape::I_Shape(N5110 &lcd)
{
    lcd.drawRect(x,y,2,8,FILL_BLACK);
}
void Shape::J_Shape(N5110 &lcd)
{
    lcd.drawRect(x,y,2,4,FILL_BLACK);
    lcd.drawRect(x-2,y+4,4,2,FILL_BLACK);
}
void Shape::L_Shape(N5110 &lcd)
{
    lcd.drawRect(x,y,2,4,FILL_BLACK);
    lcd.drawRect(x-2,y,2,2,FILL_BLACK);
    lcd.drawRect(x+2,y,2,2,FILL_BLACK);
}

void Shape::L_Shape(N5110 &lcd)
{
    lcd.drawRect(x,y,2,4,FILL_BLACK);
    lcd.drawRect(x-2,y,2,2,FILL_BLACK);
    lcd.drawRect(x+2,y,2,2,FILL_BLACK);
}

void Shape::Movement(Direction d,float mag)
{
    float mag = joystick.get_mag();
    Direction d = joystick.get_direction();
    
    if(d == W) {
        x-=mag*10;
    } else if(d == E) {
        x+=mag*10;
    }
}

void Shape::Drop()
{
    y=y+1;
}