Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 25LCxxx_SPI CommonTypes Gameduino mbed
BulletObject.h
00001 /* 00002 * SOURCE FILE : BulletObject.h 00003 * 00004 * Represents a bullet type objects with horizontal and vertical velocities. 00005 * 00006 */ 00007 00008 #ifndef BulletObjectIncluded 00009 00010 #define BulletObjectIncluded 00011 00012 #include "Gameduino.h" 00013 #include "GameObject.h" 00014 #include "SpriteImageId.h" 00015 #include "SpriteGroup.h" 00016 00017 class BulletObject : public GameObject { 00018 00019 public : 00020 00021 /***************/ 00022 /* CONSTRUCTOR */ 00023 /***************/ 00024 BulletObject() : 00025 imageNumber( PlayerBulletImage ), 00026 spriteGroup( GoodGuy ) 00027 { 00028 DeleteWhenRestricted = true; 00029 } 00030 00031 /**************/ 00032 /* DESTRUCTOR */ 00033 /**************/ 00034 virtual ~BulletObject() { 00035 } 00036 00037 /************************/ 00038 /* GET GAME OBJECT TYPE */ 00039 /************************/ 00040 // Returns type of game object. 00041 virtual GameObjectTypes GetType( void ) { 00042 return BulletObjectType; 00043 } 00044 00045 /****************/ 00046 /* START BULLET */ 00047 /****************/ 00048 void Start( Int16 x, Int16 y, Int16 hv, Int16 vv ) { 00049 Xco = x; 00050 Yco = y; 00051 hSpeed = hv; 00052 vSpeed = vv; 00053 Visible = true; 00054 } 00055 00056 /************************/ 00057 /* MOVE THE GAME OBJECT */ 00058 /************************/ 00059 virtual void ProtectedMove( void ) { 00060 Xco += hSpeed; 00061 Yco += vSpeed; 00062 } 00063 00064 /************************/ 00065 /* DRAW THE GAME OBJECT */ 00066 /************************/ 00067 // Pass pointer to Gameduino to draw on in gd. 00068 // This is only called after it has been established that the 00069 // game object is visible. 00070 virtual void Draw( Gameduino *gd ) { 00071 gd->sprite( SpriteNumber, ToPixel( Xco ), ToPixel( Yco ), imageNumber, 0, Gameduino::None, spriteGroup ); 00072 } 00073 00074 private : 00075 00076 // Number of sprite image used for bullet. 00077 SpriteImageId imageNumber; 00078 00079 // Indicates whether these are good or bad bullets for 00080 // purposes of collision detection. 00081 SpriteGroup spriteGroup; 00082 00083 // Horizontal and vertical velocities. 00084 Int16 hSpeed, vSpeed; 00085 00086 }; 00087 00088 #endif 00089 00090 /* END of BulletObject.h */ 00091
Generated on Tue Jul 12 2022 21:10:35 by
1.7.2