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