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: GameObject.cpp
- Revision:
- 5:0b0651ac7832
- Parent:
- 4:673eb9735d44
- Child:
- 6:8bbdb70bc11c
--- a/GameObject.cpp Sat Jun 08 11:24:05 2013 +0000 +++ b/GameObject.cpp Sat Jun 08 14:40:47 2013 +0000 @@ -46,16 +46,22 @@ // Pass number of pointers in the array in objectCount. // Returns true if any non-null objects were found in the array. bool GameObject::MoveAll( GameObject **objects, UInt8 objectCount ) { - GameObject *object; - bool foundNonNull = false; - for( UInt8 i = 0; i < objectCount; ++i ) { - object = objects[ i ]; - if( object != (GameObject*)NULL ) { - foundNonNull = true; - object->Move(); - } - } - return foundNonNull; + if( objects != (GameObject**)NULL ) { + GameObject *object; + bool foundNonNull = false; + for( UInt8 i = 0; i < objectCount; ++i ) { + object = objects[ i ]; + if( object != (GameObject*)NULL ) { + foundNonNull = true; + object->Move(); + } + } + return foundNonNull; + } + else { + // A null pointer was passed. Do nothing. + return false; + } } /****************************/