#include <pickupSpawner.h>
Inherits spriteObject.
Inheritance diagram for pickupSpawner:
Public Types | |
enum | spawnDir { SDIR_DOWN, SDIR_LEFT, SDIR_RIGHT } |
The direction that a Pickup will travel in after being spawned by a pickupSpawner. More... | |
Public Member Functions | |
pickupSpawner (spriteManager *newgm) | |
Create a new pickupSpawner and assign it to a spriteManager. | |
virtual | ~pickupSpawner () |
virtual void | updateSprite () |
Decrement spawn counters and generate Pickups at our location when one of the queued Pickups timers reaches 0. | |
void | pickupDied () |
Recieve notification from a Pickup that it has run out of lifetime and destroyed itself. | |
void | setDirection (spawnDir dir) |
spawnDir | getDirection () |
void | addSpawnTime (u8 secs, u8 type) |
Called by gameManager::gameBottom to queue another Pickup to spawn via this pickupSpawner. | |
Static Public Attributes | |
static const u8 | PICKUPLIFEMIN = 10 |
the shortest time a pickup will stay alive for, in seconds | |
static const u8 | PICKUPLIFEMAX = 25 |
the longest time a pickup will stay alive for, in seconds | |
static const u8 | IDLEMIN = 26 |
the minimum time this pickupSpawner will stay idle between spawns, in tenths of a second | |
static const u8 | IDLEMAX = 50 |
the maximum time this pickupSpawner will stay idle between spawns, in tenths of a second | |
Private Member Functions | |
void | resetIdleTime () |
Reset the timer in gameManager::gameBottom that corresponds to this pickupSpawner, so that a new Pickup will be queued to spawn in its place. | |
Private Attributes | |
vector< pendingPickup > | pendingPickups |
a queue specifying how long each queued Pickup should wait before spawning, and which type each queued Pickup should be | |
spawnDir | pickupDir |
the direction this pickupSpawner's Pickups should move in when spawned | |
Static Private Attributes | |
static const u16 | PICKUPSPEEDMIN = 64 |
the minimum speed a pickup will be moving at when it spawns, in fixed point format | |
static const u16 | PICKUPSPEEDMAX = 144 |
the maximum speed a pickup will be moving at when it spawns, in fixed point format | |
Classes | |
struct | pendingPickup |
A Pickup that has not yet been spawned. More... |
pickupSpawners work closely with a menuGBottom instance referenced through gameManager::gameBottom. The menuGBottom handles the Pickup spawning and countdown whilst notifying the pickupSpawner when it should fire a new Pickup.
Three pickupSpawners are spawned into the game by the gameManager - one at the top of the screen and one at each side. pickupSpawner::spawnDir tells the spawner where it is positioned, and which direction its Pickups should travel in once spawned.
Pickups are spawned moving in a random direction, at a random speed, and with a random lifetime. Various pickupSpawner members dictate the range of these random initialisation values.
Definition at line 49 of file pickupSpawner.h.
The direction that a Pickup will travel in after being spawned by a pickupSpawner.
This is an approximate direction - the Pickup will begin moving somewhere in a 45 degree arc from the direction specified.
Definition at line 64 of file pickupSpawner.h.
pickupSpawner::pickupSpawner | ( | spriteManager * | newgm | ) |
Create a new pickupSpawner and assign it to a spriteManager.
pickupSpawners initialise themselves on screen layer 3 so that they are behind most of the other game sprites.
newgm | the gameManager to which this pickupSpawner belongs |
Definition at line 32 of file pickupSpawner.cpp.
References spriteObject::setLayer().
Here is the call graph for this function:
pickupSpawner::~pickupSpawner | ( | ) | [virtual] |
Definition at line 42 of file pickupSpawner.cpp.
void pickupSpawner::updateSprite | ( | ) | [virtual] |
Decrement spawn counters and generate Pickups at our location when one of the queued Pickups timers reaches 0.
Reimplemented from spriteObject.
Definition at line 51 of file pickupSpawner.cpp.
References gameManager::getNextAvailablePickupGFXSet(), spriteObject::getx(), spriteObject::gety(), pendingPickups, pickupDir, PICKUPLIFEMAX, PICKUPLIFEMIN, PICKUPSPEEDMAX, PICKUPSPEEDMIN, SDIR_DOWN, SDIR_LEFT, SDIR_RIGHT, spriteObject::setSpeed(), spriteObject::sm, and spriteObject::updateSprite().
Here is the call graph for this function:
void pickupSpawner::pickupDied | ( | ) |
Recieve notification from a Pickup that it has run out of lifetime and destroyed itself.
Reset the idle time of the relevant spawn counter in gameManager::gameBottom.
Definition at line 115 of file pickupSpawner.cpp.
References resetIdleTime().
Referenced by Pickup::~Pickup().
Here is the call graph for this function:
void pickupSpawner::setDirection | ( | spawnDir | dir | ) | [inline] |
Definition at line 70 of file pickupSpawner.h.
References pickupDir.
Referenced by gameManager::generateSpawners().
spawnDir pickupSpawner::getDirection | ( | ) | [inline] |
void pickupSpawner::addSpawnTime | ( | u8 | secs, | |
u8 | type | |||
) |
Called by gameManager::gameBottom to queue another Pickup to spawn via this pickupSpawner.
secs | the time that the new Pickup should wait before being spawned | |
type | the type (Pickup::pickupType) of the new Pickup to spawn |
Definition at line 137 of file pickupSpawner.cpp.
References spriteObject::ANIMSPEED, pickupSpawner::pendingPickup::framesUntilSpawn, pickupSpawner::pendingPickup::nextType, pendingPickups, and spriteObject::TICKSPERFRAME.
Referenced by menuGBottom::spawnPickup().
void pickupSpawner::resetIdleTime | ( | ) | [private] |
Reset the timer in gameManager::gameBottom that corresponds to this pickupSpawner, so that a new Pickup will be queued to spawn in its place.
Definition at line 124 of file pickupSpawner.cpp.
References pickupDir, menuGBottom::pickupsActive, menuGBottom::resetIdleTime(), and spriteObject::sm.
Referenced by pickupDied().
Here is the call graph for this function:
const u8 pickupSpawner::PICKUPLIFEMIN = 10 [static] |
the shortest time a pickup will stay alive for, in seconds
Definition at line 76 of file pickupSpawner.h.
Referenced by wp_magnet::popOutPawnWeapon(), and updateSprite().
const u8 pickupSpawner::PICKUPLIFEMAX = 25 [static] |
the longest time a pickup will stay alive for, in seconds
Definition at line 78 of file pickupSpawner.h.
Referenced by wp_magnet::popOutPawnWeapon(), and updateSprite().
const u8 pickupSpawner::IDLEMIN = 26 [static] |
the minimum time this pickupSpawner will stay idle between spawns, in tenths of a second
Definition at line 80 of file pickupSpawner.h.
Referenced by menuGBottom::resetIdleTime().
const u8 pickupSpawner::IDLEMAX = 50 [static] |
the maximum time this pickupSpawner will stay idle between spawns, in tenths of a second
Definition at line 82 of file pickupSpawner.h.
Referenced by menuGBottom::resetIdleTime().
const u16 pickupSpawner::PICKUPSPEEDMIN = 64 [static, private] |
the minimum speed a pickup will be moving at when it spawns, in fixed point format
Definition at line 86 of file pickupSpawner.h.
Referenced by updateSprite().
const u16 pickupSpawner::PICKUPSPEEDMAX = 144 [static, private] |
the maximum speed a pickup will be moving at when it spawns, in fixed point format
Definition at line 88 of file pickupSpawner.h.
Referenced by updateSprite().
vector<pendingPickup> pickupSpawner::pendingPickups [private] |
a queue specifying how long each queued Pickup should wait before spawning, and which type each queued Pickup should be
Definition at line 104 of file pickupSpawner.h.
Referenced by addSpawnTime(), and updateSprite().
spawnDir pickupSpawner::pickupDir [private] |
the direction this pickupSpawner's Pickups should move in when spawned
Definition at line 106 of file pickupSpawner.h.
Referenced by getDirection(), resetIdleTime(), setDirection(), and updateSprite().