FallingCoin Class Reference

#include <falling_coin.hpp>

Inherits GameObject.

List of all members.

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


Detailed Description

Definition at line 24 of file falling_coin.hpp.


Constructor & Destructor Documentation

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 (  ) 

Definition at line 33 of file falling_coin.cpp.

00034 {
00035 }


Member Function Documentation

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 }


Member Data Documentation

Physic FallingCoin::physic [private]

Definition at line 34 of file falling_coin.hpp.

Referenced by FallingCoin(), and update().

Vector FallingCoin::pos [private]

Definition at line 35 of file falling_coin.hpp.

Referenced by draw(), FallingCoin(), and update().

SpritePtr FallingCoin::sprite [private]

Definition at line 36 of file falling_coin.hpp.

Referenced by draw(), and FallingCoin().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:30 2014 for SuperTux by  doxygen 1.5.1