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

LevelDescriptor.cpp

Committer:
RichardE
Date:
2013-06-17
Revision:
18:70190f956a24
Parent:
12:81926431fea7

File content as of revision 18:70190f956a24:

/*
 * SOURCE FILE : LevelDescriptor.cpp
 *
 * Definition of class LevelDescriptor.
 * Describes a level.
 *
 */

#include "LevelDescriptor.h"

/*****************************************/
/* GET COUNT FOR A PARTICULAR ENEMY TYPE */
/*****************************************/
// Pass type of enemy to fetch count for in et.
// Returns number of enemies of the given type on this level.
UInt8 LevelDescriptor::GetEnemyCount( EnemyType et ) const {
    bool found = false;
    const UInt8 *data = EnemyData;
    while( ! found && ( *data != ENDDESCRIPTOR ) ) {
        if( *data == (UInt8)et ) {
            found = true;
        }
        else {
            data += 2;
        }
    }        
    if( found ) {
        return data[ 1 ];
    }
    else {
        return 0;
    }
}