Yudong Xiao
/
pokemon
This is test version of Pokemongo game. ELEC 2645 final project.
pokeball/Pokemon.cpp@0:819c2d6a69ac, 2021-04-15 (annotated)
- Committer:
- shalwego
- Date:
- Thu Apr 15 15:35:12 2021 +0000
- Revision:
- 0:819c2d6a69ac
Issue about music playing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shalwego | 0:819c2d6a69ac | 1 | #include "Pokemon.h" |
shalwego | 0:819c2d6a69ac | 2 | |
shalwego | 0:819c2d6a69ac | 3 | void Pokemon::init(int x, int y, int size, int speed){ |
shalwego | 0:819c2d6a69ac | 4 | _x = x; |
shalwego | 0:819c2d6a69ac | 5 | _y = y; |
shalwego | 0:819c2d6a69ac | 6 | _size = size; |
shalwego | 0:819c2d6a69ac | 7 | |
shalwego | 0:819c2d6a69ac | 8 | _velocity.x = speed; |
shalwego | 0:819c2d6a69ac | 9 | _velocity.y = speed; |
shalwego | 0:819c2d6a69ac | 10 | } |
shalwego | 0:819c2d6a69ac | 11 | |
shalwego | 0:819c2d6a69ac | 12 | void Pokemon::draw(N5110 &lcd){ |
shalwego | 0:819c2d6a69ac | 13 | lcd.drawRect(_x,_y,_size,_size,FILL_BLACK); |
shalwego | 0:819c2d6a69ac | 14 | } |
shalwego | 0:819c2d6a69ac | 15 | |
shalwego | 0:819c2d6a69ac | 16 | void Pokemon::update(){ |
shalwego | 0:819c2d6a69ac | 17 | _x += _velocity.x; |
shalwego | 0:819c2d6a69ac | 18 | _y += _velocity.y; |
shalwego | 0:819c2d6a69ac | 19 | } |
shalwego | 0:819c2d6a69ac | 20 | |
shalwego | 0:819c2d6a69ac | 21 | void Pokemon::set_velocity(Position2D v){ |
shalwego | 0:819c2d6a69ac | 22 | _velocity.x = v.x; |
shalwego | 0:819c2d6a69ac | 23 | _velocity.y = v.y; |
shalwego | 0:819c2d6a69ac | 24 | } |
shalwego | 0:819c2d6a69ac | 25 | |
shalwego | 0:819c2d6a69ac | 26 | void Pokemon::set_pos(Position2D p){ |
shalwego | 0:819c2d6a69ac | 27 | _x = p.x; |
shalwego | 0:819c2d6a69ac | 28 | _y = p.y; |
shalwego | 0:819c2d6a69ac | 29 | } |
shalwego | 0:819c2d6a69ac | 30 | |
shalwego | 0:819c2d6a69ac | 31 | void Pokemon::pokemon_caught(){ |
shalwego | 0:819c2d6a69ac | 32 | _x = rand() % 84 ; |
shalwego | 0:819c2d6a69ac | 33 | _y = rand() % 48 ; |
shalwego | 0:819c2d6a69ac | 34 | } |
shalwego | 0:819c2d6a69ac | 35 | |
shalwego | 0:819c2d6a69ac | 36 | |
shalwego | 0:819c2d6a69ac | 37 | Position2D Pokemon::get_velocity(){ return {_velocity.x,_velocity.y}; } |
shalwego | 0:819c2d6a69ac | 38 | |
shalwego | 0:819c2d6a69ac | 39 | Position2D Pokemon::get_pos() { return {_x,_y}; } |
shalwego | 0:819c2d6a69ac | 40 | |
shalwego | 0:819c2d6a69ac | 41 | int Pokemon::get_size() { return _size; } |
shalwego | 0:819c2d6a69ac | 42 | |
shalwego | 0:819c2d6a69ac | 43 |