#include <pickup.h>
Inherits spriteObject.
Inheritance diagram for Pickup:
Public Types | |
enum | pickupType { PT_SKULL, PT_1000V, PT_INVIS, PT_MINE, PT_GUN, PT_TNT, PT_BOOT, PT_GRENADE, PT_PUCK, PT_CHUT, PT_HOOK, PT_WARP, PT_MAGNET, PT_NET, PT_SHIELD, PT_DUNCE, PT_WEASEL, PT_BOOMERANG } |
The type identifier for a Pickup. More... | |
Public Member Functions | |
Pickup (spriteManager *newgm, pickupSpawner *mySpawner, u8 lifeSeconds, s16 nx, s16 ny, u8 type, gameManager::pickupGraphics *graphicSet) | |
Create this pickup and assign it a spriteManager. | |
virtual | ~Pickup () |
When destroyed, automatically play a singleFireSprite dieing effect and sound. | |
virtual void | updateSprite () |
Call any update functions on this Pickup, then make it bounce off the edges of the screen if necessary. | |
virtual void | collidingWith (spriteObject *other) |
Mutations to happen when this Pickup is colliding with another spriteObject. | |
virtual bool | isColliding (spriteObject *other, bool checkReverse=true) const |
Check whether or not this Pickup is colliding with another spriteObject. | |
void | setType (u8 newType) |
Set the type of this Pickup and make the according icon. | |
pickupType | getType () const |
return the type of this Pickup from Pickup::pickupType | |
void | setSpawner (pickupSpawner *p) |
set the spawner that fired this Pickup so that it may be told to spawn another Pickup when this one dies | |
bool | shouldExplode () |
used for the TNT Pickup to set which animation and sound to play when destroyed | |
void | playerTouchAction (Player *other) |
The mutation that will be performed on a Player when this Pickup comes in contact with them. | |
Static Public Attributes | |
static const u8 | NUMPICKUPVARIATIONS = 18 |
the total number of possible Pickups in the game | |
Protected Attributes | |
gameManager * | gm |
another reference to this Pickups spriteManager so that game-specific function calls can be done more easily | |
Private Member Functions | |
void | makeIcon (u8 frame) |
set the Pickup::myIcon sprite's frame to the frame specified | |
Private Attributes | |
pickupSpawner * | spawner |
the pickupSpawner that was responsible for firing this Pickup | |
bool | exploding |
if true, play explosion on death instead of 'pop' animation | |
pickupType | myType |
the type of this Pickup from Pickup::pickupType | |
gameManager::pickupGraphics * | myGFXset |
the graphics set for this pickup to use for its related effects. If a free slot from the gameManager cannot be found, we cope by spawning with non-loaded GFX | |
spriteObject * | myIcon |
the spriteObject that this Pickup is using for its distinguishing icon | |
Static Private Attributes | |
static const u16 | MINX = 8 |
minimum x screen position (in pixels) that the Pickup will reflect off if it moves outside of | |
static const u16 | MINY = 8 |
minimum y screen position (in pixels) that the Pickup will reflect off if it moves outside of | |
static const u16 | MAXX = 248 |
maximum x screen position (in pixels) that the Pickup will reflect off if it moves outside of | |
static const u16 | MAXY = 176 |
maximum y screen position (in pixels) that the Pickup will reflect off if it moves outside of |
They move randomly around the level and bounce off the edges of the screen. They have a finite lifetime and handle all their own creation & destruction effect sprites internally.
Definition at line 42 of file pickup.h.
enum Pickup::pickupType |
The type identifier for a Pickup.
Mostly used to specify which Weapon to give a Player when they touch that Pickup, or what behaviour to run in such a case.
The Pickup icon given is set to the frame given by Pickup::pickupType+3
Pickup::Pickup | ( | spriteManager * | newgm, | |
pickupSpawner * | mySpawner, | |||
u8 | lifeSeconds, | |||
s16 | nx, | |||
s16 | ny, | |||
u8 | type, | |||
gameManager::pickupGraphics * | graphicSet | |||
) |
Create this pickup and assign it a spriteManager.
The spriteManager assigned must also be a gameManager. A lifetime, starting position and type are also specified.
Definition at line 30 of file pickup.cpp.
References spriteObject::addChild(), gameManager::addPickup(), gameManager::pickupGraphics::bInUse, gameManager::pickupGraphics::blobGFX, spriteObject::COL_SOLID, spriteManager::createSingleFireSprite(), gameManager::FXSprite, spriteObject::giveGFX(), spriteObject::giveSprite(), gm, gameManager::pickupGraphics::iconGFX, myGFXset, myIcon, NUMPICKUPVARIATIONS, gameManager::pickupSprite, spriteObject::setBounds(), spriteObject::setCollision(), spriteObject::setFrame(), spriteObject::setLayer(), spriteObject::setLifetime(), spriteObject::setPallete(), spriteObject::setPos(), setType(), spriteObject::sm, gameManager::pickupGraphics::spawnGFX, spriteObject::spriteObject(), and spriteObject::TICKSPERFRAME.
Here is the call graph for this function:
Pickup::~Pickup | ( | ) | [virtual] |
When destroyed, automatically play a singleFireSprite dieing effect and sound.
Also inform the pickupSpawner who created us that they are free to create a pickup to replace this one.
Definition at line 86 of file pickup.cpp.
References gameManager::pickupGraphics::bInUse, spriteManager::createSingleFireSprite(), gameManager::pickupGraphics::dieGFX, exploding, gameManager::FXSprite, spriteObject::getx(), spriteObject::gety(), gm, spriteManager::isResetting(), myGFXset, pickupSpawner::pickupDied(), gameManager::platformExplode, spriteObject::playSound(), gameManager::removePickup(), spawner, and spriteObject::TICKSPERFRAME.
Here is the call graph for this function:
void Pickup::updateSprite | ( | ) | [virtual] |
Call any update functions on this Pickup, then make it bounce off the edges of the screen if necessary.
Reimplemented from spriteObject.
Definition at line 350 of file pickup.cpp.
References spriteObject::getx(), spriteObject::gety(), MAXX, MAXY, MINX, MINY, spriteObject::updateSprite(), spriteObject::vx, and spriteObject::vy.
Here is the call graph for this function:
void Pickup::collidingWith | ( | spriteObject * | other | ) | [virtual] |
Mutations to happen when this Pickup is colliding with another spriteObject.
Pickup::PT_TNT being the only kind of Pickup which uses active collision, this function is sufficient to check for collisions with floorTiles only.
other | the spriteObject this Pickup is touching |
Reimplemented from spriteObject.
Definition at line 299 of file pickup.cpp.
References spriteObject::collidingWith(), Player::CS_TNTFALL, spriteObject::destroy(), exploding, spriteManager::gameSprites, spriteObject::getLeft(), spriteObject::getRight(), spriteObject::gety(), gm, Player::groundDeleted(), spriteObject::isStandingOn(), gameManager::player1, gameManager::player2, and spriteObject::sm.
Here is the call graph for this function:
bool Pickup::isColliding | ( | spriteObject * | other, | |
bool | checkReverse = true | |||
) | const [virtual] |
Check whether or not this Pickup is colliding with another spriteObject.
other | a reference to the spriteObject to test collision against. The collision can only succeed if:
| |
checkReverse | whether or not to compute collision for the complementary spriteObject |
Definition at line 338 of file pickup.cpp.
References getType(), spriteObject::isColliding(), and PT_TNT.
Here is the call graph for this function:
void Pickup::setType | ( | u8 | newType | ) |
Set the type of this Pickup and make the according icon.
Also initialises the animation cycle for this Pickup and any sounds it may need to play.
newType | an integer corresponding to one of Pickup::pickupType |
Definition at line 206 of file pickup.cpp.
References spriteObject::ANIMSPEED, spriteObject::COL_CENTERPOINT, gm, makeIcon(), myType, NUMPICKUPVARIATIONS, spriteObject::playSound(), PT_1000V, PT_BOOMERANG, PT_BOOT, PT_CHUT, PT_DUNCE, PT_GRENADE, PT_GUN, PT_HOOK, PT_INVIS, PT_MAGNET, PT_MINE, PT_NET, PT_PUCK, PT_SHIELD, PT_SKULL, PT_TNT, PT_WARP, PT_WEASEL, spriteObject::setAnim(), spriteObject::setCheckCollision(), spriteObject::setCollision(), gameManager::skullLoop, and spriteObject::stopSound().
Referenced by Pickup().
Here is the call graph for this function:
pickupType Pickup::getType | ( | ) | const [inline] |
return the type of this Pickup from Pickup::pickupType
Definition at line 65 of file pickup.h.
References myType.
Referenced by Player::collidingWith(), Player::isColliding(), and isColliding().
void Pickup::setSpawner | ( | pickupSpawner * | p | ) | [inline] |
bool Pickup::shouldExplode | ( | ) | [inline] |
void Pickup::playerTouchAction | ( | Player * | other | ) |
The mutation that will be performed on a Player when this Pickup comes in contact with them.
A different action is performed, depending on Pickup::pickupType.
Definition at line 137 of file pickup.cpp.
References gm, myType, gameManager::playerSkulled(), PT_1000V, PT_BOOMERANG, PT_BOOT, PT_CHUT, PT_DUNCE, PT_GRENADE, PT_GUN, PT_HOOK, PT_INVIS, PT_MAGNET, PT_MINE, PT_NET, PT_PUCK, PT_SHIELD, PT_SKULL, PT_TNT, PT_WARP, and PT_WEASEL.
Referenced by Player::collidingWith().
Here is the call graph for this function:
void Pickup::makeIcon | ( | u8 | frame | ) | [private] |
set the Pickup::myIcon sprite's frame to the frame specified
frame | the frame the icon should use |
Definition at line 287 of file pickup.cpp.
References myIcon, and spriteObject::setFrame().
Referenced by setType().
Here is the call graph for this function:
const u8 Pickup::NUMPICKUPVARIATIONS = 18 [static] |
gameManager* Pickup::gm [protected] |
another reference to this Pickups spriteManager so that game-specific function calls can be done more easily
Definition at line 77 of file pickup.h.
Referenced by collidingWith(), Pickup(), playerTouchAction(), setType(), and ~Pickup().
pickupSpawner* Pickup::spawner [private] |
the pickupSpawner that was responsible for firing this Pickup
Definition at line 80 of file pickup.h.
Referenced by setSpawner(), and ~Pickup().
bool Pickup::exploding [private] |
if true, play explosion on death instead of 'pop' animation
Definition at line 82 of file pickup.h.
Referenced by collidingWith(), shouldExplode(), and ~Pickup().
pickupType Pickup::myType [private] |
the type of this Pickup from Pickup::pickupType
Definition at line 84 of file pickup.h.
Referenced by getType(), playerTouchAction(), and setType().
gameManager::pickupGraphics* Pickup::myGFXset [private] |
the graphics set for this pickup to use for its related effects. If a free slot from the gameManager cannot be found, we cope by spawning with non-loaded GFX
spriteObject* Pickup::myIcon [private] |
the spriteObject that this Pickup is using for its distinguishing icon
Definition at line 90 of file pickup.h.
Referenced by makeIcon(), and Pickup().
const u16 Pickup::MINX = 8 [static, private] |
minimum x screen position (in pixels) that the Pickup will reflect off if it moves outside of
Definition at line 93 of file pickup.h.
Referenced by updateSprite().
const u16 Pickup::MINY = 8 [static, private] |
minimum y screen position (in pixels) that the Pickup will reflect off if it moves outside of
Definition at line 95 of file pickup.h.
Referenced by updateSprite().
const u16 Pickup::MAXX = 248 [static, private] |
maximum x screen position (in pixels) that the Pickup will reflect off if it moves outside of
Definition at line 97 of file pickup.h.
Referenced by updateSprite().
const u16 Pickup::MAXY = 176 [static, private] |
maximum y screen position (in pixels) that the Pickup will reflect off if it moves outside of
Definition at line 99 of file pickup.h.
Referenced by updateSprite().