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: Enemy/Enemy.cpp
- Revision:
- 5:096017b99011
- Parent:
- 4:3446009e2f38
- Child:
- 6:e8c03f264ffc
--- a/Enemy/Enemy.cpp Tue May 07 19:25:20 2019 +0000 +++ b/Enemy/Enemy.cpp Tue May 07 20:40:22 2019 +0000 @@ -7,16 +7,16 @@ void Enemy::init() { // Once an enemy has been created it writes nothing new until it dies } -int Enemy::write(int enemy_true, int map_x1, int map_y1) { // use collision mechanic to re-draw if both enemies are in 1 location - if (enemy_true == -1) { - return -1; +int Enemy::write(int enemy_true, int x1, int y1) { // use collision mechanic to re-draw if both enemies are in 1 location + if (enemy_true == 1) { + _x = x1 + 42 + _col * 20; // x pos of left wall + screen width / 2 + x pos of enemy + _y = y1 + 24 + _row * 10; // y pos of left wall + screen height / 2 + y pos of enemy + return 1; } else if (enemy_true == 0) { // create new enemy only if required random_position(); - _x = map_x1 + 42 + _col * 20; // x pos of left wall + screen width / 2 + x pos of enemy - _y = map_y1 + 24 + _row * 10; // y pos of left wall + screen height / 2 + y pos of enemy return 1; } else { - return 1; + return -1; } }