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.
Dependencies: mbed
Enemy/Enemy.cpp@31:5c4acae51026, 2019-05-09 (annotated)
- Committer:
- el17m2h
- Date:
- Thu May 09 10:15:20 2019 +0000
- Revision:
- 31:5c4acae51026
- Parent:
- 30:863565e9859f
- Child:
- 33:de130e274391
Added comments to the doodler cpp.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17m2h | 20:a359092079b0 | 1 | #include "Enemy.h" |
el17m2h | 29:15e9640646b7 | 2 | Enemy::Enemy() |
el17m2h | 29:15e9640646b7 | 3 | { |
el17m2h | 20:a359092079b0 | 4 | } |
el17m2h | 29:15e9640646b7 | 5 | Enemy::~Enemy() |
el17m2h | 29:15e9640646b7 | 6 | { |
el17m2h | 29:15e9640646b7 | 7 | } |
el17m2h | 29:15e9640646b7 | 8 | void Enemy::update(Vector2D floor_pos) // sets its position |
el17m2h | 29:15e9640646b7 | 9 | { |
el17m2h | 31:5c4acae51026 | 10 | _position.x = floor_pos.x + 7 - 6; // the + 7 for the centre of the floor and the + 6 for the centre of the ghost |
el17m2h | 31:5c4acae51026 | 11 | _position.y = floor_pos.y - 1 - 13; // the - 1 is so that it is on top of the floor's position |
el17m2h | 29:15e9640646b7 | 12 | // and the + 15 is so that it considers the position of the feet of the ghost (not the top) |
el17m2h | 20:a359092079b0 | 13 | } |
el17m2h | 20:a359092079b0 | 14 | |
el17m2h | 29:15e9640646b7 | 15 | void Enemy::draw(N5110 &lcd) |
el17m2h | 29:15e9640646b7 | 16 | { |
el17m2h | 30:863565e9859f | 17 | const int image [12][12] = { |
el17m2h | 29:15e9640646b7 | 18 | {0,0,0,0,1,1,1,1,0,0,0,0}, |
el17m2h | 29:15e9640646b7 | 19 | {0,0,1,1,0,0,0,0,1,1,0,0}, |
el17m2h | 29:15e9640646b7 | 20 | {0,1,0,0,0,0,0,0,0,0,1,0}, |
el17m2h | 30:863565e9859f | 21 | {1,0,0,1,0,0,0,0,1,0,0,1}, |
el17m2h | 29:15e9640646b7 | 22 | {1,0,1,1,1,0,0,1,1,1,0,1}, |
el17m2h | 30:863565e9859f | 23 | {1,0,0,1,0,0,0,0,1,0,0,1}, |
el17m2h | 29:15e9640646b7 | 24 | {1,0,0,0,0,0,0,0,0,0,0,1}, |
el17m2h | 29:15e9640646b7 | 25 | {1,0,0,0,0,0,0,0,0,0,0,1}, |
el17m2h | 29:15e9640646b7 | 26 | {1,0,0,0,0,0,0,0,0,0,0,1}, |
el17m2h | 29:15e9640646b7 | 27 | {1,1,1,0,0,1,1,0,0,1,1,1}, |
el17m2h | 29:15e9640646b7 | 28 | {1,1,0,1,1,0,0,1,1,0,1,1}, |
el17m2h | 29:15e9640646b7 | 29 | {1,0,0,0,1,0,0,1,0,0,0,1}, |
el17m2h | 23:9be87557b89a | 30 | }; |
el17m2h | 30:863565e9859f | 31 | lcd.drawSprite(_position.x, _position.y, 12, 12,(int*)image); |
el17m2h | 20:a359092079b0 | 32 | } |
el17m2h | 20:a359092079b0 | 33 | |
el17m2h | 29:15e9640646b7 | 34 | void Enemy::erase() // decides if it gets erased |
el17m2h | 29:15e9640646b7 | 35 | { |
el17m2h | 31:5c4acae51026 | 36 | _position.x = 90; // the ghost's is no longer shown on the screen |
el17m2h | 29:15e9640646b7 | 37 | _position.y = 50; |
el17m2h | 20:a359092079b0 | 38 | } |
el17m2h | 20:a359092079b0 | 39 | |
el17m2h | 29:15e9640646b7 | 40 | Vector2D Enemy::get_position() |
el17m2h | 29:15e9640646b7 | 41 | { |
el17m2h | 20:a359092079b0 | 42 | Vector2D p = {_position.x,_position.y}; |
el17m2h | 20:a359092079b0 | 43 | return p; |
el17m2h | 20:a359092079b0 | 44 | } |