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 19:27:36 2013 +0000
Revision:
16:d0b142ba4362
Parent:
15:d8ea0c7b7e64
Entering of high scores nearly there. Just requires code to allow you to backspace and confirm when you have finished.

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 16:d0b142ba4362 75
RichardE 16:d0b142ba4362 76 /********************************/
RichardE 16:d0b142ba4362 77 /* GET NUMBER OF COLUMNS IN ROW */
RichardE 16:d0b142ba4362 78 /********************************/
RichardE 16:d0b142ba4362 79 // Returns number of columns in row.
RichardE 16:d0b142ba4362 80 UInt8 GetColumnCount( void ) {
RichardE 16:d0b142ba4362 81 UInt8 count = 0;
RichardE 16:d0b142ba4362 82 FieldCell *cell = GetFirstCell();
RichardE 16:d0b142ba4362 83 while( cell != (FieldCell*)NULL ) {
RichardE 16:d0b142ba4362 84 count++;
RichardE 16:d0b142ba4362 85 cell = GetNextCell();
RichardE 16:d0b142ba4362 86 }
RichardE 16:d0b142ba4362 87 return count;
RichardE 16:d0b142ba4362 88 }
RichardE 16:d0b142ba4362 89
RichardE 15:d8ea0c7b7e64 90 private :
RichardE 15:d8ea0c7b7e64 91
RichardE 15:d8ea0c7b7e64 92 // The root cell of the row.
RichardE 15:d8ea0c7b7e64 93 // Does not contain any useful data and never gets deleted.
RichardE 15:d8ea0c7b7e64 94 FieldCell root;
RichardE 15:d8ea0c7b7e64 95
RichardE 15:d8ea0c7b7e64 96 // Pointer used when scanning through row cells.
RichardE 15:d8ea0c7b7e64 97 FieldCell *nextCell;
RichardE 15:d8ea0c7b7e64 98
RichardE 15:d8ea0c7b7e64 99 };
RichardE 15:d8ea0c7b7e64 100
RichardE 15:d8ea0c7b7e64 101 #endif
RichardE 15:d8ea0c7b7e64 102
RichardE 15:d8ea0c7b7e64 103 /* END of FieldRow.h */
RichardE 15:d8ea0c7b7e64 104
RichardE 15:d8ea0c7b7e64 105