ELEC2645 (2017/18) / Mbed 2 deprecated ll14zs

Dependencies:   mbed

Fork of ll14zs by Zeshaan Saeed

Level/Level.cpp

Committer:
ll14zs
Date:
2018-05-24
Revision:
3:1231a3961984

File content as of revision 3:1231a3961984:

#include "Level.h"

Level::Level()
{
    _height = 1; 
    srand(time(NULL));
    _width = rand()%70;
    //printf("%d\n",levelwidth)
    
    _x = 1;
    _y = 45;
    
    int direction = 0;
    
    if (direction == 0) {
        _velocity.y = -(1);
    }
}

Level::~Level()
{
    
}

void Level::draw(N5110 &lcd)
{
    lcd.drawRect(_x,_y,_width,_height,1);
    lcd.drawRect((_width +10),_y,(70-_width),_height,1);
}

void Level::update()
{
    _x += _velocity.x;
    _y += _velocity.y;
}

void Level::set_velocity(Vector2D v)
{
    _velocity.x = v.x;
    _velocity.y = v.y;
}

Vector2D Level::get_velocity()
{
    Vector2D v = {_velocity.x,_velocity.y};
    return v;
}

Vector2D Level::get_pos()
{
    Vector2D p - {_x,_y};
    return p;
}

void Level::set_pos(Vector2D p)
{
    _x = p.x;
    _y = p.y;
    
}