/
Background.hpp
75 lines (55 loc) · 2.11 KB
/
Background.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* Background.hpp -- the background layers
Copyright 2014, Michael L. Gran
This file is part of the Project Burro game engine.
Project Burro is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Project Burro is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with Project Burro. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef BURRO_BACKGROUND_H
#define BURRO_BACKGROUND_H
#include "ResCache.hpp"
#include "Tmx.h"
#include "const.h"
#include "xcairo.hpp"
#include <array>
#include "jsapi.hpp"
#include "js_func.hpp"
using namespace std;
using namespace Tmx;
struct Background_Layer {
/* BG is display when true */
bool enable;
/** the "user" or screen location of the rotation center of the
* background */
double scroll_x, scroll_y;
/** the "device" location of the rotation center of the
* background*/
double rotation_center_x, rotation_center_y;
/** the expansion factor of the background: 1.0 = 1 pixel per
* pixel */
double expansion;
/** the rotation angle of the background about its rotation
* center, in radians */
double rotation;
/** zero is transparent. one is default */
double opacity;
/** The image data of the layer as a Cairo surface. */
cairo_surface_t* surface;
};
struct Background {
array<Background_Layer, MAIN_BACKGROUNDS_COUNT> layers;
void Reset();
void Update_layer_from_cairo_surface (cairo_surface_t *layer, int z_level);
void Update_layers_from_tmx_map(Map& map, ResCache& resource_cache);
void Draw_zlevel_to_context(cairo_t *screen, int z_level);
};
extern Background bg;
extern JSFunctionSpec background_functions[16];
#endif