1 #include "background.h"
5 #include "display_manager.h"
7 Background::Background(DisplayManager& displaymanager)
9 displaymanager.add_drawable(this, LAYER_BACKGROUND0);
12 Background::~Background()
17 Background::action(float)
22 Background::set_image(Surface* image, float speed)
24 bgtype = BACKGROUND_IMAGE;
30 Background::set_gradient(Color top, Color bottom)
32 bgtype = BACKGROUND_GRADIENT;
34 gradient_bottom = bottom;
38 Background::draw(ViewPort& viewport, int )
40 if(bgtype == BACKGROUND_GRADIENT) {
41 drawgradient(gradient_top, gradient_bottom);
42 } else if(bgtype == BACKGROUND_IMAGE) {
43 int sx = int(-viewport.get_translation().x * float(speed/100.))
44 % image->w - image->w;
45 int sy = int(-viewport.get_translation().y * float(speed/100.))
46 % image->h - image->h;
47 for(int x = sx; x < screen->w; x += image->w)
48 for(int y = sy; y < screen->h; y += image->h)