📄 tbullet.cpp
字号:
// Copyright 2002 Kenneth Guy,
//
// TBullet.cpp
/** \file TBullet.cpp
implementation of class TBullet */
#include "TBullet.h"
/** Construct a new unused bullet */
TBullet::TBullet() : iSavedSpriteNo(-1), iSavedHealth(0) {
}
/** Set up the stength and sprite number for this bullet */
void TBullet::Set(TInt16 aSpriteNo, TInt16 aHealth) {
iSavedHealth=aHealth;
iSavedSpriteNo=aSpriteNo;
}
/** Start the bullet going
\param aX initial X position
\param aY initial Y position
*/
void TBullet::Shoot(TInt16 aX,TInt16 aY) {
iX=aX;
iY=aY;
SetSpriteNo(iSavedSpriteNo);
iHealth=iSavedHealth;
}
/** 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.
\param aHealth normally negative so damage done to bullet
*/
void TBullet::AddHealth(TInt16 aHealth) {
iHealth+=aHealth;
if(iHealth <= 0) {
iHealth=0;
ClearSprite();
}
}
/** Current health of bullet.
\return amount of damage the bullet can do.
*/
TInt16 TBullet::Health() {
return iHealth;
}
/** Health of newly created bullet of this type.
\return amount of health a bullet will have when shot */
TInt16 TBullet::Strength() {
return iSavedHealth;
}
/** 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.
*/
void TBullet::Move() {
iX+=8;
if(iX > 296) ClearSprite();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -