#include <JGameObject.h>
Public Member Functions | |
JGameObject (JTexture *tex, float x, float y, float width, float height) | |
virtual void | Update (float dt) |
virtual void | Render () |
virtual void | OnCollide () |
void | SetBBox (float x, float y, float width, float height) |
void | GetBBox (float x, float y, float *xNow, float *yNow, float *width, float *height) |
void | SetCollisionCircle (float cx, float cy, float radius) |
bool | Collide (JGameObject *target) |
void | SetCollisionTarget (JGameObject *target) |
JGameObject * | GetCollisionTarget () |
void | SetHitPoint (int pt) |
int | GetHitPoint () |
void | SetBlood (int pt) |
int | GetBlood () |
void | EnableAlpha (bool flag, float delta=0.0f) |
void | EnableScaling (bool flag, float delta=0.0f) |
void | EnableRotation (bool flag, float delta=0.0f) |
void | SetRenderFlags (int flags) |
void | StartFlashing () |
void | StopFlashing () |
bool | IsFlashing () |
JGameObject::JGameObject | ( | JTexture * | tex, | |
float | x, | |||
float | y, | |||
float | width, | |||
float | height | |||
) |
Constructor.
tex | - Texture for first frame. NULL for no starting frame. | |
x | - X position of texture for the frame. | |
y | - Y position of texture for the frame. | |
width | - Width of the frame. | |
height | - Height of the frame. |
virtual void JGameObject::Update | ( | float | dt | ) | [virtual] |
Update function.
dt | - Delta time since last update (in second). |
Reimplemented from JSprite.
virtual void JGameObject::Render | ( | ) | [virtual] |
Render current frame.
Reimplemented from JSprite.
virtual void JGameObject::OnCollide | ( | ) | [virtual] |
Function to handle collision.
void JGameObject::SetBBox | ( | float | x, | |
float | y, | |||
float | width, | |||
float | height | |||
) |
Set bounding box for collision detection. All the following collision detections will be done using bounding box.
x | - X position of the bounding box (relative to this sprite). | |
y | - Y position of the bounding box (relative to this sprite). | |
width | - Width of the bounding box. | |
height | - Height of the bounding box. |
void JGameObject::GetBBox | ( | float | x, | |
float | y, | |||
float * | xNow, | |||
float * | yNow, | |||
float * | width, | |||
float * | height | |||
) |
Get bounding box relative to screen position.
x | - X of screen position. | |
y | - Y of screen position. |
yNow - Y position of the bounding box (relative to screen).
width - Width of the bounding box.
height - Height of the bounding box.
void JGameObject::SetCollisionCircle | ( | float | cx, | |
float | cy, | |||
float | radius | |||
) |
Set up a circle for collision detection. All the following collision detections will be done using circle to circle collision detection.
cx | - X of the circle center. | |
cy | - Y of the circle center. | |
radius | - Radius of the circle. |
bool JGameObject::Collide | ( | JGameObject * | target | ) |
Check for collision. Either bounding box or circle to circle collision detection will be used depending on which one is setup last.
target | - Target to check for collision. |
void JGameObject::SetCollisionTarget | ( | JGameObject * | target | ) |
Set object that has collided with this object.
target | - Object that has collided with this object. |
JGameObject* JGameObject::GetCollisionTarget | ( | ) |
Get object that has collided with this object.
void JGameObject::SetHitPoint | ( | int | pt | ) |
Set damage point of this object.
pt | - Damage point. |
int JGameObject::GetHitPoint | ( | ) |
Get damage point of this object.
void JGameObject::SetBlood | ( | int | pt | ) |
Set blood of this object.
pt | - Blood value. |
int JGameObject::GetBlood | ( | ) |
Get blood of this object.
void JGameObject::EnableAlpha | ( | bool | flag, | |
float | delta = 0.0f | |||
) |
Enable alpha animation during update.
flag | - Enable flag. | |
delta | - Rate of changing the alpha value. |
void JGameObject::EnableScaling | ( | bool | flag, | |
float | delta = 0.0f | |||
) |
Enable scaling during update.
flag | - Enable flag. | |
delta | - Rate of changing the scaling value. |
void JGameObject::EnableRotation | ( | bool | flag, | |
float | delta = 0.0f | |||
) |
Enable rotation during update.
flag | - Enable flag. | |
delta | - Rate of rotation. |
void JGameObject::SetRenderFlags | ( | int | flags | ) |
Set rendering flags.
flags | - Rendering flags encoded in bits. |
void JGameObject::StartFlashing | ( | ) |
Start flashing during render.
void JGameObject::StopFlashing | ( | ) |
Start flashing during render.
bool JGameObject::IsFlashing | ( | ) |
Check if object is flashing.