Flower Class Reference

#include <flower.hpp>

Inherits MovingObject.

List of all members.

Public Member Functions

 Flower (BonusType type)
 ~Flower ()
virtual void update (float elapsed_time)
 This function is called once per frame and allows the object to update it's state.
virtual void draw (DrawingContext &context)
 The GameObject should draw itself onto the provided DrawingContext if this function is called.
virtual HitResponse collision (GameObject &other, const CollisionHit &hit)
 this function is called when the object collided with any other object

Private Member Functions

 Flower (const Flower &)
Floweroperator= (const Flower &)

Private Attributes

BonusType type
SpritePtr sprite
DrawingEffect drawing_effect

Friends

class FlipLevelTransformer


Detailed Description

Definition at line 24 of file flower.hpp.


Constructor & Destructor Documentation

Flower::Flower ( BonusType  type  ) 

Definition at line 22 of file flower.cpp.

References MovingObject::bbox, COLGROUP_TOUCHABLE, SpriteManager::create(), FIRE_BONUS, ICE_BONUS, SoundManager::preload(), MovingObject::set_group(), Rectf::set_size(), sound_manager, sprite, sprite_manager, and type.

00022                               :
00023   type(_type),
00024   sprite(),
00025   drawing_effect(NO_EFFECT)
00026 {
00027   bbox.set_size(32, 32);
00028 
00029   if(type == FIRE_BONUS) {
00030     sprite = sprite_manager->create("images/powerups/fireflower/fireflower.sprite");
00031     sound_manager->preload("sounds/fire-flower.wav");
00032   }
00033   else if(type == ICE_BONUS) {
00034     sprite = sprite_manager->create("images/powerups/iceflower/iceflower.sprite");
00035     sound_manager->preload("sounds/fire-flower.wav");
00036   } else {
00037     assert(false);
00038   }
00039 
00040   set_group(COLGROUP_TOUCHABLE);
00041 }

Flower::~Flower (  ) 

Definition at line 43 of file flower.cpp.

00044 {
00045 }

Flower::Flower ( const Flower  )  [private]


Member Function Documentation

void Flower::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 48 of file flower.cpp.

00049 {
00050 }

void Flower::draw ( DrawingContext context  )  [virtual]

The GameObject should draw itself onto the provided DrawingContext if this function is called.

Implements GameObject.

Definition at line 53 of file flower.cpp.

References drawing_effect, MovingObject::get_pos(), LAYER_OBJECTS, and sprite.

00054 {
00055   sprite->draw(context, get_pos(), LAYER_OBJECTS, drawing_effect);
00056 }

HitResponse Flower::collision ( GameObject other,
const CollisionHit hit 
) [virtual]

this function is called when the object collided with any other object

Implements MovingObject.

Definition at line 59 of file flower.cpp.

References ABORT_MOVE, Player::add_bonus(), FORCE_MOVE, SoundManager::play(), GameObject::remove_me(), sound_manager, and type.

00060 {
00061   Player* player = dynamic_cast<Player*>(&other);
00062   if(!player)
00063     return ABORT_MOVE;
00064 
00065   if(!player->add_bonus(type, true))
00066     return FORCE_MOVE;
00067 
00068   sound_manager->play("sounds/fire-flower.wav");
00069   remove_me();
00070   return ABORT_MOVE;
00071 }

Flower& Flower::operator= ( const Flower  )  [private]


Friends And Related Function Documentation

friend class FlipLevelTransformer [friend]

Definition at line 43 of file flower.hpp.


Member Data Documentation

BonusType Flower::type [private]

Definition at line 35 of file flower.hpp.

Referenced by collision(), and Flower().

SpritePtr Flower::sprite [private]

Definition at line 36 of file flower.hpp.

Referenced by draw(), and Flower().

DrawingEffect Flower::drawing_effect [private]

Definition at line 37 of file flower.hpp.

Referenced by draw(), and FlipLevelTransformer::transform_flower().


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