Version of Robotron arcade game using LPC1768, a Gameduino shield, a serial EEPROM (for high scores), two microswitch joysticks and two buttons plus a box to put it in. 20 levels of mayhem.
Dependencies: 25LCxxx_SPI CommonTypes Gameduino mbed
EnemyObject.cpp@7:e72691603fd3, 2013-06-08 (annotated)
- Committer:
- RichardE
- Date:
- Sat Jun 08 16:44:54 2013 +0000
- Revision:
- 7:e72691603fd3
Now have grunts wandering around on level 1. They follow the player but since no collision detection logic yet nobody ever gets killed.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RichardE | 7:e72691603fd3 | 1 | /* |
RichardE | 7:e72691603fd3 | 2 | * SOURCE FILE : EnemyObject.cpp |
RichardE | 7:e72691603fd3 | 3 | * |
RichardE | 7:e72691603fd3 | 4 | * Base class for enemy objects. |
RichardE | 7:e72691603fd3 | 5 | * |
RichardE | 7:e72691603fd3 | 6 | */ |
RichardE | 7:e72691603fd3 | 7 | |
RichardE | 7:e72691603fd3 | 8 | #include "EnemyObject.h" |
RichardE | 7:e72691603fd3 | 9 | |
RichardE | 7:e72691603fd3 | 10 | // Default object to chase. |
RichardE | 7:e72691603fd3 | 11 | PlayerObject EnemyObject::defaultChaseObject; |
RichardE | 7:e72691603fd3 | 12 | |
RichardE | 7:e72691603fd3 | 13 | /*****************************************************/ |
RichardE | 7:e72691603fd3 | 14 | /* CHECK IF ALL SURVIVING ENEMIES ARE INDESTRUCTABLE */ |
RichardE | 7:e72691603fd3 | 15 | /*****************************************************/ |
RichardE | 7:e72691603fd3 | 16 | // Pass pointer to array of pointers to EnemyObjects in enemies. |
RichardE | 7:e72691603fd3 | 17 | // Pass number of pointers in the array in enemyCount. |
RichardE | 7:e72691603fd3 | 18 | bool EnemyObject::AreAllIndestructable( const EnemyObject **enemies, UInt8 enemyCount ) { |
RichardE | 7:e72691603fd3 | 19 | const EnemyObject *enemy; |
RichardE | 7:e72691603fd3 | 20 | bool foundMortal = false; |
RichardE | 7:e72691603fd3 | 21 | UInt8 i = 0; |
RichardE | 7:e72691603fd3 | 22 | while( ! foundMortal && ( i < enemyCount ) ) { |
RichardE | 7:e72691603fd3 | 23 | enemy = enemies[ i ]; |
RichardE | 7:e72691603fd3 | 24 | if( ( enemy != (EnemyObject*)NULL ) && ( enemy->HitPoints != Indestructable ) ) { |
RichardE | 7:e72691603fd3 | 25 | foundMortal = true; |
RichardE | 7:e72691603fd3 | 26 | } |
RichardE | 7:e72691603fd3 | 27 | i++; |
RichardE | 7:e72691603fd3 | 28 | } |
RichardE | 7:e72691603fd3 | 29 | return ! foundMortal; |
RichardE | 7:e72691603fd3 | 30 | } |