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

Committer:
RichardE
Date:
Sat Jun 08 16:44:54 2013 +0000
Revision:
7:e72691603fd3
Child:
13:50779b12ff51
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?

UserRevisionLine numberNew contents of line
RichardE 7:e72691603fd3 1 /*
RichardE 7:e72691603fd3 2 * SOURCE FILE : EnemyObject.h
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 #ifndef EnemyObjectIncluded
RichardE 7:e72691603fd3 9
RichardE 7:e72691603fd3 10 #define EnemyObjectIncluded
RichardE 7:e72691603fd3 11
RichardE 7:e72691603fd3 12 #include "GameObject.h"
RichardE 7:e72691603fd3 13 #include "PlayerObject.h"
RichardE 7:e72691603fd3 14 #include "EnemyType.h"
RichardE 7:e72691603fd3 15
RichardE 7:e72691603fd3 16 class EnemyObject : public GameObject {
RichardE 7:e72691603fd3 17
RichardE 7:e72691603fd3 18 public :
RichardE 7:e72691603fd3 19
RichardE 7:e72691603fd3 20 enum {
RichardE 7:e72691603fd3 21 Indestructable = 0xFF,
RichardE 7:e72691603fd3 22 };
RichardE 7:e72691603fd3 23
RichardE 7:e72691603fd3 24 // Number of hit points remaining.
RichardE 7:e72691603fd3 25 // When this reaches zero the enemy dies.
RichardE 7:e72691603fd3 26 // However, if this has the special value Indestructable then enemy cannot be killed.
RichardE 7:e72691603fd3 27 UInt8 HitPoints;
RichardE 7:e72691603fd3 28
RichardE 7:e72691603fd3 29 // Set to true of the enemy squashes humans.
RichardE 7:e72691603fd3 30 bool SquashesHumans;
RichardE 7:e72691603fd3 31
RichardE 7:e72691603fd3 32 // Pointer to array of pointers to enemies.
RichardE 7:e72691603fd3 33 // Some enemies may need to add new enemies (such as bullets or new spawning enemies) to this array.
RichardE 7:e72691603fd3 34 GameObject **Enemies;
RichardE 7:e72691603fd3 35
RichardE 7:e72691603fd3 36 /***************/
RichardE 7:e72691603fd3 37 /* CONSTRUCTOR */
RichardE 7:e72691603fd3 38 /***************/
RichardE 7:e72691603fd3 39 EnemyObject() :
RichardE 7:e72691603fd3 40 HitPoints( 1 ),
RichardE 7:e72691603fd3 41 SquashesHumans( false ),
RichardE 7:e72691603fd3 42 Enemies( (GameObject**)NULL ),
RichardE 7:e72691603fd3 43 chaseObject( &defaultChaseObject )
RichardE 7:e72691603fd3 44 {
RichardE 7:e72691603fd3 45 }
RichardE 7:e72691603fd3 46
RichardE 7:e72691603fd3 47 /**************/
RichardE 7:e72691603fd3 48 /* DESTRUCTOR */
RichardE 7:e72691603fd3 49 /**************/
RichardE 7:e72691603fd3 50 virtual ~EnemyObject() {
RichardE 7:e72691603fd3 51 }
RichardE 7:e72691603fd3 52
RichardE 7:e72691603fd3 53 /************************/
RichardE 7:e72691603fd3 54 /* GET GAME OBJECT TYPE */
RichardE 7:e72691603fd3 55 /************************/
RichardE 7:e72691603fd3 56 // Returns type of game object.
RichardE 7:e72691603fd3 57 virtual GameObjectTypes GetType( void ) {
RichardE 7:e72691603fd3 58 return EnemyObjectType;
RichardE 7:e72691603fd3 59 }
RichardE 7:e72691603fd3 60
RichardE 7:e72691603fd3 61 /*****************************/
RichardE 7:e72691603fd3 62 /* GET TYPE OF ENEMY THIS IS */
RichardE 7:e72691603fd3 63 /*****************************/
RichardE 7:e72691603fd3 64 // Returns enemy type.
RichardE 7:e72691603fd3 65 virtual EnemyType GetEnemyType( void ) = 0;
RichardE 7:e72691603fd3 66
RichardE 7:e72691603fd3 67 /*******************************************************/
RichardE 7:e72691603fd3 68 /* GET NUMBER OF POINTS AWARDED FOR KILLING THIS ENEMY */
RichardE 7:e72691603fd3 69 /*******************************************************/
RichardE 7:e72691603fd3 70 // Returns number of points (in BCD).
RichardE 7:e72691603fd3 71 virtual UInt8 GetPoints( void ) = 0;
RichardE 7:e72691603fd3 72
RichardE 7:e72691603fd3 73 /***********************/
RichardE 7:e72691603fd3 74 /* SET OBJECT TO CHASE */
RichardE 7:e72691603fd3 75 /***********************/
RichardE 7:e72691603fd3 76 // Pass pointer to object to chase in co.
RichardE 7:e72691603fd3 77 void SetChaseObject( GameObject *co ) {
RichardE 7:e72691603fd3 78 chaseObject = co;
RichardE 7:e72691603fd3 79 }
RichardE 7:e72691603fd3 80
RichardE 7:e72691603fd3 81 /********************************************/
RichardE 7:e72691603fd3 82 /* INFORM ENEMY IT HAS BEEN HIT BY A BULLET */
RichardE 7:e72691603fd3 83 /********************************************/
RichardE 7:e72691603fd3 84 // Default implementation does nothing but if special behaviour
RichardE 7:e72691603fd3 85 // is required in a derived class then this should be overridden.
RichardE 7:e72691603fd3 86 // Note that this does NOT deal with determining if the enemy is dead or not.
RichardE 7:e72691603fd3 87 // An enemy ALWAYS dies if HitPoints reaches zero.
RichardE 7:e72691603fd3 88 virtual void RegisterHitByBullet( void ) {}
RichardE 7:e72691603fd3 89
RichardE 7:e72691603fd3 90 /*****************************************************/
RichardE 7:e72691603fd3 91 /* CHECK IF ALL SURVIVING ENEMIES ARE INDESTRUCTABLE */
RichardE 7:e72691603fd3 92 /*****************************************************/
RichardE 7:e72691603fd3 93 // Pass pointer to array of pointers to EnemyObjects in enemies.
RichardE 7:e72691603fd3 94 // Pass number of pointers in the array in enemyCount.
RichardE 7:e72691603fd3 95 static bool AreAllIndestructable( const EnemyObject **enemies, UInt8 enemyCount );
RichardE 7:e72691603fd3 96
RichardE 7:e72691603fd3 97 protected :
RichardE 7:e72691603fd3 98
RichardE 7:e72691603fd3 99 // Object to chase.
RichardE 7:e72691603fd3 100 GameObject *chaseObject;
RichardE 7:e72691603fd3 101
RichardE 7:e72691603fd3 102 private :
RichardE 7:e72691603fd3 103
RichardE 7:e72691603fd3 104 // Default object to chase.
RichardE 7:e72691603fd3 105 static PlayerObject defaultChaseObject;
RichardE 7:e72691603fd3 106
RichardE 7:e72691603fd3 107 };
RichardE 7:e72691603fd3 108
RichardE 7:e72691603fd3 109 #endif
RichardE 7:e72691603fd3 110
RichardE 7:e72691603fd3 111 /* END of EnemyObject.h */
RichardE 7:e72691603fd3 112