This is Quad that is controled by the user. More...
#include <Bongo.h>
Public Member Functions | |
| Bongo () | |
| ~Bongo () | |
| Arrow * | Fire () |
| Give an arrow object. | |
| void | AddArrow () |
| Get back arrow object. | |
| bool | IsVulnerable () |
| whether Bongo can be affected by ball hit | |
| void | SetLives (int nl) |
| Set number of lives. | |
| int | Lives () |
| Number of lives. | |
| int | Kill () |
| Kill (one life less) | |
| void | Free () |
| Bongo is released. | |
| Bongo () | |
| ~Bongo () | |
| Arrow * | Fire () |
| Give an arrow object. | |
| void | AddArrow () |
| Get back arrow object. | |
| bool | IsVulnerable () |
| whether Bongo can be affected by ball hit | |
| void | SetLives (int nl) |
| Set number of lives. | |
| int | Lives () |
| Number of lives. | |
| int | Kill () |
| Kill (one life less) | |
| void | Free () |
| Bongo is released. | |
Implementation of Quad and Quad_impl | |
| bool | Init (XRes *resource, XCongo *xcongo) |
| Read Quad from resource file. | |
| bool | Display () |
| Draw itself in global cotext. Since quads are intented to be used with opengl, drawing context is global. | |
| const char * | ClassName () const |
| Used for RTTI. | |
| bool | Forse (const double *forse) |
| bool | Init (XRes *resource, XCongo *xcongo) |
| Read Quad from resource file. | |
| bool | Display () |
| Draw itself in global cotext. Since quads are intented to be used with opengl, drawing context is global. | |
| const char * | ClassName () const |
| Used for RTTI. | |
| bool | Forse (const double *forse) |
Private Attributes | |
| bool | mbHasArrow |
| Whether arrow is available. | |
| int | mFlashingTime |
| How long bongo will be flashing when hit. | |
| int | mbFlashing |
| Whether bongo is flashing. | |
| time_t | mStartFlashing |
| When bongo started to flash. | |
| int | mFlashingPeriodFrames |
| How many frames will one flash sequence last. | |
| int | mbImmortal |
| Bongo can't be killed. | |
| int | mnLives |
| Number of lives left. | |
| int | mbCaptured |
| Whether bongo is captured. | |
| XRes * | mpArrowResource |
| Resource to load arrow from. | |
This is Quad that is controled by the user.
It can move only in X-Z access and shot Ball's with Arrows. It can be killed by Balls when it is hit 3 times.
| Bongo::Bongo | ( | ) |
Definition at line 12 of file Bongo.cpp.
: mpArrowResource(0), mbCaptured(false), mbFlashing(false) { }
| Bongo::~Bongo | ( | ) |
| Bongo::Bongo | ( | ) |
| Bongo::~Bongo | ( | ) |
| void Bongo::AddArrow | ( | ) |
Get back arrow object.
Bongo will not be able to shoot another arrow before it get it back.
Definition at line 156 of file Bongo.cpp.
References mbHasArrow.
Referenced by CollisionMaster::Collision().
{
mbHasArrow = true;
}
| void Bongo::AddArrow | ( | ) |
Get back arrow object.
Bongo will not be able to shoot another arrow before it get it back.
| const char * Bongo::ClassName | ( | ) | const [virtual] |
Used for RTTI.
Reimplemented from Quad_impl.
Definition at line 74 of file Bongo.cpp.
Referenced by CollisionMaster::Collision().
{
return "Bongo";
}
| const char* Bongo::ClassName | ( | ) | const [virtual] |
| bool Bongo::Display | ( | ) | [virtual] |
Draw itself in global cotext. Since quads are intented to be used with opengl, drawing context is global.
Reimplemented from Quad_impl.
Definition at line 96 of file Bongo.cpp.
References mbFlashing, mbHasArrow, Quad_impl::mColor, mFlashingPeriodFrames, Quad_impl::mPos, and Quad_impl::mSize.
{
// used for flashing
static int counter = 0;
counter++;
glPushMatrix();
// use two colors, one for non flashinga and one for
// flashing bongo
GLfloat cor[] = { mColor[0], mColor[1], mColor[2], 1.0 };
GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 };
if (mbFlashing && (counter/mFlashingPeriodFrames) % 2)
memcpy(cor, white, 3 * sizeof(GLfloat) );
// set material properties
GLfloat mat_specular[] = { cor[0], cor[1], cor[2], 1.0 };
GLfloat mat_shininess[] = { 50.0 };
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
// position and clip plane
glTranslatef(mPos[0], mPos[1], mPos[2]);
GLdouble eqn[] = { 0.0, -1.0, 0.0, mSize };
glClipPlane(GL_CLIP_PLANE1, eqn);
glRotatef(90, -1.0, 0.0, 0.0);
if (!mbHasArrow)
glEnable(GL_CLIP_PLANE1);
// draw bongo
glutSolidCone(mSize/2, 2 * mSize, int(mSize * 30), int(mSize * 22) ); /* draw sun */
if (!mbHasArrow)
glDisable(GL_CLIP_PLANE1);
glPopMatrix();
return true;
}
| bool Bongo::Display | ( | ) | [virtual] |
Draw itself in global cotext. Since quads are intented to be used with opengl, drawing context is global.
Reimplemented from Quad_impl.
| Arrow * Bongo::Fire | ( | ) |
Give an arrow object.
AddArrow must be called in order to Fire() again
Definition at line 84 of file Bongo.cpp.
References Arrow::Init(), mbHasArrow, and mpArrowResource.
Referenced by BongoOrthoMover::ProcessKey(), and BongoRealMover::ProcessKey().
{
if (!mbHasArrow)
return 0;
Arrow *carr = new Arrow(this);
carr->Init(mpArrowResource, 0);
mbHasArrow = false;
return carr;
}
| Arrow* Bongo::Fire | ( | ) |
Give an arrow object.
AddArrow must be called in order to Fire() again
| bool Bongo::Forse | ( | const double * | forse | ) |
| bool Bongo::Forse | ( | const double * | forse | ) |
| void Bongo::Free | ( | ) |
Bongo is released.
| void Bongo::Free | ( | ) |
Bongo is released.
Definition at line 172 of file Bongo.cpp.
References mbFlashing, Quad_impl::mPos, mStartFlashing, and Quad_impl::SetActive().
Referenced by Ball::Reincarnate().
{
SetActive(true); mStartFlashing = time(0);
mbFlashing = true; mPos[1] = 0.0;
}
| bool Bongo::Init | ( | XRes * | resource, |
| XCongo * | xcongo | ||
| ) | [virtual] |
Read Quad from resource file.
| resource | Resource file contained description of Quad object. |
| xcongo | Global settings file contained parameters not specific to this quad. |
Reimplemented from Quad_impl.
Definition at line 33 of file Bongo.cpp.
References XRes::DoubleValue(), XRes::IntValue(), LOGE, mbHasArrow, mbImmortal, Quad_impl::mColor, mFlashingPeriodFrames, mFlashingTime, mnLives, mpArrowResource, Quad_impl::mPos, and Quad_impl::mSize.
{
if (!resource->DoubleValue("mSize", &mSize) )
{
LOGE("reading Bongo size");
return false;
}
if (!resource->DoubleValue("mPos.mX", &mPos[0])
|| !resource->DoubleValue("mPos.mY",&mPos[1])
|| !resource->DoubleValue("mPos.mZ", &mPos[2]))
{
LOGE("reading Bongo position");
return false;
}
if (!resource->DoubleValue("mColor.red", &mColor[0])
|| !resource->DoubleValue("mColor.green",&mColor[1])
|| !resource->DoubleValue("mColor.blue", &mColor[2]))
{
LOGE("reading Bongo color");
return false;
}
double pom;
if (!resource->IntValue("mbImmortal", &mbImmortal)
|| !resource->IntValue("mnLives",&mnLives)
|| !resource->IntValue("mFlashingTime",&mFlashingTime)
|| !resource->DoubleValue("mFlashingPeriodFrames",&pom) )
{
LOGE("reading Bongo life settings");
return false;
}
mFlashingPeriodFrames = (int)ceil(pom);
mbHasArrow = true;
mpArrowResource = new XRes(resource, "mArrow");
return true;
}
| bool Bongo::Init | ( | XRes * | resource, |
| XCongo * | xcongo | ||
| ) | [virtual] |
| bool Bongo::IsVulnerable | ( | ) |
whether Bongo can be affected by ball hit
| bool Bongo::IsVulnerable | ( | ) |
whether Bongo can be affected by ball hit
we will this method to disable flashing as well, since it is called from Update method. It's not the best way though.
Definition at line 139 of file Bongo.cpp.
References mbFlashing, mbImmortal, mFlashingTime, and mStartFlashing.
Referenced by CollisionMaster::Collision().
{
if (mbImmortal)
return false;
if (!mbFlashing)
return true;
if (mStartFlashing + mFlashingTime > time(0))
return false;
// disable flashing
mbFlashing = false;
return true;
}
| int Bongo::Kill | ( | ) |
Kill (one life less)
| int Bongo::Kill | ( | ) |
Kill (one life less)
Definition at line 22 of file Bongo.cpp.
References mbFlashing, mnLives, and mStartFlashing.
Referenced by CollisionMaster::Collision().
{
if (mnLives > 1)
{
mStartFlashing = time(0);
mbFlashing = true;
}
return --mnLives;
}
| int Bongo::Lives | ( | ) |
Number of lives.
| int Bongo::Lives | ( | ) |
Number of lives.
Definition at line 166 of file Bongo.cpp.
References mnLives.
Referenced by Ball::Reincarnate().
{
return mnLives;
}
| void Bongo::SetLives | ( | int | nl | ) |
Set number of lives.
| void Bongo::SetLives | ( | int | nl | ) |
Set number of lives.
Definition at line 161 of file Bongo.cpp.
References mnLives.
Referenced by Ball::Reincarnate().
{
mnLives = nl;
}
int Bongo::mbCaptured [private] |
int Bongo::mbFlashing [private] |
bool Bongo::mbHasArrow [private] |
int Bongo::mbImmortal [private] |
Bongo can't be killed.
Definition at line 70 of file Bongo.h.
Referenced by Init(), and IsVulnerable().
int Bongo::mFlashingPeriodFrames [private] |
int Bongo::mFlashingTime [private] |
How long bongo will be flashing when hit.
Definition at line 62 of file Bongo.h.
Referenced by Init(), and IsVulnerable().
int Bongo::mnLives [private] |
XRes * Bongo::mpArrowResource [private] |
time_t Bongo::mStartFlashing [private] |
When bongo started to flash.
Definition at line 66 of file Bongo.h.
Referenced by Free(), IsVulnerable(), and Kill().
1.8.0