-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbehaviors.gx.go
374 lines (305 loc) · 7.28 KB
/
behaviors.gx.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
//gx:include "core/core.hh"
package game
import (
. "github.com/nikki93/raylib-5k/core/entity"
. "github.com/nikki93/raylib-5k/core/geom"
"github.com/nikki93/raylib-5k/core/rl"
)
//
// Physics
//
type Layout struct {
Behavior
Pos Vec2
Rot float64
}
type Velocity struct {
Behavior
Vel Vec2
}
type AngularVelocity struct {
Behavior
AngVel float64
}
type DisableFriction struct{}
type ApplySurfaceFriction struct{}
const numPlanetBitFrames = 9
type PlanetBit struct {
Frame int
Rot float64
Perturb Vec2
FlipH, FlipV bool
}
const numPlanetBitsPerSegment = 8
type PlanetBits [numPlanetBitsPerSegment]PlanetBit
type Planet struct {
Behavior
BaseRadius float64
AtmosphereRadius float64
InnerColor rl.Color
BitsColor rl.Color
AtmosphereColor rl.Color
Verts []Vec2
Bits []PlanetBits
}
type Up struct {
Behavior
Up Vec2
AutoUprightDir Vec2
grounded bool
lastGroundedTime float64
}
type Gravity struct {
Behavior
Strength float64 `default:"28"`
}
type CollisionShape struct {
Behavior
Verts []Vec2
}
type CollisionNormal struct {
Normal Vec2
Ground bool
}
type CollisionNormals struct {
Normals []CollisionNormal
}
type ArrowTarget struct {
Behavior
}
type Player struct {
Behavior
JumpsRemaining int `default:"1"`
lastJumpTime float64
SmoothedVel Vec2
CameraInitialized bool
CameraPos Vec2
CameraRot float64
FlipH bool
BeamOn bool
BeamEnd Vec2
BeamTimeSinceStart float64
BeamTimeTillDamage float64
ElementAmounts [NumElementTypes]int
BuildUIEnabled bool
BuildUIPos Vec2
BuildUIMouseOver bool
BuildUISelectedTypeId ResourceTypeId `default:"-1"`
Liftoff bool
Flying bool
FlyingAccel float64
FlyingFlameOn bool
Transmitting bool
TransmitWidthScale float64 `default:"1"`
TimeToSupernova float64
}
type EndingPlanet struct {
Behavior
}
//
// Resource
//
type ElementTypeId int
const (
CarbonElement ElementTypeId = 0
SiliconElement = 1
FuelElement = 2
AntimatterElement = 3
NumElementTypes = 4
)
type ElementType struct {
Name string
IconImageName string
iconTexture rl.Texture
}
var elementTypes = func() [NumElementTypes]ElementType {
result := [NumElementTypes]ElementType{}
result[CarbonElement] = ElementType{
Name: "carbon",
IconImageName: "icon_element_carbon.png",
}
result[SiliconElement] = ElementType{
Name: "silicon",
IconImageName: "icon_element_silicon.png",
}
result[FuelElement] = ElementType{
Name: "fuel",
IconImageName: "icon_element_fuel.png",
}
result[AntimatterElement] = ElementType{
Name: "antimatter",
IconImageName: "icon_element_antimatter.png",
}
return result
}()
type ElementAmount struct {
TypeId ElementTypeId
Amount int
}
type ResourceTypeId int
type ResourceType struct {
Name string
ImageName string
NumFrames int `default:"1"`
IconImageName string
DestructionSoundName string
VerticalOffset float64
VerticalOffsetVariance float64
Description string
Damageable bool `default:"true"`
Health int `default:"3"`
ElementAmounts []ElementAmount
Buildable bool
CollisionShapeVerts []Vec2
texture rl.Texture
iconTexture rl.Texture
destructionSound rl.Sound
}
var resourceTypes = [...]ResourceType{
{
Name: "fungus_giant",
ImageName: "resource_fungus_giant.png",
DestructionSoundName: "sfx_resource_destroy_plant.ogg",
VerticalOffset: -0.8,
VerticalOffsetVariance: -0.2,
Health: 15,
ElementAmounts: []ElementAmount{
{TypeId: CarbonElement, Amount: 11},
},
},
{
Name: "fungus_tiny",
ImageName: "resource_fungus_tiny.png",
DestructionSoundName: "sfx_resource_destroy_plant.ogg",
VerticalOffset: -0.3,
VerticalOffsetVariance: -0.08,
Health: 3,
ElementAmounts: []ElementAmount{
{TypeId: CarbonElement, Amount: 2},
},
},
{
Name: "sprout_tiny",
ImageName: "resource_sprout_tiny.png",
DestructionSoundName: "sfx_resource_destroy_plant.ogg",
VerticalOffset: -0.3,
VerticalOffsetVariance: -0.08,
Health: 3,
ElementAmounts: []ElementAmount{
{TypeId: CarbonElement, Amount: 1},
},
},
{
Name: "rock_large",
ImageName: "resource_rock_large.png",
DestructionSoundName: "sfx_resource_destroy_rock.ogg",
VerticalOffset: -0.8,
VerticalOffsetVariance: -0.2,
Health: 50,
ElementAmounts: []ElementAmount{
{TypeId: SiliconElement, Amount: 18},
},
},
{
Name: "rock_medium",
ImageName: "resource_rock_medium.png",
DestructionSoundName: "sfx_resource_destroy_rock.ogg",
VerticalOffset: -0.4,
VerticalOffsetVariance: -0.2,
Health: 20,
ElementAmounts: []ElementAmount{
{TypeId: SiliconElement, Amount: 6},
},
},
{
Name: "antiplant",
ImageName: "resource_antiplant.png",
DestructionSoundName: "sfx_resource_destroy_antimatter.ogg",
VerticalOffset: -0.4,
VerticalOffsetVariance: -0.2,
Health: 20,
ElementAmounts: []ElementAmount{
{TypeId: CarbonElement, Amount: 8},
{TypeId: AntimatterElement, Amount: 1},
},
},
{
Name: "refiner",
ImageName: "resource_building_refiner.png",
NumFrames: 2,
IconImageName: "icon_building_refiner.png",
DestructionSoundName: "sfx_resource_destroy_rock.ogg",
Description: "turns carbon into fuel",
Health: 50,
ElementAmounts: []ElementAmount{
{TypeId: SiliconElement, Amount: 40},
},
Buildable: true,
CollisionShapeVerts: []Vec2{
{-0.5 * 3, -2},
{0.5 * 3, -2},
{0.5 * 3, -0.8},
{-0.5 * 3, -0.8},
},
},
{
Name: "launchpad",
ImageName: "resource_building_launchpad.png",
NumFrames: 2,
IconImageName: "icon_building_launchpad.png",
DestructionSoundName: "sfx_resource_destroy_rock.ogg",
Description: "launch to find transmission tower",
Health: 50,
ElementAmounts: []ElementAmount{
{TypeId: CarbonElement, Amount: 64},
{TypeId: SiliconElement, Amount: 100},
{TypeId: AntimatterElement, Amount: 2},
},
Buildable: true,
CollisionShapeVerts: []Vec2{
{-0.5 * 3, -2},
{0.5 * 3, -2},
{0.5 * 3, -1.2},
{-0.5 * 3, -1.2},
},
},
{
Name: "transmission_tower",
ImageName: "resource_transmission_tower.png",
Damageable: false,
},
}
type Resource struct {
Behavior
TypeId ResourceTypeId
DrawOrder int
Frame int
FlipH bool
Health int
}
type ResourceDamaged struct {
rotDeviation float64
time float64
lastDamageTime float64
}
//
// Interactables
//
type InteractionHint struct {
Interactable bool
Message string
VerticalOffset float64 `default:"-4"`
}
type Refiner struct {
Behavior
CarbonAmount int
FuelAmount int
TimeTillNextRefinement float64
}
type Launchpad struct {
Behavior
Used bool
}
type TransmissionTower struct {
Behavior
}