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
Diff: FieldRow.cpp
- Revision:
- 15:d8ea0c7b7e64
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FieldRow.cpp Sat Jun 15 15:05:19 2013 +0000 @@ -0,0 +1,50 @@ +/* + * SOURCE FILE : FieldRow.cpp + * + * Definition of class FieldRow. + * + */ + +#include "FieldRow.h" + +/***************/ +/* CONSTRUCTOR */ +/***************/ +FieldRow::FieldRow() : + nextCell( (FieldCell*)NULL ) +{ +} + +/**************/ +/* DESTRUCTOR */ +/**************/ +FieldRow::~FieldRow() +{ + // Free all the cells in the row starting at the one after the root cell. + FieldCell *ptr = root.GetNext(); + FieldCell *next; + while( ptr != (FieldCell*)NULL ) { + next = ptr->GetNext(); + delete ptr; + ptr = next; + } +} + +/*************************/ +/* ADD A CELL TO THE ROW */ +/*************************/ +// Pass cell to add in cell. +// The cell being added must have been dynamically allocated! +void FieldRow::AddCell( FieldCell *cell ) { + // Start at the root cell. + FieldCell *ptr = &root; + // Follow chain until you find a cell who has no next cell. + FieldCell *next; + while( ( next = ptr->GetNext() ) != (FieldCell*)NULL ) { + ptr = next; + } + // Make last cell point to new cell. + ptr->SetNext( cell ); + // Make new cell point to nothing since it is the last cell. + cell->SetNext( (FieldCell*)NULL ); +}