added jam build system, please try it out - the advantage would be that it already...
[supertux.git] / src / object / coin.cpp
1 #include <config.h>
2
3 #include "coin.h"
4 #include "resources.h"
5 #include "video/drawing_context.h"
6 #include "special/sprite_manager.h"
7 #include "player.h"
8 #include "scene.h"
9
10 Coin::Coin(const Vector& pos)
11 {
12   bbox.set_pos(pos);
13   bbox.set_size(32, 32);
14   sprite = sprite_manager->create("coin");
15 }
16
17 Coin::~Coin()
18 {
19   delete sprite;
20 }
21
22 void
23 Coin::action(float )
24 {
25 }
26
27 void
28 Coin::draw(DrawingContext& context)
29 {
30   sprite->draw(context, get_pos(), LAYER_TILES);
31 }
32
33 HitResponse
34 Coin::collision(GameObject& other, const CollisionHit& )
35 {
36   Player* player = dynamic_cast<Player*>(&other);
37   if(player == 0)
38     return ABORT_MOVE;
39
40   player->get_status().incCoins();
41   remove_me();
42   return ABORT_MOVE;
43 }
44