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 14:40:47 2013 +0000
Revision:
5:0b0651ac7832
Parent:
4:673eb9735d44
Now got first real level starting and player can be controlled using joysticks. No bullets, enemies, humans or sound yet.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RichardE 4:673eb9735d44 1 /*
RichardE 4:673eb9735d44 2 * SOURCE FILE : BulletObject.h
RichardE 4:673eb9735d44 3 *
RichardE 4:673eb9735d44 4 * Represents a bullet type objects with horizontal and vertical velocities.
RichardE 4:673eb9735d44 5 *
RichardE 4:673eb9735d44 6 */
RichardE 4:673eb9735d44 7
RichardE 4:673eb9735d44 8 #ifndef BulletObjectIncluded
RichardE 4:673eb9735d44 9
RichardE 4:673eb9735d44 10 #define BulletObjectIncluded
RichardE 4:673eb9735d44 11
RichardE 4:673eb9735d44 12 #include "Gameduino.h"
RichardE 4:673eb9735d44 13 #include "GameObject.h"
RichardE 4:673eb9735d44 14 #include "SpriteImageId.h"
RichardE 4:673eb9735d44 15 #include "SpriteGroup.h"
RichardE 4:673eb9735d44 16
RichardE 4:673eb9735d44 17 class BulletObject : public GameObject {
RichardE 4:673eb9735d44 18
RichardE 4:673eb9735d44 19 public :
RichardE 4:673eb9735d44 20
RichardE 4:673eb9735d44 21 /***************/
RichardE 4:673eb9735d44 22 /* CONSTRUCTOR */
RichardE 4:673eb9735d44 23 /***************/
RichardE 4:673eb9735d44 24 BulletObject() :
RichardE 4:673eb9735d44 25 imageNumber( PlayerBulletImage ),
RichardE 4:673eb9735d44 26 spriteGroup( GoodGuy )
RichardE 4:673eb9735d44 27 {
RichardE 4:673eb9735d44 28 DeleteWhenRestricted = true;
RichardE 4:673eb9735d44 29 }
RichardE 4:673eb9735d44 30
RichardE 4:673eb9735d44 31 /**************/
RichardE 4:673eb9735d44 32 /* DESTRUCTOR */
RichardE 4:673eb9735d44 33 /**************/
RichardE 4:673eb9735d44 34 virtual ~BulletObject() {
RichardE 4:673eb9735d44 35 }
RichardE 4:673eb9735d44 36
RichardE 4:673eb9735d44 37 /************************/
RichardE 4:673eb9735d44 38 /* GET GAME OBJECT TYPE */
RichardE 4:673eb9735d44 39 /************************/
RichardE 4:673eb9735d44 40 // Returns type of game object.
RichardE 4:673eb9735d44 41 virtual GameObjectTypes GetType( void ) {
RichardE 4:673eb9735d44 42 return BulletObjectType;
RichardE 4:673eb9735d44 43 }
RichardE 4:673eb9735d44 44
RichardE 4:673eb9735d44 45 /****************/
RichardE 4:673eb9735d44 46 /* START BULLET */
RichardE 4:673eb9735d44 47 /****************/
RichardE 4:673eb9735d44 48 void Start( Int16 x, Int16 y, Int16 hv, Int16 vv ) {
RichardE 4:673eb9735d44 49 Xco = x;
RichardE 4:673eb9735d44 50 Yco = y;
RichardE 4:673eb9735d44 51 hSpeed = hv;
RichardE 4:673eb9735d44 52 vSpeed = vv;
RichardE 4:673eb9735d44 53 Visible = true;
RichardE 4:673eb9735d44 54 }
RichardE 4:673eb9735d44 55
RichardE 4:673eb9735d44 56 /************************/
RichardE 4:673eb9735d44 57 /* MOVE THE GAME OBJECT */
RichardE 4:673eb9735d44 58 /************************/
RichardE 4:673eb9735d44 59 virtual void ProtectedMove( void ) {
RichardE 4:673eb9735d44 60 Xco += hSpeed;
RichardE 4:673eb9735d44 61 Yco += vSpeed;
RichardE 4:673eb9735d44 62 }
RichardE 4:673eb9735d44 63
RichardE 4:673eb9735d44 64 /************************/
RichardE 4:673eb9735d44 65 /* DRAW THE GAME OBJECT */
RichardE 4:673eb9735d44 66 /************************/
RichardE 5:0b0651ac7832 67 // Pass pointer to Gameduino to draw on in gd.
RichardE 4:673eb9735d44 68 // This is only called after it has been established that the
RichardE 4:673eb9735d44 69 // game object is visible.
RichardE 5:0b0651ac7832 70 virtual void Draw( Gameduino *gd ) {
RichardE 5:0b0651ac7832 71 gd->sprite( SpriteNumber, ToPixel( Xco ), ToPixel( Yco ), imageNumber, 0, Gameduino::None, spriteGroup );
RichardE 4:673eb9735d44 72 }
RichardE 4:673eb9735d44 73
RichardE 4:673eb9735d44 74 private :
RichardE 4:673eb9735d44 75
RichardE 4:673eb9735d44 76 // Number of sprite image used for bullet.
RichardE 4:673eb9735d44 77 SpriteImageId imageNumber;
RichardE 4:673eb9735d44 78
RichardE 4:673eb9735d44 79 // Indicates whether these are good or bad bullets for
RichardE 4:673eb9735d44 80 // purposes of collision detection.
RichardE 4:673eb9735d44 81 SpriteGroup spriteGroup;
RichardE 4:673eb9735d44 82
RichardE 4:673eb9735d44 83 // Horizontal and vertical velocities.
RichardE 4:673eb9735d44 84 Int16 hSpeed, vSpeed;
RichardE 4:673eb9735d44 85
RichardE 4:673eb9735d44 86 };
RichardE 4:673eb9735d44 87
RichardE 4:673eb9735d44 88 #endif
RichardE 4:673eb9735d44 89
RichardE 4:673eb9735d44 90 /* END of BulletObject.h */
RichardE 4:673eb9735d44 91