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:
Mon Jun 17 15:10:43 2013 +0000
Revision:
18:70190f956a24
Parent:
5:0b0651ac7832
Improved response to button 1 when entering high scores (HighScoreEntry.cpp).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RichardE 4:673eb9735d44 1 /*
RichardE 4:673eb9735d44 2 * SOURCE FILE : PlayerObject.h
RichardE 4:673eb9735d44 3 *
RichardE 4:673eb9735d44 4 * Represents the player objects.
RichardE 4:673eb9735d44 5 *
RichardE 4:673eb9735d44 6 */
RichardE 4:673eb9735d44 7
RichardE 4:673eb9735d44 8 #ifndef PlayerObjectIncluded
RichardE 4:673eb9735d44 9
RichardE 4:673eb9735d44 10 #define PlayerObjectIncluded
RichardE 4:673eb9735d44 11
RichardE 4:673eb9735d44 12 #include "Gameduino.h"
RichardE 4:673eb9735d44 13 #include "GameObject.h"
RichardE 4:673eb9735d44 14 #include "BulletManager.h"
RichardE 4:673eb9735d44 15 #include "PanelControls.h"
RichardE 4:673eb9735d44 16 #include "BulletVelocities.h"
RichardE 4:673eb9735d44 17 #include "SpriteImageId.h"
RichardE 4:673eb9735d44 18 #include "BCDNumber.h"
RichardE 4:673eb9735d44 19
RichardE 4:673eb9735d44 20 class PlayerObject : public GameObject {
RichardE 4:673eb9735d44 21
RichardE 4:673eb9735d44 22 public :
RichardE 4:673eb9735d44 23
RichardE 4:673eb9735d44 24 // Lives remaining.
RichardE 4:673eb9735d44 25 UInt8 Lives;
RichardE 4:673eb9735d44 26
RichardE 4:673eb9735d44 27 // Score as a BCD number.
RichardE 4:673eb9735d44 28 UInt32 Score;
RichardE 4:673eb9735d44 29
RichardE 4:673eb9735d44 30 /***************/
RichardE 4:673eb9735d44 31 /* CONSTRUCTOR */
RichardE 4:673eb9735d44 32 /***************/
RichardE 4:673eb9735d44 33 PlayerObject();
RichardE 4:673eb9735d44 34
RichardE 4:673eb9735d44 35 /**************/
RichardE 4:673eb9735d44 36 /* DESTRUCTOR */
RichardE 4:673eb9735d44 37 /**************/
RichardE 4:673eb9735d44 38 virtual ~PlayerObject();
RichardE 4:673eb9735d44 39
RichardE 4:673eb9735d44 40 /**************************************/
RichardE 4:673eb9735d44 41 /* SET CONTROLS FOR THE PLAYER TO USE */
RichardE 4:673eb9735d44 42 /**************************************/
RichardE 4:673eb9735d44 43 // Pass controls to use in pc.
RichardE 4:673eb9735d44 44 void SetControls( PanelControls *pc ) {
RichardE 4:673eb9735d44 45 controls = pc;
RichardE 4:673eb9735d44 46 }
RichardE 4:673eb9735d44 47
RichardE 4:673eb9735d44 48 /*****************************************/
RichardE 4:673eb9735d44 49 /* GET CONTROLS BEING USED BY THE PLAYER */
RichardE 4:673eb9735d44 50 /*****************************************/
RichardE 4:673eb9735d44 51 PanelControls *GetControls( void ) const {
RichardE 4:673eb9735d44 52 return controls;
RichardE 4:673eb9735d44 53 }
RichardE 4:673eb9735d44 54
RichardE 4:673eb9735d44 55 /******************************/
RichardE 4:673eb9735d44 56 /* READ THE PLAYER'S CONTROLS */
RichardE 4:673eb9735d44 57 /******************************/
RichardE 4:673eb9735d44 58 void ReadControls( void ) {
RichardE 4:673eb9735d44 59 if( controls != (PanelControls*)NULL ) {
RichardE 4:673eb9735d44 60 controls->Read();
RichardE 4:673eb9735d44 61 }
RichardE 4:673eb9735d44 62 }
RichardE 4:673eb9735d44 63
RichardE 4:673eb9735d44 64 /************************/
RichardE 4:673eb9735d44 65 /* GET GAME OBJECT TYPE */
RichardE 4:673eb9735d44 66 /************************/
RichardE 4:673eb9735d44 67 // Returns type of game object.
RichardE 4:673eb9735d44 68 virtual GameObjectTypes GetType( void ) {
RichardE 4:673eb9735d44 69 return PlayerObjectType;
RichardE 4:673eb9735d44 70 }
RichardE 4:673eb9735d44 71
RichardE 4:673eb9735d44 72 /************************/
RichardE 4:673eb9735d44 73 /* MOVE THE GAME OBJECT */
RichardE 4:673eb9735d44 74 /************************/
RichardE 4:673eb9735d44 75 virtual void ProtectedMove( void );
RichardE 4:673eb9735d44 76
RichardE 4:673eb9735d44 77 /************************/
RichardE 4:673eb9735d44 78 /* DRAW THE GAME OBJECT */
RichardE 4:673eb9735d44 79 /************************/
RichardE 5:0b0651ac7832 80 // Pass pointer to Gameduino to draw on in gd.
RichardE 4:673eb9735d44 81 // This is only called after it has been established that the
RichardE 4:673eb9735d44 82 // game object is visible.
RichardE 5:0b0651ac7832 83 virtual void Draw( Gameduino *gd );
RichardE 4:673eb9735d44 84
RichardE 4:673eb9735d44 85 /*********************************/
RichardE 4:673eb9735d44 86 /* KILL A SINGLE PLAYER'S BULLET */
RichardE 4:673eb9735d44 87 /*********************************/
RichardE 5:0b0651ac7832 88 // Pass pointer to Gameduino to draw on in gd.
RichardE 4:673eb9735d44 89 // Pass index of bullet in b.
RichardE 5:0b0651ac7832 90 void KillBullet( Gameduino *gd, UInt8 b ) {
RichardE 5:0b0651ac7832 91 playerBullets.KillBullet( gd, b );
RichardE 4:673eb9735d44 92 }
RichardE 4:673eb9735d44 93
RichardE 4:673eb9735d44 94 /*****************************/
RichardE 4:673eb9735d44 95 /* KILL ALL PLAYER'S BULLETS */
RichardE 4:673eb9735d44 96 /*****************************/
RichardE 5:0b0651ac7832 97 // Pass pointer to Gameduino to draw on in gd.
RichardE 5:0b0651ac7832 98 void KillAllBullets( Gameduino *gd ) {
RichardE 5:0b0651ac7832 99 playerBullets.KillAllBullets( gd );
RichardE 4:673eb9735d44 100 }
RichardE 4:673eb9735d44 101
RichardE 4:673eb9735d44 102 /*********************************************************/
RichardE 4:673eb9735d44 103 /* GET ARRAY CONTAINING POINTERS TO ALL PLAYER'S BULLETS */
RichardE 4:673eb9735d44 104 /*********************************************************/
RichardE 4:673eb9735d44 105 // Returns pointer to array of GameObject pointers.
RichardE 4:673eb9735d44 106 // The array has BulletManager::MaxBullets pointers in it.
RichardE 4:673eb9735d44 107 GameObject **GetBullets( void ) {
RichardE 4:673eb9735d44 108 return playerBullets.GetBullets();
RichardE 4:673eb9735d44 109 }
RichardE 4:673eb9735d44 110
RichardE 4:673eb9735d44 111 /*************************/
RichardE 4:673eb9735d44 112 /* ADD TO PLAYER'S SCORE */
RichardE 4:673eb9735d44 113 /*************************/
RichardE 4:673eb9735d44 114 // Pass number of points to add in points (THIS IS BCD CODED!).
RichardE 4:673eb9735d44 115 void AddToScore( UInt16 points );
RichardE 4:673eb9735d44 116
RichardE 4:673eb9735d44 117 private :
RichardE 4:673eb9735d44 118
RichardE 4:673eb9735d44 119 // Pointer to object used to read joysticks and buttons.
RichardE 4:673eb9735d44 120 PanelControls *controls;
RichardE 4:673eb9735d44 121
RichardE 4:673eb9735d44 122 // Manages player's bullets.
RichardE 4:673eb9735d44 123 BulletManager playerBullets;
RichardE 4:673eb9735d44 124
RichardE 4:673eb9735d44 125 // Countdown until next bullet available.
RichardE 4:673eb9735d44 126 UInt8 bulletCountdown;
RichardE 4:673eb9735d44 127
RichardE 4:673eb9735d44 128 // Bullet velocity information.
RichardE 4:673eb9735d44 129 static BulletVelocities bulletVelocities;
RichardE 4:673eb9735d44 130
RichardE 4:673eb9735d44 131 // Player movement velocities.
RichardE 4:673eb9735d44 132 static BulletVelocities playerVelocities;
RichardE 4:673eb9735d44 133
RichardE 4:673eb9735d44 134 };
RichardE 4:673eb9735d44 135
RichardE 4:673eb9735d44 136 #endif
RichardE 4:673eb9735d44 137
RichardE 4:673eb9735d44 138 /* END of PlayerObject.h */
RichardE 4:673eb9735d44 139