#include <TSprite32x24.h>
Inheritance diagram for TSprite32x24:
Public Types | |
| enum | THit { EHitNone, EHitShip, EHitShipExtension, EHitLandScape, EHitBullet1, EHitBullet2, EHitBullet3, EHitBullet4, EHitBullet5, EHitBullet6, EHitBullet7, EHitBullet8 } |
| Enum describing what is under the sprite. More... | |
Public Methods | |
| TSprite32x24 () | |
| Constructor. More... | |
| void | Plot (CMap &aMap, const TUint16 *aSprites) |
| Plot the sprite to CMap. More... | |
| void | Remove () |
| Erases the sprite. More... | |
| THit | Hit () |
| Checks what the sprite was plotted over. More... | |
| void | SetSpriteNo (TInt16 aSpriteNo) |
| Sets the sprite number to plot. More... | |
| void | ClearSprite () |
| Set sprite number to -1. More... | |
| TBool | Used () |
| Is the sprite currently in use? More... | |
Public Attributes | |
| TInt16 | iX |
| X coordinate of the sprite. More... | |
| TInt16 | iY |
| Y coordinate of the sprite. More... | |
Protected Attributes | |
| TUint32 | iCollision |
| Collision information. More... | |
| TInt16 | iSpriteNo |
| Number of the sprite to plot. More... | |
Private Methods | |
| void | RemoveAsm () |
| Arm assembler to erase the sprite. More... | |
| TUint32 | PlotAsm (const TUint16 *aSpriteData) |
| Arm assembler to plot the sprite. More... | |
Private Attributes | |
| TUint16 * | iSpritePos |
| Memory location to plot the sprite. More... | |
| TUint16 * | iDrawEnd |
| End of offscreen map. More... | |
| TUint16 | iBehindSprite [32 *24] |
| Area behind the sprite. More... | |
This class plots a 32x24 pixel sprite onto the off screen map (class CMap). The Plot() function stores away the background behind the sprite so that the Remove() function can erase the sprite. The Plot() function checks the top four bits of each pixel of the background for collision information which can be queried with the Hit() member.
Definition at line 30 of file TSprite32x24.h.
|
|
Enum describing what is under the sprite.
Definition at line 33 of file TSprite32x24.h. Referenced by CGame::Collisions(), and Hit().
00033 {
00034 EHitNone,
00035 EHitShip,
00036 EHitShipExtension,
00037 EHitLandScape,
00038 EHitBullet1,
00039 EHitBullet2,
00040 EHitBullet3,
00041 EHitBullet4,
00042 EHitBullet5,
00043 EHitBullet6,
00044 EHitBullet7,
00045 EHitBullet8,
00046 };
|
|
|
Constructor.
Definition at line 20 of file TSprite32x24.cpp.
00020 : iSpritePos(NULL), 00021 iDrawEnd(NULL), 00022 iCollision(0), 00023 iSpriteNo(-1) { 00024 } |
|
||||||||||||
|
Plot the sprite to CMap.
Definition at line 36 of file TSprite32x24.cpp. References CMap::BlitStart(), CMap::DrawEnd(), TGamePanics::ESpriteNumberNotSet, iCollision, iDrawEnd, iSpriteNo, iSpritePos, iX, iY, TGamePanics::Panic(), and PlotAsm(). Referenced by CGame::DrawEveryThing().
00036 {
00037 __ASSERT_ALWAYS(iSpriteNo!=-1,TGamePanics::Panic(TGamePanics::ESpriteNumberNotSet));
00038
00039 // work out the location in the offscreen map to plot the sprite
00040 iDrawEnd=aMap.DrawEnd();
00041 iSpritePos= aMap.BlitStart()+(11*64*iY)+(iX*2);
00042
00043 // wrap at the end of the the offscreen map
00044 if(iSpritePos >= iDrawEnd)
00045 iSpritePos -= (11*64*200); // 11 64 pixel map sprites, 200 lines
00046
00047 // plot the sprite, storing away the background and checking
00048 // if the background contained a bullet/landscape/players ship etc.
00049 iCollision=PlotAsm(aSprites+(iSpriteNo*32*24));
00050 };
|
|
|
Erases the sprite.
Definition at line 59 of file TSprite32x24.cpp. References TGamePanics::ESpriteRemoveCalledWithoutPlot, iDrawEnd, iSpritePos, TGamePanics::Panic(), and RemoveAsm(). Referenced by CGame::RemoveEveryThing().
00059 {
00060 __ASSERT_ALWAYS(iSpritePos!=NULL && iDrawEnd!=NULL,TGamePanics::Panic(TGamePanics::ESpriteRemoveCalledWithoutPlot));
00061 // put the background back
00062 RemoveAsm();
00063 iSpritePos=NULL;
00064 iDrawEnd=NULL;
00065 }
|
|
|
Checks what the sprite was plotted over. Plot() stores away the logical or of each background pixel. The top four bits of each 16bit word of these are then used to determine what the sprite was plotted over. The top four bits of the top word are used for landscape, players ship, and ship extension. The top four bits of the bottom word are used for hitting the players bullets.
Definition at line 103 of file TSprite32x24.cpp. References EHitBullet1, EHitLandScape, EHitNone, EHitShip, EHitShipExtension, iCollision, and THit. Referenced by CGame::Collisions(), and CGame::Play().
00103 {
00104 // each two pixel word as 8 bits that aren't used for colour information
00105 // so this uses them to work out what it was behind the sprite
00106 if(iCollision & 0xf000 ) {
00107 return (THit) (((THit) ((iCollision & 0xf000) >> 12)-1) + EHitBullet1);
00108 } else if(iCollision & 0x80000000) {
00109 return EHitLandScape;
00110 } else if(iCollision & 0x20000000) {
00111 return EHitShip;
00112 } else if(iCollision & 0x40000000) {
00113 return EHitShipExtension;
00114 } else {
00115 return EHitNone;
00116 }
00117 };
|
|
|
Sets the sprite number to plot. Will be used by Plot() to select which sprite to draw. Definition at line 73 of file TSprite32x24.cpp. References iSpriteNo. Referenced by TBadGuy::Init(), TBadGuy::Move(), TBadGuy::PathMove(), TBullet::Shoot(), and TPlayersShip::UpdateSprite().
00073 {
00074 iSpriteNo = aSpriteNo;
00075 }
|
|
|
Set sprite number to -1. Plot() will panic if asked to draw the sprite. Used() will return EFalse if quiered. Definition at line 83 of file TSprite32x24.cpp. References iSpriteNo. Referenced by TBullet::AddHealth(), TBadGuy::Die(), TBadGuy::HitBullet(), TBullet::Move(), and TBadGuy::Move().
00083 {
00084 iSpriteNo = -1;
00085 }
|
|
|
Is the sprite currently in use?
Definition at line 89 of file TSprite32x24.cpp. References iSpriteNo. Referenced by CGame::AddBadGuy(), CGame::Collisions(), CGame::DamageBadGuys(), CGame::DrawEveryThing(), CGame::MoveThings(), CGame::RemoveEveryThing(), and CGame::Shoot().
00089 {
00090 return iSpriteNo < 0 ? EFalse : ETrue;
00091 }
|
|
|
Arm assembler to erase the sprite. Code copies sprite information from iBehindSprite to iSpritePos The remove will wrap back to the beginning of the draw area is drawing the sprite goes beyond iDrawEnd. defined in the file removesprite.s Referenced by Remove(). |
|
|
Arm assembler to plot the sprite. Code copies sprite information from aSpriteData to iSpritePos, stores the background in iBehindSprite. Will not write pixels that are all 0. The plot will wrap back to the beginning of the draw area is drawing the sprite goes beyond iDrawEnd. defined in the file sprite.s
Referenced by Plot(). |
|
|
Memory location to plot the sprite. Set up from iX and iY by Plot() and NULL'd by Remove(), Must be the first member of class or assembler routines sprites.s and remove_sprite.s muxt changed. Definition at line 64 of file TSprite32x24.h. |
|
|
End of offscreen map. Read from CMap by Plot() and NULL'd by Remove(), Must be the second member of class or assembler routines sprites.s and remove_sprite.s muxt changed. Definition at line 66 of file TSprite32x24.h. |
|
|
Area behind the sprite. Stored to by PlotAsm() and used by RemoveAsm() to erase the sprite, Must be the third member of class or assembler routines sprites.s and remove_sprite.s muxt changed. Definition at line 68 of file TSprite32x24.h. |
|
|
Collision information. Orr'd collection of the backgrounds overwritten during the last Plot, used by Hit() to calculate what the sprite was plotted over. Definition at line 72 of file TSprite32x24.h. |
|
|
Number of the sprite to plot.
Definition at line 74 of file TSprite32x24.h. Referenced by ClearSprite(), Plot(), SetSpriteNo(), and Used(). |
|
|
X coordinate of the sprite. Runs from 0->351 with 16->303 being the visible section of the screen. Each increment in iX is equal to 2 pixels ie one 32bit word Definition at line 77 of file TSprite32x24.h. Referenced by TBadGuy::Init(), TBullet::Move(), TBadGuy::Move(), TPlayersShip::MoveBy(), CGame::MoveThings(), TBadGuy::PathMove(), CGame::Play(), Plot(), TBullet::Shoot(), CGame::Shoot(), TBadGuy::SimpleMove(), and TPlayersShip::TPlayersShip(). |
|
|
Y coordinate of the sprite. Runs from -24->223 with 0->199 being the visible Definition at line 79 of file TSprite32x24.h. Referenced by TBadGuy::Init(), TBadGuy::Move(), TPlayersShip::MoveBy(), CGame::MoveThings(), TBadGuy::PathMove(), Plot(), TBullet::Shoot(), CGame::Shoot(), TBadGuy::SimpleMove(), and TPlayersShip::TPlayersShip(). |