#include <TPlayersShip.h>
Inheritance diagram for TPlayersShip:


Public Methods | |
| TPlayersShip (TInt16 aX, TInt16 aY, TInt16 aHealth, TInt16 aShipSprite, TInt16 aCrashingStartSprite, TInt16 aCrashingEndSprite) | |
| Construct a players ship. More... | |
| void | AddHealth (TInt16 aHealth) |
| Change players health. More... | |
| void | SetHealth (TInt16 aHealth) |
| Set players health. More... | |
| TInt16 | Health () |
| Query players health. More... | |
| TBool | Dieing () |
| Is the ship currently exploding. More... | |
| TBool | Dead () |
| Is the ship dead. More... | |
| void | MoveBy (TInt16 aX, TInt16 aY, TBool aAllowOfScreen) |
| Handles movement of players ship. More... | |
Private Methods | |
| void | UpdateSprite () |
| Update sprite. More... | |
Private Attributes | |
| TInt16 | iHealth |
| Players health, <=0 is dead. More... | |
| TInt16 | iCrashFrame |
| which explosion sprite to plot while dieing. More... | |
| TInt16 | iShipSprite |
| sprite of healthy ship. More... | |
| TInt16 | iCrashingStartSprite |
| sprite thats starts explosion. More... | |
| TInt16 | iCrashingEndSprite |
| last sprite of explosion animation. More... | |
| TInt16 | iLastX |
| last position. More... | |
| TInt16 | iLastY |
| last position. More... | |
Handles movement, it keeps the ship sprite within the visible area of the the offscreen map. It also keeps track of the health of the ship, changing the ship sprite to each of the explosion sprites in turn when the health drops to zero.
Definition at line 27 of file TPlayersShip.h.
|
||||||||||||||||||||||||||||
|
Construct a players ship.
Definition at line 26 of file TPlayersShip.cpp. References iLastX, iLastY, TSprite32x24::iX, TSprite32x24::iY, and UpdateSprite().
00028 : 00029 iHealth(aHealth), iCrashFrame(0), 00030 iShipSprite(aShipSprite), 00031 iCrashingStartSprite(aCrashingStartSprite), 00032 iCrashingEndSprite(aCrashingEndSprite) { 00033 00034 iX=aX; 00035 iY=aY; 00036 iLastX=aX; 00037 iLastY=aY; 00038 UpdateSprite(); 00039 } |
|
|
Change players health. Is iHealth <= 0 player is dead and explosion animation starts. Definition at line 64 of file TPlayersShip.cpp. References iHealth, and SetHealth(). Referenced by TBadGuy::HitShip().
|
|
|
Set players health. Is aHealth <= 0 player is dead and explosion animation starts. Definition at line 74 of file TPlayersShip.cpp. References iCrashFrame, iHealth, and UpdateSprite(). Referenced by AddHealth(), TBadGuy::HitShip(), and CGame::Play().
00074 {
00075 if(iCrashFrame==0) {
00076 iHealth=aHealth;
00077 if(iHealth <= 0) {
00078 iHealth=0;
00079 iCrashFrame=2;
00080 }
00081 UpdateSprite();
00082 }
00083 }
|
|
|
Query players health.
Definition at line 91 of file TPlayersShip.cpp. References iHealth. Referenced by CGame::Play().
00091 {
00092 return iHealth;
00093 }
|
|
|
Is the ship currently exploding. This is used to stop the player finishing the level or shooting while the ship is exploding.
Definition at line 104 of file TPlayersShip.cpp. References iCrashFrame. Referenced by CGame::HandleKeys(), and CGame::Play().
00104 {
00105 return iCrashFrame == 0 ? EFalse : ETrue;
00106 }
|
|
|
Is the ship dead.
Definition at line 114 of file TPlayersShip.cpp. References iCrashFrame, iCrashingEndSprite, and iCrashingStartSprite. Referenced by CGame::Play().
00114 {
00115 TInt16 spriteNo=iCrashingStartSprite+((iCrashFrame/2)-1);
00116 if(spriteNo <= iCrashingEndSprite) {
00117 return EFalse;
00118 } else {
00119 return ETrue;
00120 }
00121 }
|
|
||||||||||||||||
|
Handles movement of players ship. Called for for each frame of the game. The function is used to both move the ship and to animate the explossion of the ship. It could also be used to provide an animated ship, or different ships when the player is moving in different directions, saves last x and y positions so we could do bouncing of bad guys.
Definition at line 139 of file TPlayersShip.cpp. References iCrashFrame, iLastX, iLastY, TSprite32x24::iX, TSprite32x24::iY, and UpdateSprite(). Referenced by CGame::HandleKeys().
00139 {
00140 iLastX=iX;
00141 iLastY=iY;
00142 iX+=aX;
00143 iY+=aY;
00144 if(iY<0) iY=0;
00145 if(iY>176) iY=176;
00146 if(iX<16) iX=16;
00147
00148 // allow player to fly off screen at end of level
00149 if(aAllowOfScreen!=EFalse) {
00150 if(iX>304) iX=304;
00151 } else {
00152 if(iX>288) iX=288;
00153 }
00154
00155 // if crashing animate,
00156 if(iCrashFrame!=0) {
00157 iCrashFrame++;
00158 }
00159 UpdateSprite();
00160 }
|
|
|
Update sprite. Either set the sprite to the healthy ship or the correct frame of the explossion. Definition at line 48 of file TPlayersShip.cpp. References iCrashFrame, iCrashingEndSprite, iCrashingStartSprite, iShipSprite, and TSprite32x24::SetSpriteNo(). Referenced by MoveBy(), SetHealth(), and TPlayersShip().
00048 {
00049 if(iCrashFrame!=0) {
00050 TInt16 spriteNo=iCrashingStartSprite+((iCrashFrame/2)-1);
00051 if(spriteNo <= iCrashingEndSprite)
00052 SetSpriteNo(spriteNo);
00053 } else {
00054 SetSpriteNo(iShipSprite);
00055 }
00056 }
|
|
|
Players health, <=0 is dead.
Definition at line 43 of file TPlayersShip.h. |
|
|
which explosion sprite to plot while dieing.
Definition at line 44 of file TPlayersShip.h. Referenced by Dead(), Dieing(), MoveBy(), SetHealth(), and UpdateSprite(). |
|
|
sprite of healthy ship.
Definition at line 45 of file TPlayersShip.h. Referenced by UpdateSprite(). |
|
|
sprite thats starts explosion.
Definition at line 46 of file TPlayersShip.h. Referenced by Dead(), and UpdateSprite(). |
|
|
last sprite of explosion animation.
Definition at line 47 of file TPlayersShip.h. Referenced by Dead(), and UpdateSprite(). |
|
|
last position.
Definition at line 48 of file TPlayersShip.h. Referenced by MoveBy(), and TPlayersShip(). |
|
|
last position.
Definition at line 49 of file TPlayersShip.h. Referenced by MoveBy(), and TPlayersShip(). |