Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

TBullet Class Reference

Players bullets. More...

#include <TBullet.h>

Inheritance diagram for TBullet:

Inheritance graph
[legend]
Collaboration diagram for TBullet:

Collaboration graph
[legend]
List of all members.

Public Methods

 TBullet ()
 Construct a new unused bullet. More...

void Set (TInt16 aSpriteNo, TInt16 aHealth)
 Set up the stength and sprite number for this bullet. More...

void Shoot (TInt16 aX, TInt16 aY)
 Start the bullet going. More...

void AddHealth (TInt16 aHealth)
 Bullet has hit something so remove some health. More...

TInt16 Health ()
 Current health of bullet. More...

void Move ()
 move the bullet. More...

TInt16 Strength ()
 Health of newly created bullet of this type. More...


Private Attributes

TInt16 iHealth
 amount of damage the bullet will do before it expires. More...

TInt16 iSavedSpriteNo
 Sprite to use for this bullet. More...

TInt16 iSavedHealth
 Health of a new bullet of this type. More...


Detailed Description

Players bullets.

Definition at line 23 of file TBullet.h.


Constructor & Destructor Documentation

TBullet::TBullet  
 

Construct a new unused bullet.

Definition at line 19 of file TBullet.cpp.

00019                  : iSavedSpriteNo(-1), iSavedHealth(0) {
00020 
00021 }


Member Function Documentation

void TBullet::Set TInt16    aSpriteNo,
TInt16    aHealth
 

Set up the stength and sprite number for this bullet.

Definition at line 24 of file TBullet.cpp.

References iSavedHealth, and iSavedSpriteNo.

Referenced by CGame::Bonus(), and CGame::ConstructL().

00024                                                   {
00025   iSavedHealth=aHealth;
00026   iSavedSpriteNo=aSpriteNo;
00027 }

void TBullet::Shoot TInt16    aX,
TInt16    aY
 

Start the bullet going.

Parameters:
aX  initial X position
aY  initial Y position

Definition at line 34 of file TBullet.cpp.

References iHealth, iSavedHealth, iSavedSpriteNo, TSprite32x24::iX, TSprite32x24::iY, and TSprite32x24::SetSpriteNo().

Referenced by CGame::Shoot().

00034                                        {
00035   iX=aX;
00036   iY=aY;
00037   SetSpriteNo(iSavedSpriteNo);
00038   iHealth=iSavedHealth;
00039 }

void TBullet::AddHealth TInt16    aHealth
 

Bullet has hit something so remove some health.

Bullets are damaged by the same amount they damage other ships so the bullet will continue flying until it has damaged ships equal to its initial health or leaves the screen.

Parameters:
aHealth  normally negative so damage done to bullet

Definition at line 49 of file TBullet.cpp.

References TSprite32x24::ClearSprite(), and iHealth.

Referenced by TBadGuy::HitBullet().

00049                                       {
00050   iHealth+=aHealth;
00051   if(iHealth <= 0) {
00052     iHealth=0;
00053     ClearSprite();
00054   }
00055 }

TInt16 TBullet::Health  
 

Current health of bullet.

Returns:
amount of damage the bullet can do.

Definition at line 61 of file TBullet.cpp.

References iHealth.

Referenced by TBadGuy::HitBullet().

00061                        {
00062   return iHealth;
00063 }

void TBullet::Move  
 

move the bullet.

Called for each frame that the bullet has a valid sprite. Ie TSprite32x24::Used() return ETrue. If the bullet leaves the visible part of the screen it is cleared.

Definition at line 81 of file TBullet.cpp.

References TSprite32x24::ClearSprite(), and TSprite32x24::iX.

Referenced by CGame::MoveThings().

00081                    {
00082   iX+=8;
00083   if(iX > 296) ClearSprite();
00084 }

TInt16 TBullet::Strength  
 

Health of newly created bullet of this type.

Returns:
amount of health a bullet will have when shot

Definition at line 69 of file TBullet.cpp.

References iSavedHealth.

Referenced by CGame::Bonus().

00069                          {
00070   return iSavedHealth;
00071 }


Member Data Documentation

TInt16 TBullet::iHealth [private]
 

amount of damage the bullet will do before it expires.

Definition at line 35 of file TBullet.h.

Referenced by AddHealth(), Health(), and Shoot().

TInt16 TBullet::iSavedSpriteNo [private]
 

Sprite to use for this bullet.

Definition at line 36 of file TBullet.h.

Referenced by Set(), and Shoot().

TInt16 TBullet::iSavedHealth [private]
 

Health of a new bullet of this type.

Definition at line 37 of file TBullet.h.

Referenced by Set(), Shoot(), and Strength().


The documentation for this class was generated from the following files:
Documentation for Game (Beta) version 1.44.