All there but errors need fixing

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Tetromino.cpp Source File

Tetromino.cpp

00001 #include "Tetromino.h"
00002 
00003 int tetromino[3][4][4] = {
00004 {
00005   {1,1,1,1},
00006   {1,1,1,1},
00007   {1,1,1,1},
00008   {1,1,1,1}
00009 }, {
00010   {1,1,1,1},
00011   {1,1,1,1},
00012   {1,1,1,1},
00013   {1,1,1,1}
00014 }, {
00015   {1,1,1,1},
00016   {1,1,1,1},
00017   {1,1,1,1},
00018   {1,1,1,1}
00019 }
00020 };
00021 
00022 Tetromino::Tetromino()
00023 {
00024     
00025 }
00026 
00027 Tetromino::~Tetromino()
00028 {
00029     
00030 }
00031 
00032 void Tetromino::init(int number, int x, int y, int speed)
00033 {
00034     _x = x;
00035     _y = y;
00036     _speed = speed;
00037     _number = blockArray[blocknumber];
00038 
00039     
00040     _speed = 1;
00041     _x = WIDTH/2 - 2;
00042     _y = HEIGHT;
00043     
00044     _velocity.x = speed;
00045     _velocity.y = speed;
00046 }
00047 
00048 void Tetromino::update(Direction d, float mag)
00049 {
00050     _speed = int(mag*10.0f);
00051     
00052     if (d == CENTRE) {
00053         _y+=_speed;
00054     } else if (d == S) {
00055         _y+=_speed*2;
00056     } else if (d == E) {
00057         _x+=_speed;
00058     } else if (d == W) {
00059         _x-=_speed;
00060     }
00061         
00062     if (_x < 1) {
00063         _x = 1;
00064     }
00065     if (_x > WIDTH - 3) {
00066         _x = WIDTH - 3;
00067     }
00068 }
00069 
00070 
00071 Vector2D Tetromino::get_pos() {
00072     Vector2D p = {_x,_y};
00073     return p;
00074 }