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:
8:82d88f9381f3
Improved response to button 1 when entering high scores (HighScoreEntry.cpp).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RichardE 8:82d88f9381f3 1 /*
RichardE 8:82d88f9381f3 2 * SOURCE FILE : OneShotObject.h
RichardE 8:82d88f9381f3 3 *
RichardE 8:82d88f9381f3 4 * Base class for all objects that do not move and play an animation once before vanishing.
RichardE 8:82d88f9381f3 5 * Useful for explosions and popup scores.
RichardE 8:82d88f9381f3 6 *
RichardE 8:82d88f9381f3 7 */
RichardE 8:82d88f9381f3 8
RichardE 8:82d88f9381f3 9 #ifndef OneShotObjectIncluded
RichardE 8:82d88f9381f3 10
RichardE 8:82d88f9381f3 11 #define OneShotObjectIncluded
RichardE 8:82d88f9381f3 12
RichardE 8:82d88f9381f3 13 #include "GameObject.h"
RichardE 8:82d88f9381f3 14 #include "SpriteImageId.h"
RichardE 8:82d88f9381f3 15
RichardE 8:82d88f9381f3 16 class OneShotObject : public GameObject {
RichardE 8:82d88f9381f3 17
RichardE 8:82d88f9381f3 18 public :
RichardE 8:82d88f9381f3 19
RichardE 8:82d88f9381f3 20 /***************/
RichardE 8:82d88f9381f3 21 /* CONSTRUCTOR */
RichardE 8:82d88f9381f3 22 /***************/
RichardE 8:82d88f9381f3 23 OneShotObject() :
RichardE 8:82d88f9381f3 24 imageNumber( Explosion0Image ),
RichardE 8:82d88f9381f3 25 firstImageNumber( Explosion0Image ),
RichardE 8:82d88f9381f3 26 lastImageNumber( Explosion9Image ),
RichardE 8:82d88f9381f3 27 maxCountdown( 7 ),
RichardE 8:82d88f9381f3 28 imageCountdown( 7 )
RichardE 8:82d88f9381f3 29 {
RichardE 8:82d88f9381f3 30 MovementRestricted = false;
RichardE 8:82d88f9381f3 31 DeleteWhenRestricted = false;
RichardE 8:82d88f9381f3 32 }
RichardE 8:82d88f9381f3 33
RichardE 8:82d88f9381f3 34 /**************/
RichardE 8:82d88f9381f3 35 /* DESTRUCTOR */
RichardE 8:82d88f9381f3 36 /**************/
RichardE 8:82d88f9381f3 37 virtual ~OneShotObject() {
RichardE 8:82d88f9381f3 38 }
RichardE 8:82d88f9381f3 39
RichardE 8:82d88f9381f3 40 /**************************************************************/
RichardE 8:82d88f9381f3 41 /* SET RANGE OF SPRITE IMAGES TO USE AND DELAY FOR EACH IMAGE */
RichardE 8:82d88f9381f3 42 /**************************************************************/
RichardE 8:82d88f9381f3 43 // Pass first sprite image used in first.
RichardE 8:82d88f9381f3 44 // Pass last sprite image used in last.
RichardE 8:82d88f9381f3 45 // Pass delay count between images in count.
RichardE 8:82d88f9381f3 46 void SetImageRange( UInt8 first, UInt8 last, UInt8 count ) {
RichardE 8:82d88f9381f3 47 firstImageNumber = first;
RichardE 8:82d88f9381f3 48 lastImageNumber = last;
RichardE 8:82d88f9381f3 49 maxCountdown = count;
RichardE 8:82d88f9381f3 50 Restart();
RichardE 8:82d88f9381f3 51 }
RichardE 8:82d88f9381f3 52
RichardE 8:82d88f9381f3 53 /************************/
RichardE 8:82d88f9381f3 54 /* MOVE THE GAME OBJECT */
RichardE 8:82d88f9381f3 55 /************************/
RichardE 8:82d88f9381f3 56 virtual void ProtectedMove( void );
RichardE 8:82d88f9381f3 57
RichardE 8:82d88f9381f3 58 /************************/
RichardE 8:82d88f9381f3 59 /* DRAW THE GAME OBJECT */
RichardE 8:82d88f9381f3 60 /************************/
RichardE 8:82d88f9381f3 61 // This is only called after it has been established that the
RichardE 8:82d88f9381f3 62 // game object is visible.
RichardE 8:82d88f9381f3 63 virtual void Draw( Gameduino *gd ) {
RichardE 8:82d88f9381f3 64 gd->sprite( SpriteNumber, ToPixel( Xco ), ToPixel( Yco ), imageNumber, 0, Gameduino::None, GoodGuy );
RichardE 8:82d88f9381f3 65 }
RichardE 8:82d88f9381f3 66
RichardE 8:82d88f9381f3 67 /****************************/
RichardE 8:82d88f9381f3 68 /* RESTART FROM FIRST IMAGE */
RichardE 8:82d88f9381f3 69 /****************************/
RichardE 8:82d88f9381f3 70 void Restart( void ) {
RichardE 8:82d88f9381f3 71 imageNumber = firstImageNumber;
RichardE 8:82d88f9381f3 72 imageCountdown = maxCountdown;
RichardE 8:82d88f9381f3 73 Visible = true;
RichardE 8:82d88f9381f3 74 }
RichardE 8:82d88f9381f3 75
RichardE 8:82d88f9381f3 76 private :
RichardE 8:82d88f9381f3 77
RichardE 8:82d88f9381f3 78 // Image number currently in use.
RichardE 8:82d88f9381f3 79 UInt8 imageNumber;
RichardE 8:82d88f9381f3 80
RichardE 8:82d88f9381f3 81 // Image numbers of first and last images.
RichardE 8:82d88f9381f3 82 UInt8 firstImageNumber, lastImageNumber;
RichardE 8:82d88f9381f3 83
RichardE 8:82d88f9381f3 84 // Maximum countdown to next image change.
RichardE 8:82d88f9381f3 85 // Determines speed of explosion animation.
RichardE 8:82d88f9381f3 86 UInt8 maxCountdown;
RichardE 8:82d88f9381f3 87
RichardE 8:82d88f9381f3 88 // Countdown to next image.
RichardE 8:82d88f9381f3 89 UInt8 imageCountdown;
RichardE 8:82d88f9381f3 90
RichardE 8:82d88f9381f3 91 };
RichardE 8:82d88f9381f3 92
RichardE 8:82d88f9381f3 93 #endif
RichardE 8:82d88f9381f3 94
RichardE 8:82d88f9381f3 95 /* END of OneShotObject.h */
RichardE 8:82d88f9381f3 96