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:
Sat Jun 08 16:44:54 2013 +0000
Revision:
7:e72691603fd3
Now have grunts wandering around on level 1. They follow the player but since no collision detection logic yet nobody ever gets killed.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RichardE 7:e72691603fd3 1 /*
RichardE 7:e72691603fd3 2 * SOURCE FILE : HumanObject.h
RichardE 7:e72691603fd3 3 *
RichardE 7:e72691603fd3 4 * Represents a wandering human.
RichardE 7:e72691603fd3 5 *
RichardE 7:e72691603fd3 6 */
RichardE 7:e72691603fd3 7
RichardE 7:e72691603fd3 8 #ifndef HumanObjectIncluded
RichardE 7:e72691603fd3 9
RichardE 7:e72691603fd3 10 #define HumanObjectIncluded
RichardE 7:e72691603fd3 11
RichardE 7:e72691603fd3 12 #include "Types.h"
RichardE 7:e72691603fd3 13 #include "GameObject.h"
RichardE 7:e72691603fd3 14 #include "GameObjectTypes.h"
RichardE 7:e72691603fd3 15
RichardE 7:e72691603fd3 16 class HumanObject : public GameObject {
RichardE 7:e72691603fd3 17
RichardE 7:e72691603fd3 18 public :
RichardE 7:e72691603fd3 19
RichardE 7:e72691603fd3 20 // States a human can be in.
RichardE 7:e72691603fd3 21 // Each human starts in the WalkingAbout state and keeps wandering around as
RichardE 7:e72691603fd3 22 // long as it is in this state.
RichardE 7:e72691603fd3 23 // If the player touches a human than it changes to the Rescued state and
RichardE 7:e72691603fd3 24 // it stops walking and its appearance changes to show the number of points
RichardE 7:e72691603fd3 25 // awarded. Eventually this disappears and the Visible property inherited from
RichardE 7:e72691603fd3 26 // GameObject is set to false. On next draw the human will be removed from the
RichardE 7:e72691603fd3 27 // array of humans and replaced with NULL.
RichardE 7:e72691603fd3 28 enum State {
RichardE 7:e72691603fd3 29 WalkingAbout,
RichardE 7:e72691603fd3 30 Rescued,
RichardE 7:e72691603fd3 31 Dead,
RichardE 7:e72691603fd3 32 };
RichardE 7:e72691603fd3 33
RichardE 7:e72691603fd3 34 // Different kinds of human.
RichardE 7:e72691603fd3 35 enum HumanType {
RichardE 7:e72691603fd3 36 Woman,
RichardE 7:e72691603fd3 37 Man,
RichardE 7:e72691603fd3 38 };
RichardE 7:e72691603fd3 39
RichardE 7:e72691603fd3 40 // Current state of human.
RichardE 7:e72691603fd3 41 State CurrentState;
RichardE 7:e72691603fd3 42
RichardE 7:e72691603fd3 43 /***************/
RichardE 7:e72691603fd3 44 /* CONSTRUCTOR */
RichardE 7:e72691603fd3 45 /***************/
RichardE 7:e72691603fd3 46 HumanObject();
RichardE 7:e72691603fd3 47
RichardE 7:e72691603fd3 48 /**************/
RichardE 7:e72691603fd3 49 /* DESTRUCTOR */
RichardE 7:e72691603fd3 50 /**************/
RichardE 7:e72691603fd3 51 virtual ~HumanObject();
RichardE 7:e72691603fd3 52
RichardE 7:e72691603fd3 53 /************************/
RichardE 7:e72691603fd3 54 /* GET GAME OBJECT TYPE */
RichardE 7:e72691603fd3 55 /************************/
RichardE 7:e72691603fd3 56 // Returns type of game object.
RichardE 7:e72691603fd3 57 virtual GameObjectTypes GetType( void ) {
RichardE 7:e72691603fd3 58 return HumanObjectType;
RichardE 7:e72691603fd3 59 }
RichardE 7:e72691603fd3 60
RichardE 7:e72691603fd3 61 /*****************************/
RichardE 7:e72691603fd3 62 /* GET TYPE OF HUMAN THIS IS */
RichardE 7:e72691603fd3 63 /*****************************/
RichardE 7:e72691603fd3 64 // Returns type of human.
RichardE 7:e72691603fd3 65 HumanType GetHumanType( void );
RichardE 7:e72691603fd3 66
RichardE 7:e72691603fd3 67 /************************/
RichardE 7:e72691603fd3 68 /* MOVE THE GAME OBJECT */
RichardE 7:e72691603fd3 69 /************************/
RichardE 7:e72691603fd3 70 virtual void ProtectedMove( void );
RichardE 7:e72691603fd3 71
RichardE 7:e72691603fd3 72 /************************/
RichardE 7:e72691603fd3 73 /* DRAW THE GAME OBJECT */
RichardE 7:e72691603fd3 74 /************************/
RichardE 7:e72691603fd3 75 // Pass pointer to Gameduino to draw on in gd.
RichardE 7:e72691603fd3 76 // This is only called after it has been established that the
RichardE 7:e72691603fd3 77 // game object is visible.
RichardE 7:e72691603fd3 78 virtual void Draw( Gameduino *gd );
RichardE 7:e72691603fd3 79
RichardE 7:e72691603fd3 80 private :
RichardE 7:e72691603fd3 81
RichardE 7:e72691603fd3 82 // Address of animation data in program memory.
RichardE 7:e72691603fd3 83 const UInt8 *animationData;
RichardE 7:e72691603fd3 84
RichardE 7:e72691603fd3 85 // Horizontal and vertical velocities.
RichardE 7:e72691603fd3 86 Int16 hSpeed, vSpeed;
RichardE 7:e72691603fd3 87
RichardE 7:e72691603fd3 88 // Countdown used when in rescued or dead states.
RichardE 7:e72691603fd3 89 UInt8 countdown;
RichardE 7:e72691603fd3 90
RichardE 7:e72691603fd3 91 // Index of next animation to use when constructing.
RichardE 7:e72691603fd3 92 // Cycles around all human animations.
RichardE 7:e72691603fd3 93 static UInt8 nextAnimationIndex;
RichardE 7:e72691603fd3 94
RichardE 7:e72691603fd3 95 };
RichardE 7:e72691603fd3 96
RichardE 7:e72691603fd3 97 #endif
RichardE 7:e72691603fd3 98
RichardE 7:e72691603fd3 99 /* END of HumanObject.h */
RichardE 7:e72691603fd3 100