ELEC2645 (2017/18) / Mbed 2 deprecated ll14zs

Dependencies:   mbed

Fork of ll14zs by Zeshaan Saeed

Committer:
ll14zs
Date:
Thu May 24 17:37:17 2018 +0000
Revision:
3:1231a3961984
Final Submission. I have read and agreed with Statement of Academic Integrity

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ll14zs 3:1231a3961984 1 #include "Level.h"
ll14zs 3:1231a3961984 2
ll14zs 3:1231a3961984 3 Level::Level()
ll14zs 3:1231a3961984 4 {
ll14zs 3:1231a3961984 5 _height = 1;
ll14zs 3:1231a3961984 6 srand(time(NULL));
ll14zs 3:1231a3961984 7 _width = rand()%70;
ll14zs 3:1231a3961984 8 //printf("%d\n",levelwidth)
ll14zs 3:1231a3961984 9
ll14zs 3:1231a3961984 10 _x = 1;
ll14zs 3:1231a3961984 11 _y = 45;
ll14zs 3:1231a3961984 12
ll14zs 3:1231a3961984 13 int direction = 0;
ll14zs 3:1231a3961984 14
ll14zs 3:1231a3961984 15 if (direction == 0) {
ll14zs 3:1231a3961984 16 _velocity.y = -(1);
ll14zs 3:1231a3961984 17 }
ll14zs 3:1231a3961984 18 }
ll14zs 3:1231a3961984 19
ll14zs 3:1231a3961984 20 Level::~Level()
ll14zs 3:1231a3961984 21 {
ll14zs 3:1231a3961984 22
ll14zs 3:1231a3961984 23 }
ll14zs 3:1231a3961984 24
ll14zs 3:1231a3961984 25 void Level::draw(N5110 &lcd)
ll14zs 3:1231a3961984 26 {
ll14zs 3:1231a3961984 27 lcd.drawRect(_x,_y,_width,_height,1);
ll14zs 3:1231a3961984 28 lcd.drawRect((_width +10),_y,(70-_width),_height,1);
ll14zs 3:1231a3961984 29 }
ll14zs 3:1231a3961984 30
ll14zs 3:1231a3961984 31 void Level::update()
ll14zs 3:1231a3961984 32 {
ll14zs 3:1231a3961984 33 _x += _velocity.x;
ll14zs 3:1231a3961984 34 _y += _velocity.y;
ll14zs 3:1231a3961984 35 }
ll14zs 3:1231a3961984 36
ll14zs 3:1231a3961984 37 void Level::set_velocity(Vector2D v)
ll14zs 3:1231a3961984 38 {
ll14zs 3:1231a3961984 39 _velocity.x = v.x;
ll14zs 3:1231a3961984 40 _velocity.y = v.y;
ll14zs 3:1231a3961984 41 }
ll14zs 3:1231a3961984 42
ll14zs 3:1231a3961984 43 Vector2D Level::get_velocity()
ll14zs 3:1231a3961984 44 {
ll14zs 3:1231a3961984 45 Vector2D v = {_velocity.x,_velocity.y};
ll14zs 3:1231a3961984 46 return v;
ll14zs 3:1231a3961984 47 }
ll14zs 3:1231a3961984 48
ll14zs 3:1231a3961984 49 Vector2D Level::get_pos()
ll14zs 3:1231a3961984 50 {
ll14zs 3:1231a3961984 51 Vector2D p - {_x,_y};
ll14zs 3:1231a3961984 52 return p;
ll14zs 3:1231a3961984 53 }
ll14zs 3:1231a3961984 54
ll14zs 3:1231a3961984 55 void Level::set_pos(Vector2D p)
ll14zs 3:1231a3961984 56 {
ll14zs 3:1231a3961984 57 _x = p.x;
ll14zs 3:1231a3961984 58 _y = p.y;
ll14zs 3:1231a3961984 59
ll14zs 3:1231a3961984 60 }
ll14zs 3:1231a3961984 61