This repository has been archived by the owner on Jan 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconstants.go
438 lines (387 loc) · 7.87 KB
/
constants.go
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
/*
To the extent possible under law, Ian Davis has waived all copyright
and related or neighboring rights to this Amberfell Source Code file.
This work is published from the United Kingdom.
*/
package main
import (
"github.com/banthar/Go-SDL/sdl"
)
const (
// GroundLevel = 807
CHUNK_WIDTH = 8
CHUNK_HEIGHT = 128
MAP_DIAM = 64000
PLAYER_START_X = 35096 //35120 //32122 //32035 //31972 //31768 //31559 //31445 //32011 // 31767 //MAP_DIAM / 2
PLAYER_START_Z = 33986 //34035 //31029 //31426 //31450 //31621 //31488 //32137 //31058 // 32009 //MAP_DIAM / 2
NOISE_SCALE = 16
SEA_LEVEL = 30
TREE_PRECIPITATION_MIN = 0.2
TREE_DENSITY_PCT = 5
TREE_LINE = 5 * CHUNK_HEIGHT / 6
BUSH_PRECIPITATION_MIN = 0.1
BUSH_DENSITY_PCT = 1
VERTEX_BUFFER_CAPACITY = 20000
BLOCK_SCALE = 0.4
MAX_ITEMS_IN_INVENTORY = 999
PLAYER_REACH = 7
XAXIS = 0
YAXIS = 1
ZAXIS = 2
TILES_HORZ = 16
TILES_VERT = 8
TILE_WIDTH = 48 // Height and width of a block texture in pixels
SCREEN_SCALE = 1.0 * TILE_WIDTH // Width of one world coordinate unit in pixels
PIXEL_SCALE = 1.0 / SCREEN_SCALE // Width of one pixel in world coordinate units
KEY_DEBOUNCE_DELAY = 3e8 // nanoseconds
MAX_LIGHT_LEVEL = 12
MOUSE_BTN_LEFT = (1 << (sdl.BUTTON_LEFT - 1))
MOUSE_BTN_RIGHT = (1 << (sdl.BUTTON_RIGHT - 1))
MOUSE_BTN_MIDDLE = (1 << (sdl.BUTTON_MIDDLE - 1))
)
const (
EAST_FACE = iota // +ve x
WEST_FACE // -ve x
NORTH_FACE // -ve z
SOUTH_FACE // +ve z
UP_FACE // +ve y
DOWN_FACE // -ve y
DIR_NE
DIR_SE
DIR_SW
DIR_NW
DIR_UN
DIR_UE
DIR_US
DIR_UW
DIR_DN
DIR_DE
DIR_DS
DIR_DW
FACE_NONE
)
const (
ORIENT_EAST = iota
ORIENT_NORTH
ORIENT_SOUTH
ORIENT_WEST
)
const (
SHAPE_CUBE = iota
SHAPE_ORIENTED_CUBE
SHAPE_WALL
SHAPE_SLAB
SHAPE_PILE
)
const (
BLOCK_AIR = iota
BLOCK_STONE
BLOCK_DIRT
BLOCK_TRUNK
BLOCK_LEAVES
BLOCK_LOG_WALL
BLOCK_LOG_SLAB
BLOCK_AMBERFELL_SOURCE
BLOCK_COAL_SEAM
BLOCK_IRON_SEAM
BLOCK_COPPER_SEAM
BLOCK_MAGNETITE_SEAM
BLOCK_ZINC_SEAM
BLOCK_QUARTZ_SEAM
BLOCK_CARVED_STONE
BLOCK_CAMPFIRE
BLOCK_BURNT_GRASS
BLOCK_BUSH
BLOCK_PLANK_WALL
BLOCK_PLANK_SLAB
BLOCK_STONEBRICK_WALL
BLOCK_STONEBRICK_SLAB
BLOCK_AMBERFELL_PUMP
BLOCK_STEAM_GENERATOR
BLOCK_CARPENTERS_BENCH
//BLOCK_MILLING_MACHINE // TODO - for gears
//BLOCK_LATHE // TODO
//BLOCK_EXTRUDER // TODO - for pipes
BLOCK_AMBERFELL_CONDENSER
BLOCK_FURNACE
BLOCK_FORGE
BLOCK_BEESNEST
)
const (
ITEM_FIREWOOD = iota + 512
ITEM_RUBBLE
ITEM_PLANK
ITEM_STONE_BRICK
ITEM_AMBERFELL
ITEM_AMBERFELL_CRYSTAL
ITEM_COAL
ITEM_IRON_ORE
ITEM_COPPER_ORE
ITEM_ZINC_ORE
ITEM_MAGNETITE_ORE
ITEM_IRON_INGOT
ITEM_COPPER_INGOT
ITEM_BRASS_INGOT
ITEM_ZINC_INGOT
ITEM_LODESTONE
ITEM_IRON_PLATE
ITEM_COPPER_PLATE
ITEM_BRASS_PLATE
ITEM_SCRAP_IRON
ITEM_SCRAP_COPPER
ITEM_SCRAP_BRASS
ITEM_SCRAP_ZINC
ITEM_LEATHER
ITEM_BEESWAX
ITEM_QUARTZ
ITEM_GLASS
)
const (
MAX_ITEMS = 4096
ITEM_NONE = MAX_ITEMS - 1
)
const (
BEHAVIOUR_WANDER = iota
BEHAVIOUR_SEPARATE
BEHAVIOUR_GATHER
BEHAVIOUR_ALIGN
BEHAVIOUR_PURSUE
BEHAVIOUR_EVADE
BEHAVIOUR_ATTACK
)
const (
TARGET_ANY = iota
TARGET_PLAYER
TARGET_WOLF
TARGET_CAMPFIRE
TARGET_AMBERFELL_SOURCE
)
const (
ACTION_HAND = iota
ACTION_BREAK
ACTION_WEAPON
ACTION_ITEM0
ACTION_ITEM1
ACTION_ITEM2
ACTION_ITEM3
ACTION_ITEM4
)
// Textures in tile.png
const (
// Row 1 (0-15)
TEXTURE_NONE = iota
TEXTURE_STONE_TOP
TEXTURE_DIRT_TOP
TEXTURE_TRUNK_TOP
TEXTURE_FIRE
TEXTURE_LOG_WALL_TOP
TEXTURE_AMBERFELL_SOURCE_TOP
TEXTURE_COAL
TEXTURE_COPPER
TEXTURE_IRON
TEXTURE_BURNT_GRASS
TEXTURE_ZINC
TEXTURE_BEESNEST
TEXTURE_BEESNEST_TOP
TEXTURE_CRACKS
TEXTURE_QUARTZ_SEAM
// Row 2 (16-31)
TEXTURE_CARVED_STONE
TEXTURE_STONE
TEXTURE_DIRT
TEXTURE_TRUNK
TEXTURE_LEAVES
TEXTURE_LOG_WALL
TEXTURE_AMBERFELL_SOURCE
TEXTURE_STONE_BRICK
TEXTURE_FURNACE_TOP
TEXTURE_FORGE_TOP
_ // 26
_ // 27
_ // 28
_ // 29
_ // 30
_ // 31
// Row 3 (32-47)
TEXTURE_COPPER_MACH_SIDE
TEXTURE_COPPER_MACH_TOP
_ // 34
_ // 35
_ // 36
_ // 37
_ // 38
_ // 39
_ // 40
_ // 41
_ // 42
_ // 43
_ // 44
_ // 45
_ // 46
_ // 47
// Row 4 (48-63)
TEXTURE_IRON_MACH_SIDE
TEXTURE_IRON_MACH_TOP
_ // 50
_ // 51
_ // 52
_ // 53
_ // 54
_ // 55
_ // 56
_ // 57
_ // 58
_ // 59
_ // 60
_ // 61
_ // 62
_ // 63
// Row 5 (64-79)
TEXTURE_PLANK_WALL
TEXTURE_CARPENTERS_BENCH_TOP
_ // 66
_ // 67
_ // 68
_ // 69
_ // 70
_ // 71
_ // 72
_ // 73
_ // 74
_ // 75
_ // 76
_ // 77
_ // 78
_ // 79
// Row 6 (80-95)
TEXTURE_ACTION_HAND
TEXTURE_ACTION_BREAK
TEXTURE_ACTION_WEAPON
TEXTURE_ITEM_FIREWOOD
TEXTURE_ITEM_PLANK
TEXTURE_ITEM_COAL
TEXTURE_ITEM_IRON_ORE
TEXTURE_ITEM_COPPER_ORE
TEXTURE_ITEM_IRON_INGOT
TEXTURE_ITEM_COPPER_INGOT
TEXTURE_ITEM_AMBERFELL
TEXTURE_ITEM_LODESTONE
TEXTURE_ITEM_AMBERFELL_CRYSTAL
TEXTURE_ITEM_RUBBLE
TEXTURE_ITEM_STONE_BRICK
TEXTURE_ITEM_COPPER_PLATE
TEXTURE_ITEM_IRON_PLATE
TEXTURE_ITEM_BRASS_PLATE
// Row 7 (96-111)
TEXTURE_ITEM_BRASS_INGOT
TEXTURE_ITEM_SCRAP_COPPER
TEXTURE_ITEM_SCRAP_IRON
TEXTURE_ITEM_SCRAP_BRASS
TEXTURE_ITEM_SCRAP_ZINC
TEXTURE_ITEM_ZINC_ORE
TEXTURE_ITEM_ZINC_INGOT
TEXTURE_ITEM_LEATHER
TEXTURE_ITEM_BEESWAX
TEXTURE_ITEM_QUARTZ
TEXTURE_ITEM_GLASS
)
const (
// Player textures
TEXTURE_HAT_FRONT = iota + 4096
TEXTURE_HAT_LEFT
TEXTURE_HAT_BACK
TEXTURE_HAT_RIGHT
TEXTURE_HAT_TOP
TEXTURE_HEAD_FRONT
TEXTURE_HEAD_LEFT
TEXTURE_HEAD_BACK
TEXTURE_HEAD_RIGHT
TEXTURE_HEAD_BOTTOM
TEXTURE_TORSO_FRONT
TEXTURE_TORSO_LEFT
TEXTURE_TORSO_BACK
TEXTURE_TORSO_RIGHT
TEXTURE_TORSO_TOP
TEXTURE_LEG
TEXTURE_LEG_SIDE
TEXTURE_ARM
TEXTURE_ARM_TOP
TEXTURE_HAND
TEXTURE_BRIM
// Mob textures
TEXTURE_WOLF_HEAD_BACK
TEXTURE_WOLF_HEAD_FRONT
TEXTURE_WOLF_HEAD_TOP
TEXTURE_WOLF_HEAD_SIDE
TEXTURE_WOLF_HEAD_BOTTOM
TEXTURE_WOLF_TORSO_BACK
TEXTURE_WOLF_TORSO_FRONT
TEXTURE_WOLF_TORSO_TOP
TEXTURE_WOLF_TORSO_SIDE
TEXTURE_WOLF_TORSO_BOTTOM
TEXTURE_WOLF_LEG
// HUD textures
TEXTURE_PICKER
)
// Strength of materials
const (
STRENGTH_STONE = 10
STRENGTH_DIRT = 3
STRENGTH_WOOD = 5
STRENGTH_LEAVES = 1
STRENGTH_IRON = 30
STRENGTH_UNBREAKABLE = 255
)
const (
OCCURRENCE_COMMON = 0.54
OCCURRENCE_UNCOMMON = 0.58
OCCURRENCE_RARE = 0.65
OCCURRENCE_VARY_RARE = 0.75
)
type OreOccurrence struct {
itemid ItemId
occurrence float64
}
var (
// array not map to ensure ordering is deterministic
ORE_DISTRIBUTIONS = [...]OreOccurrence{
OreOccurrence{BLOCK_COAL_SEAM, OCCURRENCE_COMMON},
OreOccurrence{BLOCK_COPPER_SEAM, OCCURRENCE_COMMON},
OreOccurrence{BLOCK_IRON_SEAM, OCCURRENCE_UNCOMMON},
OreOccurrence{BLOCK_MAGNETITE_SEAM, OCCURRENCE_VARY_RARE},
OreOccurrence{BLOCK_ZINC_SEAM, OCCURRENCE_RARE},
OreOccurrence{BLOCK_QUARTZ_SEAM, OCCURRENCE_RARE},
}
SUNLIGHT_LEVELS = [8]float64{0.02, 0.05, 0.08, 0.11, 0.15, 0.20, 0.30, 0.45}
NORMALS = [6]([3]float32){[3]float32{1.0, 0.0, 0.0},
[3]float32{-1.0, 0.0, 0.0},
[3]float32{0.0, 0.0, -1.0},
[3]float32{0.0, 0.0, 1.0},
[3]float32{0.0, 1.0, 0.0},
[3]float32{0.0, -1.0, 0.0},
}
LIGHT_LEVELS = [13]([4]float32){[4]float32{0, 0, 0, 1},
[4]float32{0.04, 0.04, 0.04, 1.0},
[4]float32{0.12, 0.12, 0.12, 1.0},
[4]float32{0.20, 0.20, 0.20, 1.0},
[4]float32{0.28, 0.28, 0.28, 1.0},
[4]float32{0.36, 0.36, 0.36, 1.0},
[4]float32{0.44, 0.44, 0.44, 1.0},
[4]float32{0.52, 0.52, 0.52, 1.0},
[4]float32{0.60, 0.60, 0.60, 1.0},
[4]float32{0.68, 0.68, 0.68, 1.0},
[4]float32{0.76, 0.76, 0.76, 1.0},
[4]float32{0.84, 0.84, 0.84, 1.0},
[4]float32{0.92, 0.92, 0.92, 1.0},
}
COLOUR_WHITE = [4]float32{1.0, 1.0, 1.0, 1.0}
COLOUR_CRACKS = [4]float32{1.0, 1.0, 1.0, 0.4}
COLOURS = [5][4]float32{
{1.0, 1.0, 1.0, 1.0},
{0.7, 0.7, 0.7, 1.0},
{0.55, 0.55, 0.55, 1.0},
{0.4, 0.4, 0.4, 1.0},
{0.2, 0.2, 0.2, 1.0},
}
COLOUR_HIGH = [4]float32{96.0 / 255, 208.0 / 255, 96.0 / 255, 1.0}
)