All there but errors need fixing

Dependencies:   mbed

Tetromino/Tetromino.cpp

Committer:
el18rs
Date:
2020-05-31
Revision:
4:7ddd287a5d28
Parent:
3:522c6f850e91

File content as of revision 4:7ddd287a5d28:

#include "Tetromino.h"

int tetromino[3][4][4] = {
{
  {1,1,1,1},
  {1,1,1,1},
  {1,1,1,1},
  {1,1,1,1}
}, {
  {1,1,1,1},
  {1,1,1,1},
  {1,1,1,1},
  {1,1,1,1}
}, {
  {1,1,1,1},
  {1,1,1,1},
  {1,1,1,1},
  {1,1,1,1}
}
};

Tetromino::Tetromino()
{
    
}

Tetromino::~Tetromino()
{
    
}

void Tetromino::init(int number, int x, int y, int speed)
{
    _x = x;
    _y = y;
    _speed = speed;
    _number = blockArray[blocknumber];

    
    _speed = 1;
    _x = WIDTH/2 - 2;
    _y = HEIGHT;
    
    _velocity.x = speed;
    _velocity.y = speed;
}

void Tetromino::update(Direction d, float mag)
{
    _speed = int(mag*10.0f);
    
    if (d == CENTRE) {
        _y+=_speed;
    } else if (d == S) {
        _y+=_speed*2;
    } else if (d == E) {
        _x+=_speed;
    } else if (d == W) {
        _x-=_speed;
    }
        
    if (_x < 1) {
        _x = 1;
    }
    if (_x > WIDTH - 3) {
        _x = WIDTH - 3;
    }
}


Vector2D Tetromino::get_pos() {
    Vector2D p = {_x,_y};
    return p;
}