Had a bit of time today and worked on supertux:
[supertux.git] / src / object / flower.cpp
1 #include <config.h>
2
3 #include <math.h>
4 #include "flower.h"
5 #include "resources.h"
6 #include "camera.h"
7 #include "sector.h"
8 #include "player.h"
9 #include "app/globals.h"
10 #include "special/sprite_manager.h"
11
12 Flower::Flower(const Vector& pos, Type _type)
13   : type(_type)
14 {
15   bbox.set_pos(pos);
16   bbox.set_size(32, 32);
17
18   if(_type == FIREFLOWER)
19     sprite = sprite_manager->create("fireflower");
20   else
21     sprite = sprite_manager->create("iceflower"); 
22 }
23
24 Flower::~Flower()
25 {
26   delete sprite;
27 }
28
29 void
30 Flower::action(float )
31 {
32 }
33
34 void
35 Flower::draw(DrawingContext& context)
36 {
37   sprite->draw(context, get_pos(), LAYER_OBJECTS);
38 }
39
40 HitResponse
41 Flower::collision(GameObject& other, const CollisionHit& )
42 {
43   Player* player = dynamic_cast<Player*>(&other);
44   if(!player)
45     return ABORT_MOVE;
46
47   if(type == FIREFLOWER)
48     player->got_power = Player::FIRE_POWER;
49   else
50     player->got_power = Player::ICE_POWER;
51   SoundManager::get()->play_sound(IDToSound(SND_COFFEE));
52   remove_me();
53   return ABORT_MOVE;
54 }
55