-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathatlas.odin
205 lines (185 loc) · 3.72 KB
/
atlas.odin
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// This file is generated by running the atlas_builder.
package main
/*
Note: This file assumes the existence of a type Rect that defines a rectangle in the same package, it can defined as:
Rect :: rl.Rectangle
or if you don't use raylib:
Rect :: struct {
x, y, width, height: f32,
}
or if you want to use integers (or any other numeric type):
Rect :: struct {
x, y, width, height: int,
}
Just make sure you have something along those lines the same package as this file.
*/
TEXTURE_ATLAS_FILENAME :: "./assets/atlas.png"
ATLAS_WIDTH :: 205
ATLAS_HEIGHT :: 64
ATLAS_FONT_SIZE :: 32
LETTERS_IN_FONT :: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890?!&.,_:[]-+"
// A generated square in the atlas you can use with rl.SetShapesTexture to make
// raylib shapes such as rl.DrawRectangleRec() use the atlas.
SHAPES_TEXTURE_RECT :: Rect {195, 0, 10, 10}
Texture_Name :: enum {
None,
Wall,
Skip,
Floor,
}
Atlas_Texture :: struct {
rect: Rect,
// These offsets tell you how much space there is between the rect and the edge of the original document.
// The atlas is tightly packed, so empty pixels are removed. This can be especially apparent in animations where
// frames can have different offsets due to different amount of empty pixels around the frames.
// In many cases you need to add {offset_left, offset_top} to your position. But if you are
// flipping a texture, then you might need offset_bottom or offset_right.
offset_top: f32,
offset_right: f32,
offset_bottom: f32,
offset_left: f32,
document_size: [2]f32,
duration: f32,
}
atlas_textures: [Texture_Name]Atlas_Texture = {
.None = {},
.Wall = { rect = {0, 0, 64, 64}, offset_top = 0, offset_right = 0, offset_bottom = 0, offset_left = 0, document_size = {64, 64}, duration = 0.000},
.Skip = { rect = {65, 0, 64, 64}, offset_top = 0, offset_right = 0, offset_bottom = 0, offset_left = 0, document_size = {64, 64}, duration = 0.000},
.Floor = { rect = {130, 0, 64, 64}, offset_top = 0, offset_right = 0, offset_bottom = 0, offset_left = 0, document_size = {64, 64}, duration = 0.000},
}
Animation_Name :: enum {
None,
}
Tag_Loop_Dir :: enum {
Forward,
Reverse,
Ping_Pong,
Ping_Pong_Reverse,
}
// Any aseprite file with frames will create new animations. Also, any tags
// within the aseprite file will make that that into a separate animation.
Atlas_Animation :: struct {
first_frame: Texture_Name,
last_frame: Texture_Name,
document_size: [2]f32,
loop_direction: Tag_Loop_Dir,
repeat: u16,
}
atlas_animations := [Animation_Name]Atlas_Animation {
.None = {},
}
// All these are pre-generated so you can save tile IDs to data without
// worrying about their order changing later.
Tile_Id :: enum {
T0Y0X0,
T0Y0X1,
T0Y0X2,
T0Y0X3,
T0Y0X4,
T0Y0X5,
T0Y0X6,
T0Y0X7,
T0Y0X8,
T0Y0X9,
T0Y1X0,
T0Y1X1,
T0Y1X2,
T0Y1X3,
T0Y1X4,
T0Y1X5,
T0Y1X6,
T0Y1X7,
T0Y1X8,
T0Y1X9,
T0Y2X0,
T0Y2X1,
T0Y2X2,
T0Y2X3,
T0Y2X4,
T0Y2X5,
T0Y2X6,
T0Y2X7,
T0Y2X8,
T0Y2X9,
T0Y3X0,
T0Y3X1,
T0Y3X2,
T0Y3X3,
T0Y3X4,
T0Y3X5,
T0Y3X6,
T0Y3X7,
T0Y3X8,
T0Y3X9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