hopefully fixed the crash on exit, keep sectors script bundled in the sector and...
[supertux.git] / src / object / floating_image.cpp
1 #include <config.h>
2
3 #include <stdexcept>
4 #include "resources.hpp"
5 #include "main.hpp"
6 #include "math/rect.hpp"
7 #include "sprite/sprite_manager.hpp"
8 #include "sprite/sprite.hpp"
9 #include "video/drawing_context.hpp"
10 #include "lisp/lisp.hpp"
11 #include "floating_image.hpp"
12
13 FloatingImage::FloatingImage(const std::string& spritefile) 
14   : layer(LAYER_FOREGROUND1 + 1), visible(false), anchor(ANCHOR_MIDDLE)
15 {
16   sprite.reset(sprite_manager->create(spritefile));
17 }
18
19 FloatingImage::~FloatingImage()
20 {
21 }
22
23 void
24 FloatingImage::update(float elapsed_time)
25 {
26   (void) elapsed_time;
27 }
28
29 void
30 FloatingImage::draw(DrawingContext& context)
31 {
32   if(!visible)
33     return;
34
35   context.push_transform();
36   context.set_translation(Vector(0, 0));
37
38   Vector spos = pos + get_anchor_pos(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
39       sprite->get_width(), sprite->get_height(), anchor);
40
41   sprite->draw(context, spos, layer);
42
43   context.pop_transform();
44 }