1 
2 //          Copyright Luna & Cospec 2019.
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          https://www.boost.org/LICENSE_1_0.txt)
6 
7 module wsf.spec.scene;
8 import wsf.spec.tileset;
9 import wsf.serialization;
10 
11 /**
12     The scene in-game
13 */
14 class Scene {
15 
16     /**
17         The name of the scene
18     */
19     string name;
20 
21     /**
22         Contains all the tilesets for this scene
23     */
24     Tileset tileset;
25 
26     /**
27         Width of scene in pixels
28     */
29     uint width() {
30         return tilesX*tileWidth;
31     }
32 
33     /**
34         Height of scene in pixels
35     */
36     uint height() {
37         return tilesY*tileHeight;
38     }
39 
40     /**
41         Width of tiles
42     */
43     uint tileWidth;
44 
45     /**
46         Height of tiles
47     */
48     uint tileHeight;
49 
50     /**
51         The amount of tile slots in the X axis
52     */
53     uint tilesX;
54 
55     /**
56         The amount of tile slots on the Y axis
57     */
58     uint tilesY;
59 
60     /**
61         Basis width for quads
62     */
63     uint quadBasisX;
64 
65     /**
66         Basis height for quads
67     */
68     uint quadBasisY;
69 
70     /**
71         Layers
72 
73         index 0 = main layer
74     */
75     Layer[] layers;
76 }
77 
78 /**
79     A layer
80 */
81 class Layer {
82     /**
83         Contains all the tiles for this layer
84     */
85     Tile[] tiles;
86 
87     /**
88         Wether to draw the layer infront or behind the main layer
89     */
90     LayerOrder order;
91 }
92 
93 /**
94     Draw order for layer
95 */
96 enum LayerOrder : ubyte {
97     Auto = 0,
98     Background = 1,
99     Foreground = 2
100 }
101 
102 /**
103     Tile flip
104 */
105 enum TileFlip : ubyte {
106     None,
107     Horizontal = 1,
108     Vertical = 3
109 }
110 
111 /**
112     A tile
113 */
114 struct Tile {
115 
116     /**
117         X coordinate of tile
118     */
119     uint x;
120 
121     /**
122         T coordinate of tile
123     */
124     uint y;
125 
126     /**
127         ID of tile
128     */
129     ubyte id;
130 
131     /**
132         Which direction to flip tile
133     */
134     @optional
135     TileFlip flip = TileFlip.None;
136 
137 }