![](/media/cache/profiles/859bf1416b8b8761c5d588dee78dc65f.50x50_q85.jpg)
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: LevelNormal.cpp
- Revision:
- 12:81926431fea7
- Parent:
- 10:bfa1c307c99d
- Child:
- 13:50779b12ff51
--- a/LevelNormal.cpp Sun Jun 09 19:58:49 2013 +0000 +++ b/LevelNormal.cpp Mon Jun 10 20:02:28 2013 +0000 @@ -31,7 +31,7 @@ /* CONSTRUCTOR */ /***************/ // Pass pointer to level descriptor data in data parameter. -LevelNormal::LevelNormal( const UInt8 *data ) : +LevelNormal::LevelNormal( const LevelDescriptor *data ) : descriptorData( data ) { // Normal levels are always dynamically alocated. @@ -286,12 +286,12 @@ /**************/ // Returns code indicating how level ended. Level::LevelExitCode LevelNormal::Play( void ) { - UInt8 humanCount, enemyCount = 0; + UInt8 enemyCount = 0; GameObject **ptr = dataForLevel.Enemies; // Repeat for all enemy types. for( UInt8 et = 0; et < (int)EnemyTypeCount; ++et ) { // Get number of this enemy type on this level. - UInt8 eCount = LevelDescriptor::GetEnemyCount( descriptorData, (EnemyType)et ); + UInt8 eCount = descriptorData->GetEnemyCount( (EnemyType)et ); // Create required number of enemies. for( UInt8 eNum = 0; eNum < eCount; ++eNum ) { if( enemyCount < LevelData::MaxEnemies ) { @@ -303,11 +303,11 @@ } } } - // Humans. - #define HUMANCOUNT 6 - HumanObject humans[ HUMANCOUNT ]; + // Create required number of humans. + HumanObject humans[ LevelData::MaxHumans ]; ptr = dataForLevel.Humans; - humanCount = ( HUMANCOUNT > LevelData::MaxHumans ) ? LevelData::MaxHumans : HUMANCOUNT; + UInt8 humanCount = descriptorData->HumanCount; + humanCount = ( humanCount > LevelData::MaxHumans ) ? LevelData::MaxHumans : humanCount; for( UInt8 i = 0; i < humanCount; ++i ) { *ptr++ = humans + i; }