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 15 15:05:19 2013 +0000
Revision:
15:d8ea0c7b7e64
Child:
16:d0b142ba4362
Started adding code to represent a grid of rectangles which is used on high score entry screen. See FieldGrid, FieldRow and FieldCell classes and use in HighScoreEntry.cpp.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RichardE 15:d8ea0c7b7e64 1 /*
RichardE 15:d8ea0c7b7e64 2 * SOURCE FILE : FieldRow.h
RichardE 15:d8ea0c7b7e64 3 *
RichardE 15:d8ea0c7b7e64 4 * Definition of class FieldRow.
RichardE 15:d8ea0c7b7e64 5 *
RichardE 15:d8ea0c7b7e64 6 */
RichardE 15:d8ea0c7b7e64 7
RichardE 15:d8ea0c7b7e64 8 #ifndef FieldRowDefined
RichardE 15:d8ea0c7b7e64 9
RichardE 15:d8ea0c7b7e64 10 #define FieldRowDefined
RichardE 15:d8ea0c7b7e64 11
RichardE 15:d8ea0c7b7e64 12 #include "FieldCell.h"
RichardE 15:d8ea0c7b7e64 13
RichardE 15:d8ea0c7b7e64 14 class FieldRow {
RichardE 15:d8ea0c7b7e64 15
RichardE 15:d8ea0c7b7e64 16 public :
RichardE 15:d8ea0c7b7e64 17
RichardE 15:d8ea0c7b7e64 18 /***************/
RichardE 15:d8ea0c7b7e64 19 /* CONSTRUCTOR */
RichardE 15:d8ea0c7b7e64 20 /***************/
RichardE 15:d8ea0c7b7e64 21 FieldRow();
RichardE 15:d8ea0c7b7e64 22
RichardE 15:d8ea0c7b7e64 23 /**************/
RichardE 15:d8ea0c7b7e64 24 /* DESTRUCTOR */
RichardE 15:d8ea0c7b7e64 25 /**************/
RichardE 15:d8ea0c7b7e64 26 virtual ~FieldRow();
RichardE 15:d8ea0c7b7e64 27
RichardE 15:d8ea0c7b7e64 28 /*************************/
RichardE 15:d8ea0c7b7e64 29 /* ADD A CELL TO THE ROW */
RichardE 15:d8ea0c7b7e64 30 /*************************/
RichardE 15:d8ea0c7b7e64 31 // Pass cell to add in cell.
RichardE 15:d8ea0c7b7e64 32 // The cell being added must have been dynamically allocated!
RichardE 15:d8ea0c7b7e64 33 void AddCell( FieldCell *cell );
RichardE 15:d8ea0c7b7e64 34
RichardE 15:d8ea0c7b7e64 35 /*************************/
RichardE 15:d8ea0c7b7e64 36 /* GET FIRST CELL IN ROW */
RichardE 15:d8ea0c7b7e64 37 /*************************/
RichardE 15:d8ea0c7b7e64 38 // Returns pointer to first cell or NULL if no cells in row.
RichardE 15:d8ea0c7b7e64 39 FieldCell *GetFirstCell( void ) {
RichardE 15:d8ea0c7b7e64 40 FieldCell *result = root.GetNext();
RichardE 15:d8ea0c7b7e64 41 if( result == (FieldCell*)NULL ) {
RichardE 15:d8ea0c7b7e64 42 nextCell = (FieldCell*)NULL;
RichardE 15:d8ea0c7b7e64 43 }
RichardE 15:d8ea0c7b7e64 44 else {
RichardE 15:d8ea0c7b7e64 45 nextCell = result->GetNext();
RichardE 15:d8ea0c7b7e64 46 }
RichardE 15:d8ea0c7b7e64 47 return result;
RichardE 15:d8ea0c7b7e64 48 }
RichardE 15:d8ea0c7b7e64 49
RichardE 15:d8ea0c7b7e64 50 /************************/
RichardE 15:d8ea0c7b7e64 51 /* GET NEXT CELL IN ROW */
RichardE 15:d8ea0c7b7e64 52 /************************/
RichardE 15:d8ea0c7b7e64 53 // Returns pointer to NEXT cell or NULL if no MORE cells in row.
RichardE 15:d8ea0c7b7e64 54 FieldCell *GetNextCell( void ) {
RichardE 15:d8ea0c7b7e64 55 FieldCell *result = nextCell;
RichardE 15:d8ea0c7b7e64 56 if( result != (FieldCell*)NULL ) {
RichardE 15:d8ea0c7b7e64 57 nextCell = result->GetNext();
RichardE 15:d8ea0c7b7e64 58 }
RichardE 15:d8ea0c7b7e64 59 return result;
RichardE 15:d8ea0c7b7e64 60 }
RichardE 15:d8ea0c7b7e64 61
RichardE 15:d8ea0c7b7e64 62 /**********************************************/
RichardE 15:d8ea0c7b7e64 63 /* GET CELL AT PARTICULAR POSITION IN THE ROW */
RichardE 15:d8ea0c7b7e64 64 /**********************************************/
RichardE 15:d8ea0c7b7e64 65 // Pass index of cell in pos.
RichardE 15:d8ea0c7b7e64 66 // Returns pointer to cell or NULL if no cell at given index.
RichardE 15:d8ea0c7b7e64 67 FieldCell *GetCellAt( UInt8 pos ) {
RichardE 15:d8ea0c7b7e64 68 FieldCell *result = GetFirstCell();
RichardE 15:d8ea0c7b7e64 69 while( ( pos > 0 ) && ( result != (FieldCell*)NULL ) ) {
RichardE 15:d8ea0c7b7e64 70 result = GetNextCell();
RichardE 15:d8ea0c7b7e64 71 pos--;
RichardE 15:d8ea0c7b7e64 72 }
RichardE 15:d8ea0c7b7e64 73 return result;
RichardE 15:d8ea0c7b7e64 74 }
RichardE 15:d8ea0c7b7e64 75
RichardE 15:d8ea0c7b7e64 76 private :
RichardE 15:d8ea0c7b7e64 77
RichardE 15:d8ea0c7b7e64 78 // The root cell of the row.
RichardE 15:d8ea0c7b7e64 79 // Does not contain any useful data and never gets deleted.
RichardE 15:d8ea0c7b7e64 80 FieldCell root;
RichardE 15:d8ea0c7b7e64 81
RichardE 15:d8ea0c7b7e64 82 // Pointer used when scanning through row cells.
RichardE 15:d8ea0c7b7e64 83 FieldCell *nextCell;
RichardE 15:d8ea0c7b7e64 84
RichardE 15:d8ea0c7b7e64 85 };
RichardE 15:d8ea0c7b7e64 86
RichardE 15:d8ea0c7b7e64 87 #endif
RichardE 15:d8ea0c7b7e64 88
RichardE 15:d8ea0c7b7e64 89 /* END of FieldRow.h */
RichardE 15:d8ea0c7b7e64 90
RichardE 15:d8ea0c7b7e64 91