ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

Committer:
el17m2h
Date:
Wed Apr 17 15:19:58 2019 +0000
Revision:
10:e1d2289705ef
Parent:
9:5e53bca2a4c2
Child:
11:2041290b5a74
Managed to fix the doodler's bounce by changing the velocity to a double instead of a int type. I also added a get_velocity_y() function to the function checking the floor's collisions.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17m2h 1:0001cb3eb053 1 #include "Floors.h"
el17m2h 1:0001cb3eb053 2
el17m2h 1:0001cb3eb053 3 Floors::Floors(){
el17m2h 1:0001cb3eb053 4 }
el17m2h 1:0001cb3eb053 5 Floors::~Floors(){
el17m2h 1:0001cb3eb053 6 }
el17m2h 3:116913e97fd7 7
el17m2h 3:116913e97fd7 8 void Floors::init(int x, int y, int width, int height){
el17m2h 1:0001cb3eb053 9 _height = height;
el17m2h 1:0001cb3eb053 10 _width = width;
el17m2h 3:116913e97fd7 11
el17m2h 9:5e53bca2a4c2 12 _pos.x = x;
el17m2h 9:5e53bca2a4c2 13 _pos.y = y;
el17m2h 1:0001cb3eb053 14
el17m2h 1:0001cb3eb053 15 }
el17m2h 1:0001cb3eb053 16
el17m2h 1:0001cb3eb053 17 void Floors::draw(N5110 &lcd){
el17m2h 9:5e53bca2a4c2 18 lcd.drawRect(_pos.x, _pos.y, _width, _height, FILL_BLACK);
el17m2h 1:0001cb3eb053 19 }
el17m2h 1:0001cb3eb053 20
el17m2h 10:e1d2289705ef 21 void Floors::update(Vector2D current_pos){
el17m2h 10:e1d2289705ef 22 _pos = current_pos;
el17m2h 9:5e53bca2a4c2 23 // if they are below the y bottom then they re-appear at top in a random place
el17m2h 8:90e789413e0b 24
el17m2h 9:5e53bca2a4c2 25 }
el17m2h 9:5e53bca2a4c2 26
el17m2h 9:5e53bca2a4c2 27 Vector2D Floors::get_pos(){
el17m2h 9:5e53bca2a4c2 28 Vector2D p = {_pos.x,_pos.y};
el17m2h 9:5e53bca2a4c2 29 return p;
el17m2h 5:8814d6de77d0 30 }
el17m2h 5:8814d6de77d0 31
el17m2h 1:0001cb3eb053 32
el17m2h 1:0001cb3eb053 33 void Floors::set_pos(Vector2D p){
el17m2h 9:5e53bca2a4c2 34 _pos.x = p.x;
el17m2h 9:5e53bca2a4c2 35 _pos.y = p.y;
el17m2h 1:0001cb3eb053 36 }