f9e274869f366639235e19bebf738a43a230b105
[supertux.git] / src / object / invisible_block.cpp
1 #include <config.h>
2
3 #include "invisible_block.h"
4 #include "resources.h"
5 #include "special/sprite.h"
6 #include "special/sprite_manager.h"
7 #include "video/drawing_context.h"
8 #include "object_factory.h"
9
10 InvisibleBlock::InvisibleBlock(const Vector& pos)
11   : Block(pos, sprite_manager->create("invisibleblock")), visible(false)
12 {
13   flags &= ~FLAG_SOLID;
14 }
15
16 void
17 InvisibleBlock::draw(DrawingContext& context)
18 {
19   if(visible)
20     sprite->draw(context, get_pos(), LAYER_OBJECTS);
21 }
22
23 void
24 InvisibleBlock::hit(Player& )
25 {
26   if(visible)
27     return;
28
29   sprite->set_action("empty");
30   SoundManager::get()->play_sound(IDToSound(SND_BRICK));
31   start_bounce();
32   flags |= FLAG_SOLID;
33   visible = true;
34 }
35
36 //IMPLEMENT_FACTORY(InvisibleBlock, "invisible_block");