Yudong Xiao
/
pokemon
This is test version of Pokemongo game. ELEC 2645 final project.
Diff: pokeball/Pokemon.cpp
- Revision:
- 0:819c2d6a69ac
diff -r 000000000000 -r 819c2d6a69ac pokeball/Pokemon.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pokeball/Pokemon.cpp Thu Apr 15 15:35:12 2021 +0000 @@ -0,0 +1,43 @@ +#include "Pokemon.h" + +void Pokemon::init(int x, int y, int size, int speed){ + _x = x; + _y = y; + _size = size; + + _velocity.x = speed; + _velocity.y = speed; +} + +void Pokemon::draw(N5110 &lcd){ + lcd.drawRect(_x,_y,_size,_size,FILL_BLACK); +} + +void Pokemon::update(){ + _x += _velocity.x; + _y += _velocity.y; +} + +void Pokemon::set_velocity(Position2D v){ + _velocity.x = v.x; + _velocity.y = v.y; +} + +void Pokemon::set_pos(Position2D p){ + _x = p.x; + _y = p.y; +} + +void Pokemon::pokemon_caught(){ + _x = rand() % 84 ; + _y = rand() % 48 ; +} + + +Position2D Pokemon::get_velocity(){ return {_velocity.x,_velocity.y}; } + +Position2D Pokemon::get_pos() { return {_x,_y}; } + +int Pokemon::get_size() { return _size; } + +