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
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.cpp
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 #include "FieldRow.h"
RichardE 15:d8ea0c7b7e64 9
RichardE 15:d8ea0c7b7e64 10 /***************/
RichardE 15:d8ea0c7b7e64 11 /* CONSTRUCTOR */
RichardE 15:d8ea0c7b7e64 12 /***************/
RichardE 15:d8ea0c7b7e64 13 FieldRow::FieldRow() :
RichardE 15:d8ea0c7b7e64 14 nextCell( (FieldCell*)NULL )
RichardE 15:d8ea0c7b7e64 15 {
RichardE 15:d8ea0c7b7e64 16 }
RichardE 15:d8ea0c7b7e64 17
RichardE 15:d8ea0c7b7e64 18 /**************/
RichardE 15:d8ea0c7b7e64 19 /* DESTRUCTOR */
RichardE 15:d8ea0c7b7e64 20 /**************/
RichardE 15:d8ea0c7b7e64 21 FieldRow::~FieldRow()
RichardE 15:d8ea0c7b7e64 22 {
RichardE 15:d8ea0c7b7e64 23 // Free all the cells in the row starting at the one after the root cell.
RichardE 15:d8ea0c7b7e64 24 FieldCell *ptr = root.GetNext();
RichardE 15:d8ea0c7b7e64 25 FieldCell *next;
RichardE 15:d8ea0c7b7e64 26 while( ptr != (FieldCell*)NULL ) {
RichardE 15:d8ea0c7b7e64 27 next = ptr->GetNext();
RichardE 15:d8ea0c7b7e64 28 delete ptr;
RichardE 15:d8ea0c7b7e64 29 ptr = next;
RichardE 15:d8ea0c7b7e64 30 }
RichardE 15:d8ea0c7b7e64 31 }
RichardE 15:d8ea0c7b7e64 32
RichardE 15:d8ea0c7b7e64 33 /*************************/
RichardE 15:d8ea0c7b7e64 34 /* ADD A CELL TO THE ROW */
RichardE 15:d8ea0c7b7e64 35 /*************************/
RichardE 15:d8ea0c7b7e64 36 // Pass cell to add in cell.
RichardE 15:d8ea0c7b7e64 37 // The cell being added must have been dynamically allocated!
RichardE 15:d8ea0c7b7e64 38 void FieldRow::AddCell( FieldCell *cell ) {
RichardE 15:d8ea0c7b7e64 39 // Start at the root cell.
RichardE 15:d8ea0c7b7e64 40 FieldCell *ptr = &root;
RichardE 15:d8ea0c7b7e64 41 // Follow chain until you find a cell who has no next cell.
RichardE 15:d8ea0c7b7e64 42 FieldCell *next;
RichardE 15:d8ea0c7b7e64 43 while( ( next = ptr->GetNext() ) != (FieldCell*)NULL ) {
RichardE 15:d8ea0c7b7e64 44 ptr = next;
RichardE 15:d8ea0c7b7e64 45 }
RichardE 15:d8ea0c7b7e64 46 // Make last cell point to new cell.
RichardE 15:d8ea0c7b7e64 47 ptr->SetNext( cell );
RichardE 15:d8ea0c7b7e64 48 // Make new cell point to nothing since it is the last cell.
RichardE 15:d8ea0c7b7e64 49 cell->SetNext( (FieldCell*)NULL );
RichardE 15:d8ea0c7b7e64 50 }