Quad Pang
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Attributes
Arrow Class Reference

Arrow is quad with limited Lifetime. More...

#include <Arrow.h>

Inheritance diagram for Arrow:
Quad_impl Lifetime Quad_impl Lifetime Quad Quad Quad Quad

List of all members.

Public Member Functions

 Arrow (Bongo *parent)
 ~Arrow ()
BongoGetParent ()
 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 ()
BongoGetParent ()
 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.
BongompParent
 Bongo that fired this arrow.
bool mbHitBox
 whether arrow is stuck in box roof

Detailed Description

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.

Definition at line 29 of file Arrow.h.


Constructor & Destructor Documentation

Arrow::Arrow ( Bongo parent)
Parameters:
parentThis is bongo whose arrow is thrown

Definition at line 10 of file Arrow.cpp.

: mpParent(parent), mGluQuadric(0), mbHitBox(false)
{
}

Definition at line 15 of file Arrow.cpp.

References mGluQuadric.

{  
    if (mGluQuadric)
        gluDeleteQuadric(mGluQuadric);
}
Arrow::Arrow ( Bongo parent)
Parameters:
parentThis is bongo whose arrow is thrown

Member Function Documentation

const char * Arrow::ClassName ( ) const [virtual]

Used for RTTI.

Returns:
Name of the actual class.
See also:
Factory

Reimplemented from Quad_impl.

Definition at line 60 of file Arrow.cpp.

Referenced by CollisionMaster::Collision().

{ 
    return "Arrow"; 
}
const char* Arrow::ClassName ( ) const [virtual]

Used for RTTI.

Returns:
Name of the actual class.
See also:
Factory

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.

Returns:
true if ok, false on error.

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.

Returns:
true if ok, false on error.

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;
}

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;
}

Helpfull for engine to get back arrow to it's parent.

void Arrow::HitBox ( )

Engine will call when Box and arrow collide to disable gravitation for an arrow.

void Arrow::HitBox ( )

Engine will call when Box and arrow collide to disable gravitation for an arrow.

Definition at line 101 of file Arrow.cpp.

References mbHitBox.

Referenced by CollisionMaster::Collision().

{ 
    mbHitBox = true; 
}
bool Arrow::Init ( XRes resource,
XCongo xcongo 
) [virtual]

Read Quad from resource file.

Parameters:
resourceResource file contained description of Quad object.
xcongoGlobal settings file contained parameters not specific to this quad.
Returns:
true if ok, false on error.

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]

Read Quad from resource file.

Parameters:
resourceResource file contained description of Quad object.
xcongoGlobal settings file contained parameters not specific to this quad.
Returns:
true if ok, false on error.

Reimplemented from Quad_impl.

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);
} 

Member Data Documentation

bool Arrow::mbHitBox [private]

whether arrow is stuck in box roof

Definition at line 66 of file Arrow.h.

Referenced by HitBox(), and Move().

GLUquadric * Arrow::mGluQuadric [private]

Quadratic is used to draw Cylindre.

Definition at line 62 of file Arrow.h.

Referenced by Display(), Init(), and ~Arrow().

Bongo * Arrow::mpParent [private]

Bongo that fired this arrow.

Definition at line 64 of file Arrow.h.

Referenced by GetParent(), and Init().


The documentation for this class was generated from the following files: