#include <massObject.h>
Inherits spriteObject.
Inherited by Player, wp_gren_proj, wp_puck_proj, and wp_weasel_proj.
Inheritance diagram for massObject:
Public Member Functions | |
massObject (spriteManager *newsm) | |
Builds a new massObject and assigns it to a spriteManager. | |
virtual | ~massObject () |
virtual void | updateSprite () |
Updates the sprite to apply gravitational effects to it. | |
virtual void | checkPenetration () |
Update the massObject's position so that it lands on any baseable spriteObjects that it may otherwise pass through in the tick. | |
virtual void | collidingWith (spriteObject *other) |
When standing on another SpriteObject, flag this massObject as grounded and set its y velocity to 0. | |
bool | isOnGround () const |
Check whether this massObject is currently on the ground. | |
bool | wasOnGround () const |
Check whether this massObject was on the ground in the previous tick. | |
bool | isFrozen () |
Check whether or not the massObject should stop falling. | |
Protected Attributes | |
bool | grounded |
whether or not the massObject is currently on the ground | |
bool | wasGrounded |
grounded state in previous tick | |
bool | bStasis |
freeze this object's y-velocity if true | |
Static Protected Attributes | |
static const u8 | GRAVITY = 32 |
downwards acceleration per frame in fixed point format (1/8 pixel) | |
static const u16 | TERMINALVEL = 1024 |
maximum falling speed in fixed point format (4 pixels/frame) |
massObjects will continue falling at a constant rate of acceleration (massObject::GRAVITY) until they reach terminal velocity (massObject::TERMINALVEL). If they are interrupted at any point by a baseable spriteObject, they will stop falling and 'land' on that spriteObject.
Definition at line 38 of file massObject.h.
massObject::massObject | ( | spriteManager * | newsm | ) |
Builds a new massObject and assigns it to a spriteManager.
newsm | the spriteManager which should be responsible for updating and deleting this sprite |
Definition at line 27 of file massObject.cpp.
References spriteObject::COL_SOLID, spriteObject::setCheckCollision(), and spriteObject::setCollision().
Here is the call graph for this function:
massObject::~massObject | ( | ) | [virtual] |
Definition at line 38 of file massObject.cpp.
void massObject::updateSprite | ( | ) | [virtual] |
Updates the sprite to apply gravitational effects to it.
The sprite will accellerate downwards unless it lands on another baseable spriteObject.
Reimplemented from spriteObject.
Reimplemented in Player, wp_gren_proj, wp_puck_proj, and wp_weasel_proj.
Definition at line 47 of file massObject.cpp.
References bStasis, checkPenetration(), GRAVITY, grounded, isOnGround(), TERMINALVEL, spriteObject::updateSprite(), spriteObject::vy, and wasGrounded.
Referenced by wp_weasel_proj::updateSprite(), wp_puck_proj::updateSprite(), wp_gren_proj::updateSprite(), and Player::updateSprite().
Here is the call graph for this function:
void massObject::checkPenetration | ( | ) | [virtual] |
Update the massObject's position so that it lands on any baseable spriteObjects that it may otherwise pass through in the tick.
Definition at line 81 of file massObject.cpp.
References spriteManager::gameSprites, spriteObject::getBottom(), spriteObject::inHorizPlaneOf(), spriteObject::inVertPlaneOf(), spriteObject::isOver(), spriteObject::isUnder(), spriteObject::sm, spriteObject::vy, and spriteObject::y.
Referenced by updateSprite().
Here is the call graph for this function:
void massObject::collidingWith | ( | spriteObject * | other | ) | [virtual] |
When standing on another SpriteObject, flag this massObject as grounded and set its y velocity to 0.
other | the spriteObject we are touching to be checked for standing on. |
Reimplemented from spriteObject.
Reimplemented in Player, and wp_puck_proj.
Definition at line 68 of file massObject.cpp.
References grounded, spriteObject::isStandingOn(), and spriteObject::vy.
Referenced by wp_puck_proj::collidingWith(), and Player::collidingWith().
Here is the call graph for this function:
bool massObject::isOnGround | ( | ) | const [inline] |
Check whether this massObject is currently on the ground.
Definition at line 52 of file massObject.h.
References grounded.
Referenced by Player::basicInput(), Player::bounce(), wp_weasel_proj::changeDirection(), Player::crouch(), Weapon::fire(), Player::handleNetted(), Player::jump(), Player::readyForVictory(), Player::roll(), wp_weasel_proj::updateSprite(), wp_puck_proj::updateSprite(), wp_gren_proj::updateSprite(), updateSprite(), wp_magnet::weaponTick(), wp_hook::weaponTick(), and wp_chut::weaponTick().
bool massObject::wasOnGround | ( | ) | const [inline] |
Check whether this massObject was on the ground in the previous tick.
Useful for detecting changes in object state, firing animation events etc.
Definition at line 58 of file massObject.h.
References wasGrounded.
Referenced by Player::basicInput(), Player::collidingWith(), wp_weasel_proj::updateSprite(), and wp_puck_proj::updateSprite().
bool massObject::isFrozen | ( | ) | [inline] |
Check whether or not the massObject should stop falling.
Reasonably sure this isn't actually implemented at present.
Definition at line 65 of file massObject.h.
References bStasis.
Referenced by gameManager::gameTick().
const u8 massObject::GRAVITY = 32 [static, protected] |
downwards acceleration per frame in fixed point format (1/8 pixel)
Definition at line 69 of file massObject.h.
Referenced by updateSprite().
const u16 massObject::TERMINALVEL = 1024 [static, protected] |
maximum falling speed in fixed point format (4 pixels/frame)
Definition at line 71 of file massObject.h.
Referenced by updateSprite().
bool massObject::grounded [protected] |
whether or not the massObject is currently on the ground
Definition at line 74 of file massObject.h.
Referenced by collidingWith(), isOnGround(), and updateSprite().
bool massObject::wasGrounded [protected] |
grounded state in previous tick
Definition at line 76 of file massObject.h.
Referenced by updateSprite(), and wasOnGround().
bool massObject::bStasis [protected] |
freeze this object's y-velocity if true
Definition at line 78 of file massObject.h.
Referenced by Player::freezePlayer(), Player::isDisabled(), isFrozen(), Player::readyForVictory(), Player::updateSprite(), and updateSprite().