#include <falling_coin.hpp>
Inherits GameObject.
Public Member Functions | |
FallingCoin (const Vector &start_position, const int x_vel) | |
~FallingCoin () | |
void | draw (DrawingContext &context) |
The GameObject should draw itself onto the provided DrawingContext if this function is called. | |
void | update (float elapsed_time) |
This function is called once per frame and allows the object to update it's state. | |
Private Attributes | |
Physic | physic |
Vector | pos |
SpritePtr | sprite |
Definition at line 24 of file falling_coin.hpp.
FallingCoin::FallingCoin | ( | const Vector & | start_position, | |
const int | x_vel | |||
) |
Definition at line 22 of file falling_coin.cpp.
References SpriteManager::create(), physic, pos, Physic::set_velocity_x(), Physic::set_velocity_y(), sprite, and sprite_manager.
00022 : 00023 physic(), 00024 pos(), 00025 sprite() 00026 { 00027 pos = start_position; 00028 sprite = sprite_manager->create("images/objects/coin/coin.sprite"); 00029 physic.set_velocity_y(-800); 00030 physic.set_velocity_x(vel_x); 00031 }
FallingCoin::~FallingCoin | ( | ) |
void FallingCoin::draw | ( | DrawingContext & | context | ) | [virtual] |
The GameObject should draw itself onto the provided DrawingContext if this function is called.
Implements GameObject.
Definition at line 38 of file falling_coin.cpp.
References LAYER_FLOATINGOBJECTS, pos, and sprite.
00039 { 00040 sprite->draw(context, pos, LAYER_FLOATINGOBJECTS + 5); 00041 }
void FallingCoin::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)
Implements GameObject.
Definition at line 44 of file falling_coin.cpp.
References Physic::get_movement(), physic, pos, GameObject::remove_me(), SCREEN_HEIGHT, and Vector::y.
00045 { 00046 pos += physic.get_movement(elapsed_time); 00047 if (pos.y > SCREEN_HEIGHT) 00048 remove_me(); 00049 }
Physic FallingCoin::physic [private] |
Vector FallingCoin::pos [private] |
SpritePtr FallingCoin::sprite [private] |