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:
Sun Jun 09 19:34:56 2013 +0000
Revision:
10:bfa1c307c99d
Child:
12:81926431fea7
Changed how levels are represented so that dynamic allocation of memory is used. Maple version couldn't do this. Still only 2 levels. Use EnemyFactory whenever creating or destroying enemies.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RichardE 10:bfa1c307c99d 1 /*
RichardE 10:bfa1c307c99d 2 * SOURCE FILE : LevelDescriptor.cpp
RichardE 10:bfa1c307c99d 3 *
RichardE 10:bfa1c307c99d 4 * Definition of class LevelDescriptor.
RichardE 10:bfa1c307c99d 5 * Describes a level.
RichardE 10:bfa1c307c99d 6 *
RichardE 10:bfa1c307c99d 7 */
RichardE 10:bfa1c307c99d 8
RichardE 10:bfa1c307c99d 9 #include "LevelDescriptor.h"
RichardE 10:bfa1c307c99d 10
RichardE 10:bfa1c307c99d 11 /*****************************************/
RichardE 10:bfa1c307c99d 12 /* GET COUNT FOR A PARTICULAR ENEMY TYPE */
RichardE 10:bfa1c307c99d 13 /*****************************************/
RichardE 10:bfa1c307c99d 14 // Pass pointer to array containing data in data parameter.
RichardE 10:bfa1c307c99d 15 // The array alternates between enemy type and count and MUST
RichardE 10:bfa1c307c99d 16 // be terminated with a byte of value ENDDESCRIPTOR.
RichardE 10:bfa1c307c99d 17 // Pass type of enemy to fetch count for in et.
RichardE 10:bfa1c307c99d 18 // Returns number of enemies of the given type on this level.
RichardE 10:bfa1c307c99d 19 UInt8 LevelDescriptor::GetEnemyCount( const UInt8 *data, EnemyType et ) {
RichardE 10:bfa1c307c99d 20 bool found = false;
RichardE 10:bfa1c307c99d 21 while( ! found && ( *data != ENDDESCRIPTOR ) ) {
RichardE 10:bfa1c307c99d 22 if( *data == (UInt8)et ) {
RichardE 10:bfa1c307c99d 23 found = true;
RichardE 10:bfa1c307c99d 24 }
RichardE 10:bfa1c307c99d 25 else {
RichardE 10:bfa1c307c99d 26 data += 2;
RichardE 10:bfa1c307c99d 27 }
RichardE 10:bfa1c307c99d 28 }
RichardE 10:bfa1c307c99d 29 if( found ) {
RichardE 10:bfa1c307c99d 30 return data[ 1 ];
RichardE 10:bfa1c307c99d 31 }
RichardE 10:bfa1c307c99d 32 else {
RichardE 10:bfa1c307c99d 33 return 0;
RichardE 10:bfa1c307c99d 34 }
RichardE 10:bfa1c307c99d 35 }
RichardE 10:bfa1c307c99d 36