Arrow is quad with limited Lifetime. More...
#include <Arrow.h>
Public Member Functions | |
| Arrow (Bongo *parent) | |
| ~Arrow () | |
| Bongo * | GetParent () |
| Helpfull for engine to get back arrow to it's parent. | |
| void | HitBox () |
| Engine will call when Box and arrow collide to disable gravitation for an arrow. | |
| Arrow (Bongo *parent) | |
| ~Arrow () | |
| Bongo * | GetParent () |
| Helpfull for engine to get back arrow to it's parent. | |
| void | HitBox () |
| Engine will call when Box and arrow collide to disable gravitation for an arrow. | |
Override methods from Quad and Quad_impl | |
classes | |
| 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 | Move (const double *forse) |
| If arrow hit the box, gravitation should not affect it. | |
| 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 | Move (const double *forse) |
Private Attributes | |
| GLUquadric * | mGluQuadric |
| Quadratic is used to draw Cylindre. | |
| Bongo * | mpParent |
| Bongo that fired this arrow. | |
| bool | mbHitBox |
| whether arrow is stuck in box roof | |
Arrow is quad with limited Lifetime.
It is created by Bongo and it will last certain period of time, after which it will be returned to Bongo.
| Arrow::Arrow | ( | Bongo * | parent | ) |
| parent | This is bongo whose arrow is thrown |
Definition at line 10 of file Arrow.cpp.
: mpParent(parent), mGluQuadric(0), mbHitBox(false) { }
| Arrow::~Arrow | ( | ) |
Definition at line 15 of file Arrow.cpp.
References mGluQuadric.
{
if (mGluQuadric)
gluDeleteQuadric(mGluQuadric);
}
| Arrow::Arrow | ( | Bongo * | parent | ) |
| parent | This is bongo whose arrow is thrown |
| Arrow::~Arrow | ( | ) |
| const char * Arrow::ClassName | ( | ) | const [virtual] |
Used for RTTI.
Reimplemented from Quad_impl.
Definition at line 60 of file Arrow.cpp.
Referenced by CollisionMaster::Collision().
{
return "Arrow";
}
| const char* Arrow::ClassName | ( | ) | const [virtual] |
| bool Arrow::Display | ( | ) | [virtual] |
Draw itself in global cotext. Since quads are intented to be used with opengl, drawing context is global.
Reimplemented from Quad_impl.
| bool Arrow::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 74 of file Arrow.cpp.
References Quad_impl::mColor, mGluQuadric, Quad_impl::mPos, and Quad_impl::mSize.
{
glPushMatrix();
// set material properties
GLfloat mat_specular[] = { mColor[0], mColor[1], mColor[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);
// use glu Quadric operation to draw cylinder
glPushMatrix();
glTranslatef(mPos[0], 0.0, mPos[2]);
glRotatef(90, -1.0, 0.0, 0.0);
gluCylinder(mGluQuadric, mSize/12, mSize/12, mPos[1], 4, 4);
glPopMatrix();
// Draw solid Cone
glTranslatef(mPos[0], mPos[1], mPos[2]);
glRotatef(90, -1.0, 0.0, 0.0);
glutSolidCone(mSize/4, mSize, int(mSize/2 * 30), int(mSize/2 * 22) );
glPopMatrix();
return true;
}
| Bongo * Arrow::GetParent | ( | ) |
Helpfull for engine to get back arrow to it's parent.
Definition at line 21 of file Arrow.cpp.
References mpParent.
Referenced by CollisionMaster::Collision().
{
return mpParent;
}
| Bongo* Arrow::GetParent | ( | ) |
Helpfull for engine to get back arrow to it's parent.
| void Arrow::HitBox | ( | ) |
| void Arrow::HitBox | ( | ) |
| bool Arrow::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 26 of file Arrow.cpp.
References Quad_impl::Color(), XRes::DoubleValue(), Lifetime::Init(), LOGE, Quad_impl::mColor, Quad_impl::mDirection, mGluQuadric, Quad_impl::mPos, Quad_impl::mPower, mpParent, Quad_impl::mSize, Quad_impl::Position(), and Quad_impl::Size().
Referenced by Bongo::Fire().
{
// expiratino time will be read from resource
if (!Lifetime::Init(resource) )
return false;
memset(mDirection, 0, 3 * sizeof(double) );
if (!resource->DoubleValue("mPower", &mPower) )
{
LOGE("reading Arrow power");
return false;
}
mDirection[1] = mPower;
int i;
const double *parent_pos = mpParent->Position();
for (i = 0; i < 3; i++)
mPos[i] = parent_pos[i];
mPos[1] += mpParent->Size();
mSize = mpParent->Size();
const double *parent_color = mpParent->Color();
for (i = 0; i < 3; i++)
mColor[i] = parent_color[i];
// create a quadric object
mGluQuadric = gluNewQuadric();
if (!mGluQuadric)
{
LOGE("gluNewQuadric");
return false;
}
return true;
}
| bool Arrow::Init | ( | XRes * | resource, |
| XCongo * | xcongo | ||
| ) | [virtual] |
| bool Arrow::Move | ( | const double * | forse | ) |
| bool Arrow::Move | ( | const double * | forse | ) |
If arrow hit the box, gravitation should not affect it.
Definition at line 66 of file Arrow.cpp.
References mbHitBox.
Referenced by CollisionMaster::Collision().
{
if (mbHitBox)
return false;
return Quad_impl::Move(forse);
}
bool Arrow::mbHitBox [private] |
GLUquadric * Arrow::mGluQuadric [private] |
Bongo * Arrow::mpParent [private] |
Bongo that fired this arrow.
Definition at line 64 of file Arrow.h.
Referenced by GetParent(), and Init().
1.8.0