#include <oneup.hpp>
Inherits MovingSprite.
Public Member Functions | |
OneUp (const Vector &pos, Direction direction=RIGHT) | |
virtual void | update (float elapsed_time) |
This function is called once per frame and allows the object to update it's state. | |
virtual HitResponse | collision (GameObject &other, const CollisionHit &hit) |
this function is called when the object collided with any other object | |
Private Attributes | |
Physic | physic |
Definition at line 24 of file oneup.hpp.
Definition at line 21 of file oneup.cpp.
References LEFT, physic, and Physic::set_velocity().
00021 : 00022 MovingSprite(pos, "images/powerups/1up/1up.sprite", LAYER_FLOATINGOBJECTS, COLGROUP_TOUCHABLE), 00023 physic() 00024 { 00025 physic.set_velocity((direction == LEFT)?-100:100, -400); 00026 }
void OneUp::update | ( | float | elapsed_time | ) | [virtual] |
This function is called once per frame and allows the object to update it's state.
The elapsed_time is the time since the last frame in seconds and should be the base for all timed calculations (don't use SDL_GetTicks directly as this will fail in pause mode)
Reimplemented from MovingSprite.
Definition at line 29 of file oneup.cpp.
References MovingObject::bbox, Sector::current(), Physic::get_movement(), MovingObject::movement, physic, and GameObject::remove_me().
00030 { 00031 if(!Sector::current()->inside(bbox)) 00032 remove_me(); 00033 00034 movement = physic.get_movement(elapsed_time); 00035 }
HitResponse OneUp::collision | ( | GameObject & | other, | |
const CollisionHit & | hit | |||
) | [virtual] |
this function is called when the object collided with any other object
Implements MovingObject.
Definition at line 38 of file oneup.cpp.
References ABORT_MOVE, PlayerStatus::add_coins(), Statistics::coins, Sector::current(), FORCE_MOVE, Sector::get_level(), Player::get_status(), GameObject::remove_me(), and Level::stats.
00039 { 00040 Player* player = dynamic_cast<Player*> (&other); 00041 if(player) { 00042 player->get_status()->add_coins(100); 00043 #if 0 00044 // FIXME: do we want this? q.v. src/level.cpp 00045 Sector::current()->get_level()->stats.coins += 100; 00046 #endif 00047 remove_me(); 00048 return ABORT_MOVE; 00049 } 00050 return FORCE_MOVE; 00051 }
Physic OneUp::physic [private] |