#include <RStatus.h>
Collaboration diagram for RStatus:

Public Methods | |
| RStatus () | |
| constructor. More... | |
| TInt | Open (const TUint16 *aStatusData) |
| Open a status panel. More... | |
| void | Close () |
| Close the status panel. More... | |
| void | Update (TInt aScore, TInt aLives, TInt aHealth) |
| Update status pane. More... | |
| void | Draw (TInt aScore, TInt aLives, TInt aHealth) |
| Redraw the whole status pane. More... | |
Private Methods | |
| void | UpdateSingle (TInt &aOffset, TInt &aSaved, TInt aNew) |
| Update a sprite status section. More... | |
Private Attributes | |
| RScreenUtils | iScreen |
| Utilities for drawing to screen memory. More... | |
| TInt | iSavedScore |
| Last score that was plotted. More... | |
| TInt | iSavedLives |
| Number of lives last time status was updated. More... | |
| TInt | iSavedHealth |
| Number of health last time status was updated. More... | |
| const TUint16 * | iStatusData |
| Status data, see class description. More... | |
This class handles drawing and updating the status pane, which contains the number of lives, health, and score the player has.
Draw() will cause the whole status pane to be rendered, Update() will only render what has changed since the last Draw()/Update(). If Update() is called and no previous Draw()/Update() has occured the whole pane will be rendered.
The status area is defined by the status section of the level file. This is a series of TUint16s these are:
first background sprites to be drawn when pane is first rendered: 1,offset to sprite,x size, ysize, x pos, ypos .... this list is terminated with a 0xffff
then the health status area: health sprite offset, sprite x size, sprite y size, background color, then a list of locations to draw the sprite x,y, x,y, ... terminated with 0xffff if the players health level is one then only the first location will be filled, two the first and second locations, etc. If the players health is greater that the number of locations then all locations are filled.
then there is the lives status area, this is the same format as the health status area.
then there is the location to draw the players score xpos, ypox, foreground color, background color.
then there is an alignment TInt16 if it is required to align to a 32 bit word boundary.
finally there is sprite data refered to by the offsets above. Sprite offsets are all from the start of the status data.
Definition at line 63 of file RStatus.h.
|
|
constructor.
Definition at line 20 of file RStatus.cpp.
00020 : iStatusData(NULL) { 00021 00022 } |
|
|
Open a status panel. This opens the RScreenUtils and remebers the status data. This does not plot the status pane on the screen.
Definition at line 33 of file RStatus.cpp. References iSavedHealth, iSavedLives, iSavedScore, iScreen, iStatusData, and RScreenUtils::Open(). Referenced by CGame::ConstructL().
00033 {
00034 TInt error=iScreen.Open();
00035 if(error==KErrNone) {
00036 iSavedScore=-1;
00037 iSavedLives=-1;
00038 iSavedHealth=-1;
00039 iStatusData=aStatusData;
00040 }
00041 return(error);
00042 }
|
|
|
Close the status panel.
Definition at line 45 of file RStatus.cpp. References RScreenUtils::Close(), iScreen, and iStatusData. Referenced by CGame::~CGame().
00045 {
00046 iScreen.Close();
00047 iStatusData=NULL;
00048 }
|
|
||||||||||||||||
|
Update status pane. Just update the bits that have changed by erasing or plotting more status sprites and erasing and replotting the score if it has changed.
Definition at line 76 of file RStatus.cpp. References RScreenUtils::DrawPicture(), RScreenUtils::TPicture::iData, iSavedHealth, iSavedLives, iSavedScore, iScreen, iStatusData, RScreenUtils::TPicture::iXPos, RScreenUtils::TPicture::iXSize, RScreenUtils::TPicture::iYPos, RScreenUtils::TPicture::iYSize, RScreenUtils::Number(), and UpdateSingle(). Referenced by Draw(), and CGame::Play().
00076 {
00077 if(iStatusData==NULL)
00078 return;
00079 TInt offset=0;
00080 if(iSavedScore==-1) {
00081 while(iStatusData[offset++]!=0xffff) {
00082 RScreenUtils::TPicture pics;
00083 pics.iData = iStatusData+(iStatusData[offset++]/2);
00084 pics.iXSize=iStatusData[offset++];
00085 pics.iYSize=iStatusData[offset++];
00086 pics.iXPos=iStatusData[offset++];
00087 pics.iYPos=iStatusData[offset++];
00088 iScreen.DrawPicture(pics);
00089 }
00090 } else {
00091 while(iStatusData[offset++]!=0xffff) {};
00092 }
00093
00094 UpdateSingle(offset,iSavedHealth,aHealth);
00095 // don't display the life the player is using
00096 UpdateSingle(offset,iSavedLives,aLives-1);
00097
00098 if(iSavedScore!=aScore) {
00099 TUint16 x;
00100 TUint16 y;
00101 x=iStatusData[offset++];
00102 y=iStatusData[offset++];
00103 TUint16 foreColor=iStatusData[offset++];
00104 TUint16 backColor=iStatusData[offset++];
00105 iScreen.Number(x,y,aScore,foreColor,backColor);
00106 iSavedScore=aScore;
00107 }
00108 }
|
|
||||||||||||||||
|
Redraw the whole status pane. Just resets the saved data to -1 and calls Update().
Definition at line 59 of file RStatus.cpp. References iSavedHealth, iSavedLives, iSavedScore, and Update(). Referenced by CGame::Play().
00059 {
00060 iSavedScore=-1;
00061 iSavedLives=-1;
00062 iSavedHealth=-1;
00063 Update(aScore,aLives,aHealth);
00064 }
|
|
||||||||||||||||
|
Update a sprite status section. This updates either the health or the lives depending on the position in the status data. The update is done by either plotting more sprites or erasing old ones.
Definition at line 122 of file RStatus.cpp. References RScreenUtils::BlankArea(), RScreenUtils::DrawPicture(), RScreenUtils::TBlank::iColor, RScreenUtils::TPicture::iData, iScreen, iStatusData, RScreenUtils::TBlank::iXPos, RScreenUtils::TPicture::iXPos, RScreenUtils::TBlank::iXSize, RScreenUtils::TPicture::iXSize, RScreenUtils::TBlank::iYPos, RScreenUtils::TPicture::iYPos, RScreenUtils::TBlank::iYSize, and RScreenUtils::TPicture::iYSize. Referenced by Update().
00122 {
00123 RScreenUtils::TPicture picture;
00124 RScreenUtils::TBlank blank;
00125 picture.iData = iStatusData+(iStatusData[aOffset++]/2);
00126 picture.iXSize=iStatusData[aOffset++];
00127 blank.iXSize=picture.iXSize;
00128 picture.iYSize=iStatusData[aOffset++];
00129 blank.iYSize=picture.iYSize;
00130 blank.iColor=iStatusData[aOffset++];
00131 picture.iXPos=iStatusData[aOffset++];
00132 blank.iXPos=picture.iXPos;
00133 TInt pos=0;
00134 while(picture.iXPos!=0xffff) {
00135 picture.iYPos=iStatusData[aOffset++];
00136 blank.iYPos=picture.iYPos;
00137 pos++;
00138
00139 if(pos<=aNew && pos > aSaved)
00140 iScreen.DrawPicture(picture);
00141
00142 if(pos > aNew && pos <= aSaved)
00143 iScreen.BlankArea(blank);
00144
00145 picture.iXPos=iStatusData[aOffset++];
00146 blank.iXPos=picture.iXPos;
00147 }
00148 aSaved=aNew;
00149 }
|
|
|
Utilities for drawing to screen memory.
Definition at line 75 of file RStatus.h. Referenced by Close(), Open(), Update(), and UpdateSingle(). |
|
|
Last score that was plotted.
|
|
|
Number of lives last time status was updated.
|
|
|
Number of health last time status was updated.
|
|
|
Status data, see class description.
Definition at line 79 of file RStatus.h. Referenced by Close(), Open(), Update(), and UpdateSingle(). |