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
Diff: PlayerObject.h
- Revision:
- 4:673eb9735d44
- Child:
- 5:0b0651ac7832
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PlayerObject.h Sat Jun 08 11:24:05 2013 +0000 @@ -0,0 +1,136 @@ +/* + * SOURCE FILE : PlayerObject.h + * + * Represents the player objects. + * + */ + +#ifndef PlayerObjectIncluded + + #define PlayerObjectIncluded + + #include "Gameduino.h" + #include "GameObject.h" + #include "BulletManager.h" + #include "PanelControls.h" + #include "BulletVelocities.h" + #include "SpriteImageId.h" + #include "BCDNumber.h" + + class PlayerObject : public GameObject { + + public : + + // Lives remaining. + UInt8 Lives; + + // Score as a BCD number. + UInt32 Score; + + /***************/ + /* CONSTRUCTOR */ + /***************/ + PlayerObject(); + + /**************/ + /* DESTRUCTOR */ + /**************/ + virtual ~PlayerObject(); + + /**************************************/ + /* SET CONTROLS FOR THE PLAYER TO USE */ + /**************************************/ + // Pass controls to use in pc. + void SetControls( PanelControls *pc ) { + controls = pc; + } + + /*****************************************/ + /* GET CONTROLS BEING USED BY THE PLAYER */ + /*****************************************/ + PanelControls *GetControls( void ) const { + return controls; + } + + /******************************/ + /* READ THE PLAYER'S CONTROLS */ + /******************************/ + void ReadControls( void ) { + if( controls != (PanelControls*)NULL ) { + controls->Read(); + } + } + + /************************/ + /* GET GAME OBJECT TYPE */ + /************************/ + // Returns type of game object. + virtual GameObjectTypes GetType( void ) { + return PlayerObjectType; + } + + /************************/ + /* MOVE THE GAME OBJECT */ + /************************/ + virtual void ProtectedMove( void ); + + /************************/ + /* DRAW THE GAME OBJECT */ + /************************/ + // This is only called after it has been established that the + // game object is visible. + virtual void Draw( void ); + + /*********************************/ + /* KILL A SINGLE PLAYER'S BULLET */ + /*********************************/ + // Pass index of bullet in b. + void KillBullet( UInt8 b ) { + playerBullets.KillBullet( b ); + } + + /*****************************/ + /* KILL ALL PLAYER'S BULLETS */ + /*****************************/ + void KillAllBullets( void ) { + playerBullets.KillAllBullets(); + } + + /*********************************************************/ + /* GET ARRAY CONTAINING POINTERS TO ALL PLAYER'S BULLETS */ + /*********************************************************/ + // Returns pointer to array of GameObject pointers. + // The array has BulletManager::MaxBullets pointers in it. + GameObject **GetBullets( void ) { + return playerBullets.GetBullets(); + } + + /*************************/ + /* ADD TO PLAYER'S SCORE */ + /*************************/ + // Pass number of points to add in points (THIS IS BCD CODED!). + void AddToScore( UInt16 points ); + + private : + + // Pointer to object used to read joysticks and buttons. + PanelControls *controls; + + // Manages player's bullets. + BulletManager playerBullets; + + // Countdown until next bullet available. + UInt8 bulletCountdown; + + // Bullet velocity information. + static BulletVelocities bulletVelocities; + + // Player movement velocities. + static BulletVelocities playerVelocities; + + }; + +#endif + +/* END of PlayerObject.h */ +