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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Level.h Source File

Level.h

00001 /*
00002  * SOURCE FILE : Level.h
00003  *
00004  * Definition of class Level.
00005  * Base class for all levels.
00006  *
00007  */
00008 
00009 #ifndef LevelDefined
00010 
00011   #define LevelDefined
00012 
00013   #include "Types.h"
00014   #include "Gameduino.h"               // Gameduino library
00015   #include "GDExtra.h"                 // a few more Gameduino related functions
00016   #include "GDConst.h"                 // a few more Gameduino constants
00017   #include "CharCodes.h"               // character codes
00018   #include "CharBlocks.h"
00019   #include "StringData.h"
00020   #include "HighScoreTable.h"
00021   #include "CharFrame.h"
00022   #include "PanelControls.h"
00023   #include "PlayerObject.h"
00024   #include "ArenaConst.h"
00025   #include "SpriteImageId.h"
00026   #include "GameObject.h"
00027   #include "HumanObject.h"
00028   #include "GruntObject.h"
00029   #include "CrusherObject.h"
00030   #include "BrainObject.h"
00031   #include "MutantObject.h"
00032   #include "BlueMeanyObject.h"
00033   #include "SoundManager.h"
00034   #include "Sounds.h"
00035   
00036   class Level {
00037 
00038   public :
00039 
00040     // Number of this level.
00041     UInt8 LevelNumber;
00042     
00043     // True if level was dynamically allocated.
00044     bool IsDynamicallyAllocated;
00045     
00046     /***************/
00047     /* CONSTRUCTOR */
00048     /***************/
00049     Level();
00050 
00051     /**************/
00052     /* DESTRUCTOR */
00053     /**************/
00054     virtual ~Level();
00055 
00056     /************************/
00057     /* SET HIGH SCORE TABLE */
00058     /************************/
00059     // Pass pointer to EEPROM in e.
00060     void SetHighScores( HighScoreTable *hst ) {
00061         highScores = hst;
00062     }
00063 
00064     /*************************************************/
00065     /* SET GAMEDUINO ON WHICH GRAPHICS WILL BE DRAWN */
00066     /*************************************************/
00067     // Pass pointer to a Gameduino.
00068     void SetGameduino( Gameduino *g ) {
00069         gd = g;
00070     }
00071                 
00072     /***************************************/
00073     /* SET PLAYER WHO IS PLAYING THE LEVEL */
00074     /***************************************/
00075     // Pass pointer to player in p.
00076     void SetPlayer( PlayerObject *p ) {
00077       player = p;
00078     }
00079     
00080     // Enumeration of reasons why level ended.
00081     enum LevelExitCode {
00082       Completed,       // level was completed
00083       GameOver,        // player has no more lives
00084     };
00085     
00086     /**************/
00087     /* PLAY LEVEL */
00088     /**************/
00089     // Returns code indicating how level ended.
00090     virtual LevelExitCode Play( void ) = 0;
00091     
00092   protected :
00093   
00094     // Pointer to high score table.
00095     HighScoreTable *highScores;
00096         
00097     // Gameduino on which level is played.
00098     Gameduino *gd;
00099     
00100     // Player playing the level.
00101     PlayerObject *player;
00102     
00103     /*************/
00104     /* PLAY LOOP */
00105     /*************/
00106     // Returns code indicating how level ended.
00107     // This method should be called from the Play method after the
00108     // level data has been initialised and the return value returned
00109     // by the Play method.
00110     virtual LevelExitCode PlayLoop( void ) = 0;
00111 
00112   };
00113 
00114 #endif
00115 
00116 /* END of Level.h */
00117