Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: People/People.cpp
- Revision:
- 33:7fedd8029473
- Child:
- 34:85ccc16f24d2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/People/People.cpp Thu May 14 22:41:16 2020 +0000 @@ -0,0 +1,39 @@ +#include "People.h" + +const int k_people_sprite[5][4] = { + { 0,1,1,0,}, + { 1,1,1,1,}, + { 1,1,1,1,}, + { 0,1,1,0,}, + { 0,1,1,0,}, +}; + +People::People() { + +} + +People::~People() { + +} + +void People::init(Gamepad &pad, int position_x_start) { + position_x_ = position_x_start; + position_y_ = 43; +} + +void People::draw_people(N5110 &lcd, Direction d_){ + position_x_ += calc_people_movement(d_); + lcd.drawSprite(position_x_, position_y_, 5, 4, (int*)k_people_sprite); +} + +int People::calc_people_movement(Direction d_){ + // moves the people in oposite direction to spaceship when it's position is + // at min and max x positions and joystick has direction + if (d_ == W || d_ == NW || d_ == SW){ + return 2; + }else if (d_ == E || d_ == NE || d_ == SE){ + return -2; + }else { + return 0; + } +} \ No newline at end of file