gamengine3d 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. gamengine3d/__init__.py +18 -0
  2. gamengine3d/assets/__init__.py +0 -0
  3. gamengine3d/assets/circular_crosshair.png +0 -0
  4. gamengine3d/assets/plus_sign_crosshair.png +0 -0
  5. gamengine3d/cli.py +83 -0
  6. gamengine3d/context.py +319 -0
  7. gamengine3d/engine.py +715 -0
  8. gamengine3d/examples/__init__.py +0 -0
  9. gamengine3d/examples/basics.py +66 -0
  10. gamengine3d/examples/parkour.py +285 -0
  11. gamengine3d/examples/player_movement.py +161 -0
  12. gamengine3d/examples/reactor.py +526 -0
  13. gamengine3d/examples/scripts/__init__.py +0 -0
  14. gamengine3d/examples/scripts/bouncer.py +18 -0
  15. gamengine3d/examples/scripts/breaker_coil.py +17 -0
  16. gamengine3d/examples/scripts/breaker_decoder.py +39 -0
  17. gamengine3d/examples/scripts/breaker_gate.py +23 -0
  18. gamengine3d/examples/scripts/breaker_shield.py +28 -0
  19. gamengine3d/examples/scripts/coin.py +12 -0
  20. gamengine3d/examples/scripts/collector.py +13 -0
  21. gamengine3d/examples/scripts/confetti.py +27 -0
  22. gamengine3d/examples/scripts/director.py +213 -0
  23. gamengine3d/examples/scripts/drone.py +21 -0
  24. gamengine3d/examples/scripts/ghost_pulse.py +24 -0
  25. gamengine3d/examples/scripts/horror_atmosphere.py +96 -0
  26. gamengine3d/examples/scripts/interact.py +45 -0
  27. gamengine3d/examples/scripts/orbiter.py +25 -0
  28. gamengine3d/examples/scripts/player_controller.py +165 -0
  29. gamengine3d/examples/scripts/pulse.py +22 -0
  30. gamengine3d/examples/scripts/reactor_core.py +29 -0
  31. gamengine3d/examples/scripts/spin.py +13 -0
  32. gamengine3d/examples/scripts/sway.py +19 -0
  33. gamengine3d/examples/scripts/void_guard.py +26 -0
  34. gamengine3d/examples/transparency.py +92 -0
  35. gamengine3d/game_objects.py +975 -0
  36. gamengine3d/helper.py +720 -0
  37. gamengine3d/obj_reader.py +29 -0
  38. gamengine3d/objects/0.obj +964 -0
  39. gamengine3d/objects/1.obj +48 -0
  40. gamengine3d/objects/2.obj +983 -0
  41. gamengine3d/objects/3.obj +1623 -0
  42. gamengine3d/objects/4.obj +163 -0
  43. gamengine3d/objects/5.obj +861 -0
  44. gamengine3d/objects/6.obj +1314 -0
  45. gamengine3d/objects/7.obj +70 -0
  46. gamengine3d/objects/8.obj +1932 -0
  47. gamengine3d/objects/9.obj +1458 -0
  48. gamengine3d/objects/A_capital.obj +124 -0
  49. gamengine3d/objects/B_capital.obj +1118 -0
  50. gamengine3d/objects/C_capital.obj +1082 -0
  51. gamengine3d/objects/D_capital.obj +548 -0
  52. gamengine3d/objects/E_capital.obj +128 -0
  53. gamengine3d/objects/F_capital.obj +108 -0
  54. gamengine3d/objects/G_capital.obj +1125 -0
  55. gamengine3d/objects/H_capital.obj +128 -0
  56. gamengine3d/objects/I_capital.obj +48 -0
  57. gamengine3d/objects/J_capital.obj +454 -0
  58. gamengine3d/objects/K_capital.obj +125 -0
  59. gamengine3d/objects/L_capital.obj +68 -0
  60. gamengine3d/objects/M_capital.obj +163 -0
  61. gamengine3d/objects/N_capital.obj +112 -0
  62. gamengine3d/objects/O_capital.obj +968 -0
  63. gamengine3d/objects/P_capital.obj +620 -0
  64. gamengine3d/objects/Q_capital.obj +1362 -0
  65. gamengine3d/objects/R_capital.obj +1036 -0
  66. gamengine3d/objects/S_capital.obj +1346 -0
  67. gamengine3d/objects/T_capital.obj +88 -0
  68. gamengine3d/objects/U_capital.obj +860 -0
  69. gamengine3d/objects/V_capital.obj +81 -0
  70. gamengine3d/objects/W_capital.obj +147 -0
  71. gamengine3d/objects/X_capital.obj +136 -0
  72. gamengine3d/objects/Y_capital.obj +103 -0
  73. gamengine3d/objects/Z_capital.obj +90 -0
  74. gamengine3d/objects/__init__.py +0 -0
  75. gamengine3d/objects/a.obj +1920 -0
  76. gamengine3d/objects/ampersand.obj +2186 -0
  77. gamengine3d/objects/asterisk.obj +2512 -0
  78. gamengine3d/objects/at.obj +2682 -0
  79. gamengine3d/objects/b.obj +1104 -0
  80. gamengine3d/objects/backslash.obj +48 -0
  81. gamengine3d/objects/brace_close.obj +1179 -0
  82. gamengine3d/objects/brace_open.obj +1179 -0
  83. gamengine3d/objects/bracket_close.obj +88 -0
  84. gamengine3d/objects/bracket_open.obj +88 -0
  85. gamengine3d/objects/c.obj +1082 -0
  86. gamengine3d/objects/caret.obj +81 -0
  87. gamengine3d/objects/colon.obj +912 -0
  88. gamengine3d/objects/comma.obj +675 -0
  89. gamengine3d/objects/d.obj +861 -0
  90. gamengine3d/objects/dash.obj +48 -0
  91. gamengine3d/objects/dollar.obj +1671 -0
  92. gamengine3d/objects/dot.obj +532 -0
  93. gamengine3d/objects/doublequote.obj +114 -0
  94. gamengine3d/objects/e.obj +1094 -0
  95. gamengine3d/objects/equals.obj +76 -0
  96. gamengine3d/objects/exclamation.obj +1336 -0
  97. gamengine3d/objects/f.obj +660 -0
  98. gamengine3d/objects/g.obj +2694 -0
  99. gamengine3d/objects/greater.obj +81 -0
  100. gamengine3d/objects/h.obj +628 -0
  101. gamengine3d/objects/hash.obj +332 -0
  102. gamengine3d/objects/i.obj +558 -0
  103. gamengine3d/objects/j.obj +824 -0
  104. gamengine3d/objects/k.obj +104 -0
  105. gamengine3d/objects/l.obj +48 -0
  106. gamengine3d/objects/less.obj +81 -0
  107. gamengine3d/objects/m.obj +1177 -0
  108. gamengine3d/objects/n.obj +628 -0
  109. gamengine3d/objects/o.obj +968 -0
  110. gamengine3d/objects/p.obj +861 -0
  111. gamengine3d/objects/paren_close.obj +554 -0
  112. gamengine3d/objects/paren_open.obj +554 -0
  113. gamengine3d/objects/percent.obj +1767 -0
  114. gamengine3d/objects/plus.obj +128 -0
  115. gamengine3d/objects/q.obj +861 -0
  116. gamengine3d/objects/question.obj +1306 -0
  117. gamengine3d/objects/r.obj +608 -0
  118. gamengine3d/objects/s.obj +1478 -0
  119. gamengine3d/objects/semicolon.obj +1185 -0
  120. gamengine3d/objects/singlequote.obj +70 -0
  121. gamengine3d/objects/slash.obj +48 -0
  122. gamengine3d/objects/t.obj +639 -0
  123. gamengine3d/objects/u.obj +618 -0
  124. gamengine3d/objects/underscore.obj +48 -0
  125. gamengine3d/objects/v.obj +81 -0
  126. gamengine3d/objects/w.obj +147 -0
  127. gamengine3d/objects/x.obj +136 -0
  128. gamengine3d/objects/y.obj +92 -0
  129. gamengine3d/objects/z.obj +90 -0
  130. gamengine3d/renderer.py +1390 -0
  131. gamengine3d/shaders/__init__.py +0 -0
  132. gamengine3d/shaders/default.frag +143 -0
  133. gamengine3d/shaders/default.vert +43 -0
  134. gamengine3d/shaders/depth.frag +2 -0
  135. gamengine3d/shaders/depth.vert +9 -0
  136. gamengine3d-0.5.0.dist-info/METADATA +177 -0
  137. gamengine3d-0.5.0.dist-info/RECORD +141 -0
  138. gamengine3d-0.5.0.dist-info/WHEEL +5 -0
  139. gamengine3d-0.5.0.dist-info/entry_points.txt +2 -0
  140. gamengine3d-0.5.0.dist-info/licenses/LICENSE.txt +21 -0
  141. gamengine3d-0.5.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,526 @@
1
+ from pathlib import Path
2
+ from gamengine3d import Engine, Cuboid, Cylinder, Sphere, Text, Light, Color, vector3d
3
+
4
+ # ---------------------------------------------------------------- Engine
5
+
6
+ engine = Engine(
7
+ 1280, 800,
8
+ background_color=Color.RGB(3, 6, 10),
9
+ ambient_light=0.08,
10
+ name="Reactor Demo",
11
+ )
12
+ engine.crosshair = "plus-sign-crosshair"
13
+ engine.context.mouse_sensitivity = 0.3
14
+
15
+ EXAMPLE_DIR = Path(__file__).parent
16
+ SCRIPT_DIR = EXAMPLE_DIR / "scripts"
17
+
18
+ ROOM_X = 80.0
19
+ ROOM_Z = 58.0
20
+ HEIGHT = 16.0
21
+
22
+ SLATE = Color.RGB(26, 30, 38)
23
+ DECK = Color.RGB(22, 26, 34)
24
+ GUNMETAL = Color.RGB(96, 102, 112)
25
+ DARKMETAL = Color.RGB(40, 45, 54)
26
+ TEAL = Color.RGB(45, 200, 210)
27
+ CYAN = Color.RGB(90, 190, 255)
28
+ AMBER = Color.RGB(255, 170, 60)
29
+ PINK = Color.RGB(255, 90, 180)
30
+ BLUE = Color.RGB(80, 150, 255)
31
+ GREEN = Color.RGB(120, 230, 130)
32
+ PAPER = Color.RGB(200, 210, 220)
33
+
34
+
35
+ def solid(name, pos, size, color, emit=False):
36
+ obj = Cuboid(pos=pos, size=size, color=color, name=f"Solid_{name}", emit=emit)
37
+ engine.add_object(obj)
38
+ return obj
39
+
40
+
41
+ _prop_count = [0]
42
+
43
+
44
+ def deco(pos, size, color, emit=False):
45
+ _prop_count[0] += 1
46
+ obj = Cuboid(name=f"Deco{_prop_count[0]:03d}", pos=pos, size=size, color=color, emit=emit)
47
+ engine.add_object(obj)
48
+ return obj
49
+
50
+
51
+ def light(position, color, intensity, name):
52
+ l = Light(position=position, color=color, intensity=intensity, show=False, name=name)
53
+ engine.add_light(l)
54
+ l.shadow_caster = False
55
+
56
+
57
+ def glow(pos, color, name, radius=0.16, speed=3.0, lo=0.6, hi=1.4):
58
+ s = Sphere(
59
+ pos=pos,
60
+ radius=radius,
61
+ color=color,
62
+ emit=True,
63
+ name=name,
64
+ )
65
+ s.shadow_caster = False
66
+ s.pulse_speed = speed
67
+ s.pulse_lo = lo
68
+ s.pulse_hi = hi
69
+ s.attach(str(SCRIPT_DIR / "pulse.py"), engine.context)
70
+ engine.add_object(s)
71
+ return s
72
+
73
+
74
+ def hanging_text(pos, text, color, rot, scale=0.4, spacing=0.1, emit=True, name=None):
75
+ engine.add_object(Text(
76
+ pos=pos,
77
+ text=text,
78
+ color=color,
79
+ scale=vector3d(scale),
80
+ spacing=spacing,
81
+ rotation=rot,
82
+ center=True,
83
+ emit=emit,
84
+ name=name or text,
85
+ ))
86
+
87
+
88
+ # ---------------------------------------------------------------- The hall
89
+
90
+ solid("Floor", vector3d(0, -0.5, 0), vector3d(ROOM_X, 1, ROOM_Z), DECK)
91
+ ceiling = solid("Ceiling", vector3d(0, HEIGHT + 0.5, 0), vector3d(ROOM_X, 1, ROOM_Z), Color.RGB(10, 13, 18))
92
+ ceiling.shadow_caster = False
93
+ solid("WallN", vector3d(0, 8.0, -ROOM_Z / 2), vector3d(ROOM_X, HEIGHT, 1), SLATE)
94
+ solid("WallS", vector3d(0, 8.0, ROOM_Z / 2), vector3d(ROOM_X, HEIGHT, 1), SLATE)
95
+ solid("WallW", vector3d(-ROOM_X / 2, 8.0, 0), vector3d(1, HEIGHT, ROOM_Z), SLATE)
96
+ solid("WallE", vector3d(ROOM_X / 2, 8.0, 0), vector3d(1, HEIGHT, ROOM_Z), SLATE)
97
+
98
+ # Four blocky pillars around the hall hold the ceiling and give cover.
99
+ for i, (px, pz) in enumerate(((-12, -12), (12, -12), (-12, 12), (12, 12))):
100
+ solid(f"Pillar{i}", vector3d(px, 2.5, pz), vector3d(1.4, 5.0, 1.4), Color.RGB(34, 38, 48))
101
+ glow(vector3d(px, 5.45, pz), TEAL, f"PillarCap{i}", radius=0.22, speed=3.4, hi=1.8)
102
+
103
+ # ---------------------------------------------------------------- Reactor
104
+
105
+ solid("ReactorBase", vector3d(0, 0.7, 0), vector3d(6.4, 1.4, 6.4), GUNMETAL)
106
+ solid("CoreStep", vector3d(0, 0.25, 3.4), vector3d(1.6, 0.5, 2.0), Color.RGB(46, 52, 62))
107
+ deco(vector3d(0, 1.46, 0), vector3d(6.8, 0.12, 6.8), TEAL, emit=True)
108
+
109
+ core = Sphere(
110
+ pos=vector3d(0, 2.3, 0),
111
+ radius=0.9,
112
+ color=Color.RGB(120, 240, 245),
113
+ emit=True,
114
+ name="ReactorCore",
115
+ )
116
+ core.shadow_caster = False
117
+ core.attach(str(SCRIPT_DIR / "reactor_core.py"), engine.context)
118
+ engine.add_object(core)
119
+
120
+ core_marker = Cuboid(
121
+ pos=vector3d(0, 2.4, 0),
122
+ size=vector3d(1.5, 1.5, 1.5),
123
+ color=Color.RGB(0, 0, 0),
124
+ name="CoreMarker",
125
+ visible=False,
126
+ )
127
+ core_marker.shadow_caster = False
128
+ core_marker.attach(str(SCRIPT_DIR / "collector.py"), engine.context)
129
+ engine.add_object(core_marker)
130
+
131
+ halo_core = Sphere(
132
+ pos=vector3d(0, 2.3, 0),
133
+ radius=2.0,
134
+ color=TEAL,
135
+ emit=True,
136
+ visible=False,
137
+ name="HaloCore",
138
+ )
139
+ halo_core.shadow_caster = False
140
+ engine.add_object(halo_core)
141
+
142
+ # Four teal petals shroud the core until it is restored.
143
+ for i, (ox, oz) in enumerate(((0, 1.55), (1.55, 0), (0, -1.55), (-1.55, 0))):
144
+ size = vector3d(2.4 if ox == 0 else 1.0, 0.16, 2.4 if oz == 0 else 1.0)
145
+ petal = Cuboid(
146
+ pos=vector3d(ox, 2.3, oz),
147
+ size=size,
148
+ color=Color.RGB(30, 120, 128),
149
+ emit=True,
150
+ name=f"Petal{i}",
151
+ )
152
+ petal.shadow_caster = False
153
+ engine.add_object(petal)
154
+
155
+ # Three glowing orbs busily circle the dome.
156
+ for i, (h, s) in enumerate(((1.6, 0.9), (2.4, 1.2), (3.2, 1.5))):
157
+ orb = Sphere(
158
+ pos=vector3d(2.7, h, 0),
159
+ radius=0.13,
160
+ color=TEAL,
161
+ emit=True,
162
+ name=f"Orbit{i}",
163
+ )
164
+ orb.shadow_caster = False
165
+ orb.orbit_center = vector3d(0, 3.0, 0)
166
+ orb.orbit_radius = 2.7
167
+ orb.orbit_height = h
168
+ orb.orbit_speed = s
169
+ orb.attach(str(SCRIPT_DIR / "orbiter.py"), engine.context)
170
+ engine.add_object(orb)
171
+
172
+ # A maintenance drone lazily patrols the vault.
173
+ drone = Sphere(
174
+ pos=vector3d(7, 3.5, 0),
175
+ radius=0.3,
176
+ color=CYAN,
177
+ emit=True,
178
+ name="Drone",
179
+ )
180
+ drone.shadow_caster = False
181
+ drone.drone_center = vector3d(0, 3.5, 0)
182
+ drone.drone_radius = 7.0
183
+ drone.drone_speed = 0.55
184
+ drone.attach(str(SCRIPT_DIR / "drone.py"), engine.context)
185
+ engine.add_object(drone)
186
+
187
+ # ---------------------------------------------------------------- Station builder
188
+
189
+ # Every breaker lives on an identical pad: glowing floor tile, two beacon
190
+ # columns with caps, a floating crystal, a name tag and a tip line, all in
191
+ # the station's colour. Solve it and the whole pad flips green.
192
+ #
193
+ # key : short id used in every object name (Gate/Coil/Shield/Decoder)
194
+ # full : big label shown above the station
195
+ # tip : what to do when standing on the pad (no-space glyph set)
196
+ # f : unit vector from the station toward the room centre (label faces it)
197
+ # p : unit vector perpendicular to f (beacon column offset direction)
198
+ # rot : text rotation so labels/tips face the room centre
199
+ STATIONS = [
200
+ {
201
+ "key": "Gate",
202
+ "full": "MOTION_GATE",
203
+ "tip": "E:_RESYNC",
204
+ "cx": -33.0, "cz": -8.0,
205
+ "fx": 1.0, "fz": 0.0,
206
+ "px": 0.0, "pz": 1.0,
207
+ "rot": vector3d(0, 90, 0),
208
+ "color": AMBER,
209
+ },
210
+ {
211
+ "key": "Coil",
212
+ "full": "SHOCK_COIL",
213
+ "tip": "E:_REBOOT",
214
+ "cx": 20.0, "cz": 20.0,
215
+ "fx": 0.0, "fz": -1.0,
216
+ "px": 1.0, "pz": 0.0,
217
+ "rot": vector3d(270, 0, 0),
218
+ "color": PINK,
219
+ },
220
+ {
221
+ "key": "Shield",
222
+ "full": "SHIELD_VAULT",
223
+ "tip": "E:_OVERRIDE",
224
+ "cx": 30.0, "cz": 0.0,
225
+ "fx": -1.0, "fz": 0.0,
226
+ "px": 0.0, "pz": 1.0,
227
+ "rot": vector3d(0, 270, 0),
228
+ "color": BLUE,
229
+ },
230
+ {
231
+ "key": "Decoder",
232
+ "full": "DECODER",
233
+ "tip": "E:_INPUT",
234
+ "cx": 0.0, "cz": -22.0,
235
+ "fx": 0.0, "fz": 1.0,
236
+ "px": 1.0, "pz": 0.0,
237
+ "rot": vector3d(90, 0, 0),
238
+ "color": GREEN,
239
+ },
240
+ ]
241
+
242
+
243
+ def station(d):
244
+ key = d["key"]
245
+ cx, cz = d["cx"], d["cz"]
246
+ color = d["color"]
247
+
248
+ pad = solid(f"{key}Pad", vector3d(cx, 0.08, cz), vector3d(5.6, 0.16, 5.6), Color.RGB(14, 17, 22))
249
+ ring = solid(f"{key}Ring", vector3d(cx, 0.16, cz), vector3d(5.6, 0.08, 5.6), color, emit=True)
250
+
251
+ for i, sgn in enumerate((-1, 1)):
252
+ bx = cx + sgn * d["px"] * 2.2
253
+ bz = cz + sgn * d["pz"] * 2.2
254
+ pillar = Cuboid(
255
+ pos=vector3d(bx, 1.8, bz),
256
+ size=vector3d(0.32, 3.6, 0.32),
257
+ color=DARKMETAL,
258
+ name=f"Beacon{key}{i}",
259
+ )
260
+ pillar.shadow_caster = False
261
+ engine.add_object(pillar)
262
+ glow(vector3d(bx, 3.75, bz), color, f"BeaconCap{key}{i}", radius=0.18, speed=3.2)
263
+
264
+ crystal = Cuboid(
265
+ pos=vector3d(cx, 2.35, cz),
266
+ size=vector3d(0.46),
267
+ color=color,
268
+ emit=True,
269
+ name=f"Crystal{key}",
270
+ )
271
+ crystal.shadow_caster = False
272
+ crystal.spin_speed = 40.0
273
+ crystal.attach(str(SCRIPT_DIR / "spin.py"), engine.context)
274
+ engine.add_object(crystal)
275
+
276
+ glow(vector3d(cx, 2.2, cz), color, f"CrystalGlow{key}", radius=0.2, speed=3.6, hi=1.6)
277
+
278
+ hanging_text(vector3d(cx, 4.6, cz), d["full"], color, d["rot"], scale=0.5, name=f"Label{key}")
279
+ hanging_text(vector3d(cx, 3.4, cz), d["tip"], PAPER, d["rot"], scale=0.24, spacing=0.09, name=f"Tip{key}")
280
+
281
+ halo = Sphere(
282
+ pos=vector3d(cx, 1.2, cz),
283
+ radius=1.7,
284
+ color=color,
285
+ emit=True,
286
+ visible=False,
287
+ name=f"Halo{key}",
288
+ )
289
+ halo.shadow_caster = False
290
+ engine.add_object(halo)
291
+
292
+ light(vector3d(cx, 3.6, cz), color, 0.7, f"Pad{key}")
293
+ return pad
294
+
295
+
296
+ def console(name, pos, size, color, front_color, fx, fz, script):
297
+ box = Cuboid(pos=pos, size=size, color=color, name=f"Breaker_{name}")
298
+ box.attach(str(SCRIPT_DIR / script), engine.context)
299
+ engine.add_object(box)
300
+ if fx:
301
+ axis = size.x
302
+ offset = vector3d(fx * (axis / 2 - 0.02), 0, 0)
303
+ strip_size = vector3d(0.05, size.y - 0.5, size.z - 0.16)
304
+ else:
305
+ axis = size.z
306
+ offset = vector3d(0, 0, fz * (axis / 2 - 0.02))
307
+ strip_size = vector3d(size.x - 0.16, size.y - 0.5, 0.05)
308
+ strip = deco(pos + offset + vector3d(0, -0.1, 0), strip_size, front_color, emit=True)
309
+ strip.shadow_caster = False
310
+ return box
311
+
312
+
313
+ # ---------------------------------------------------------------- A: Motion Gate (west)
314
+
315
+ station(STATIONS[0])
316
+
317
+ deco(vector3d(-38.3, 1.75, -9.5), vector3d(0.16, 3.5, 0.24), SLATE)
318
+ deco(vector3d(-38.3, 1.75, -6.5), vector3d(0.16, 3.5, 0.24), SLATE)
319
+ deco(vector3d(-38.3, 3.5, -8), vector3d(0.16, 0.5, 3.4), SLATE)
320
+ deco(vector3d(-37.9, 2.1, -8), vector3d(0.12, 1.9, 1.6), AMBER, emit=True)
321
+
322
+ solid("DoorGate", vector3d(-37.6, 1.5, -8), vector3d(0.3, 2.2, 2.6), Color.RGB(70, 76, 88))
323
+ console("GateConsole", vector3d(-33, 1.1, -8), vector3d(1.15, 1.6, 0.55), Color.RGB(40, 34, 26), AMBER, 1.0, 0.0, "breaker_gate.py")
324
+ glow(vector3d(-33, 1.95, -8), AMBER, "GateLamp", radius=0.15, speed=3.0)
325
+
326
+ # ---------------------------------------------------------------- B: Shock Coil (south)
327
+
328
+ station(STATIONS[1])
329
+
330
+ solid("CoilBase", vector3d(20, 0.15, 20), vector3d(2.0, 0.5, 2.0), GUNMETAL)
331
+ for i, cy in enumerate((1.6, 2.0, 2.4)):
332
+ engine.add_object(Cylinder(
333
+ pos=vector3d(20, cy, 20),
334
+ length=0.1,
335
+ radius=0.55,
336
+ color=PINK,
337
+ name=f"CoilRing{i}",
338
+ emit=True,
339
+ ))
340
+ cyl = Cylinder(
341
+ pos=vector3d(20, 3.0, 20),
342
+ length=1.5,
343
+ radius=0.06,
344
+ color=Color.RGB(46, 52, 62),
345
+ name="CoilSupport",
346
+ )
347
+ engine.add_object(cyl)
348
+ beacon = Cuboid(
349
+ pos=vector3d(20, 3.4, 20),
350
+ size=vector3d(0.12, 0.22, 1.5),
351
+ color=PINK,
352
+ emit=True,
353
+ name="CoilBeacon",
354
+ )
355
+ beacon.shadow_caster = False
356
+ beacon.spin_speed = 70.0
357
+ beacon.attach(str(SCRIPT_DIR / "spin.py"), engine.context)
358
+ engine.add_object(beacon)
359
+
360
+ ball = Sphere(
361
+ pos=vector3d(20, 1.0, 20),
362
+ radius=0.25,
363
+ color=Color.RGB(255, 230, 240),
364
+ emit=True,
365
+ name="Ball",
366
+ )
367
+ ball.shadow_caster = False
368
+ ball.bounce_floor = 0.5
369
+ ball.bounce_height = 2.4
370
+ ball.attach(str(SCRIPT_DIR / "bouncer.py"), engine.context)
371
+ engine.add_object(ball)
372
+
373
+ for i, (h, s) in enumerate(((1.4, 1.0), (2.0, 1.3), (2.6, 1.6))):
374
+ spark = Sphere(
375
+ pos=vector3d(21.6, h, 20),
376
+ radius=0.11,
377
+ color=PINK,
378
+ emit=True,
379
+ name=f"CoilOrb{i}",
380
+ )
381
+ spark.shadow_caster = False
382
+ spark.orbit_center = vector3d(20, 2.0, 20)
383
+ spark.orbit_radius = 1.6
384
+ spark.orbit_height = h
385
+ spark.orbit_speed = s
386
+ spark.attach(str(SCRIPT_DIR / "orbiter.py"), engine.context)
387
+ engine.add_object(spark)
388
+
389
+ console("CoilConsole", vector3d(18.4, 1.0, 20), vector3d(1.0, 1.5, 0.5), Color.RGB(38, 24, 34), PINK, 0.0, -1.0, "breaker_coil.py")
390
+ glow(vector3d(18.4, 2.0, 20), PINK, "CoilLamp", radius=0.15, speed=3.4, hi=1.8)
391
+
392
+ # ---------------------------------------------------------------- C: Shield Vault (east)
393
+
394
+ station(STATIONS[2])
395
+
396
+ solid("VaultN", vector3d(33, 1.5, -2.9), vector3d(9.0, 3.0, 0.4), SLATE)
397
+ solid("VaultS", vector3d(33, 1.5, 2.9), vector3d(9.0, 3.0, 0.4), SLATE)
398
+ solid("VaultBack", vector3d(37.4, 1.5, 0), vector3d(0.4, 3.0, 6.0), SLATE)
399
+ solid("VaultBar", vector3d(31.0, 1.1, 0), vector3d(0.35, 2.6, 5.6), Color.RGB(60, 66, 80))
400
+
401
+ field_viz = Cuboid(
402
+ pos=vector3d(31.0, 1.2, 0),
403
+ size=vector3d(0.1, 2.4, 5.2),
404
+ color=BLUE,
405
+ emit=True,
406
+ name="ShieldField",
407
+ )
408
+ field_viz.shadow_caster = False
409
+ engine.add_object(field_viz)
410
+
411
+ console("ShieldConsole", vector3d(28.4, 1.0, 0), vector3d(1.0, 1.5, 0.5), Color.RGB(22, 30, 46), BLUE, -1.0, 0.0, "breaker_shield.py")
412
+ glow(vector3d(28.4, 2.0, 0), BLUE, "ShieldLamp", radius=0.15, speed=3.0)
413
+
414
+ # ---------------------------------------------------------------- D: Decoder (north)
415
+
416
+ station(STATIONS[3])
417
+
418
+ deco(vector3d(0, 0.3, -22), vector3d(1.3, 0.2, 0.7), Color.RGB(36, 42, 34))
419
+ console("DecoderConsole", vector3d(0, 1.0, -22), vector3d(1.1, 1.5, 0.5), Color.RGB(28, 40, 28), GREEN, 0.0, 1.0, "breaker_decoder.py")
420
+
421
+ engine.add_object(Text(
422
+ pos=vector3d(0, 2.0, -22.4),
423
+ text="#-#-#-#",
424
+ color=GREEN,
425
+ scale=vector3d(0.55),
426
+ spacing=0.11,
427
+ rotation=vector3d(90, 0, 0),
428
+ center=True,
429
+ emit=True,
430
+ name="Breaker_DecoderPanel",
431
+ ))
432
+
433
+ # ---------------------------------------------------------------- Story & mission boards
434
+
435
+ solid("BoardStory", vector3d(-39.8, 7.5, 0), vector3d(0.2, 8, 30), Color.RGB(14, 17, 22))
436
+ hanging_text(vector3d(-39.4, 10.4, 0), "INCIDENT:_92", TEAL, vector3d(0, 90, 0), scale=0.5)
437
+ hanging_text(vector3d(-39.4, 9.4, 0), "CORE_SURGE:_SHUTDOWN", PAPER, vector3d(0, 90, 0), scale=0.4)
438
+ hanging_text(vector3d(-39.4, 8.4, 0), "4:_BREAKERS:_OFFLINE", PAPER, vector3d(0, 90, 0), scale=0.4)
439
+ hanging_text(vector3d(-39.4, 7.4, 0), "REBUILD:_CLAIM:_CORE", PAPER, vector3d(0, 90, 0), scale=0.4)
440
+ hanging_text(vector3d(-39.4, 6.2, 0), "E:_ON:_CORE:_TO:_GRAB", Color.RGB(220, 190, 120), vector3d(0, 90, 0), scale=0.3)
441
+
442
+ solid("BoardMission", vector3d(0, 7, 28.7), vector3d(34, 8, 0.2), Color.RGB(16, 20, 26))
443
+ hanging_text(vector3d(0, 10.2, 28.5), "MISSION:_RESTORE_CORE", TEAL, vector3d(270, 0, 0), scale=0.5)
444
+ hanging_text(vector3d(0, 9.2, 28.5), "1:_GATE:_WEST", AMBER, vector3d(270, 0, 0), scale=0.42)
445
+ hanging_text(vector3d(0, 8.2, 28.5), "2:_COIL:_SOUTH", PINK, vector3d(270, 0, 0), scale=0.42)
446
+ hanging_text(vector3d(0, 7.2, 28.5), "3:_VAULT:_EAST", BLUE, vector3d(270, 0, 0), scale=0.42)
447
+ hanging_text(vector3d(0, 6.2, 28.5), "4:_DECODER:_NORTH", GREEN, vector3d(270, 0, 0), scale=0.42)
448
+ hanging_text(vector3d(0, 5.0, 28.5), "HOLD:_E:_AT:_CORE:_WHEN:_4:_OK", Color.RGB(180, 200, 210), vector3d(270, 0, 0), scale=0.3, spacing=0.09)
449
+
450
+ # ---------------------------------------------------------------- Lights
451
+
452
+ light(vector3d(-12, 12.5, 8), Color.RGB(200, 225, 255), 0.9, "HallLamp0")
453
+ light(vector3d(12, 12.5, -8), Color.RGB(200, 225, 255), 0.9, "HallLamp1")
454
+ light(vector3d(0, 6.2, 2.6), Color.RGB(60, 220, 230), 0.7, "DomeA")
455
+ light(vector3d(0, 9.0, -2.2), Color.RGB(90, 190, 255), 0.6, "DomeB")
456
+ light(vector3d(0, 3.4, 0), Color.RGB(60, 220, 230), 0.9, "CoreGlow")
457
+ light(vector3d(0, 3.8, 0), Color.RGB(255, 255, 240), 0.0, "CoreBright")
458
+
459
+ engine.attach(str(SCRIPT_DIR / "director.py"))
460
+
461
+ # ---------------------------------------------------------------- HUD
462
+
463
+ engine.add_object(Text(
464
+ pos=vector3d(0, 12, -28.5),
465
+ text="RESTORE_CORE:0:4",
466
+ color=Color.RGB(90, 230, 240),
467
+ scale=vector3d(0.5),
468
+ spacing=0.1,
469
+ rotation=vector3d(90, 0, 0),
470
+ center=True,
471
+ emit=True,
472
+ name="Hud_Objective",
473
+ ))
474
+
475
+ engine.add_object(Text(
476
+ pos=vector3d(0, 3.4, 28.5),
477
+ text="wasd:move.shift:sprint.space:jump.E:interact.R:decode.M:mouse.click:grab.C:crosshair.K:save",
478
+ color=Color.RGB(110, 120, 130),
479
+ scale=vector3d(0.24),
480
+ spacing=0.09,
481
+ rotation=vector3d(270, 0, 0),
482
+ center=True,
483
+ name="Hud_Help",
484
+ ))
485
+
486
+ engine.add_object(Text(
487
+ pos=vector3d(0, 6.8, 0),
488
+ text="POWER_RESTORED",
489
+ color=Color.RGB(255, 210, 80),
490
+ scale=vector3d(0.9),
491
+ spacing=0.14,
492
+ rotation=vector3d(90, 0, 0),
493
+ center=True,
494
+ emit=True,
495
+ visible=False,
496
+ name="Hud_Win",
497
+ ))
498
+
499
+ # A hidden behaviour marker: casts the interact ray at the thing you look at.
500
+ interactor = Cuboid(
501
+ pos=vector3d(0, -10, 0),
502
+ size=vector3d(0.4),
503
+ color=Color.RGB(0, 0, 0),
504
+ visible=False,
505
+ name="Interactor",
506
+ )
507
+ interactor.attach(str(SCRIPT_DIR / "interact.py"), engine.context)
508
+ engine.add_object(interactor)
509
+
510
+ # ---------------------------------------------------------------- Player
511
+
512
+ player = Cuboid(
513
+ name="Player",
514
+ color=Color.RGB(255, 60, 60),
515
+ size=vector3d(0.6, 1.8, 0.6),
516
+ pos=vector3d(0, 0.9, 22),
517
+ visible=False,
518
+ )
519
+ player.attach(str(SCRIPT_DIR / "player_controller.py"), engine.context)
520
+ engine.add_object(player)
521
+
522
+ engine.camera.move_to(vector3d(-14, 7, 30))
523
+ engine.camera.look_at(vector3d(0, 2, 0))
524
+ engine.context.set_mouse_look(True)
525
+
526
+ engine.run(dynamic_view=False)
File without changes
@@ -0,0 +1,18 @@
1
+ class Bouncer:
2
+ def __init__(self, obj, context):
3
+ self.obj = obj
4
+ self.context = context
5
+ self.floor = getattr(obj, "bounce_floor", 0.0)
6
+ self.max_height = getattr(obj, "bounce_height", 2.2)
7
+ self.vel = 0.0
8
+ self.g = 22.0
9
+
10
+ def update(self, dt):
11
+ if not getattr(self.context.runtime_vars, "coil_powered", False):
12
+ return
13
+ self.vel -= self.g * dt
14
+ self.obj.pos.y += self.vel * dt
15
+ bottom = self.floor + self.obj.radius
16
+ if self.obj.pos.y <= bottom:
17
+ self.obj.pos.y = bottom
18
+ self.vel = (2 * self.g * (self.max_height - bottom)) ** 0.5
@@ -0,0 +1,17 @@
1
+ class BreakerCoil:
2
+ def __init__(self, obj, context):
3
+ self.obj = obj
4
+ self.context = context
5
+ self.solved = False
6
+
7
+ def update(self, dt):
8
+ if self.solved or not self.obj.received_message:
9
+ return
10
+ self.obj.received_message = False
11
+ self.solve()
12
+
13
+ def solve(self):
14
+ self.solved = True
15
+ self.context.runtime_vars.coil_powered = True
16
+ core = self.context.functions.get_game_object("ReactorCore")
17
+ core.message(message="restored_coil", sender=self.obj.name)
@@ -0,0 +1,39 @@
1
+ class BreakerDecoder:
2
+ CODES = ["#-#-#-#", "5-#-#-#", "5-e-#-#", "5-e-3-#", "5-e-3-5"]
3
+
4
+ def __init__(self, obj, context):
5
+ self.obj = obj
6
+ self.context = context
7
+ self.state = 0
8
+ self.solved = False
9
+ context.on_key_press("r", self.scramble)
10
+
11
+ def start(self):
12
+ self.apply_text()
13
+
14
+ def update(self, dt):
15
+ if self.solved or not self.obj.received_message:
16
+ return
17
+ self.obj.received_message = False
18
+ self.decode()
19
+
20
+ def decode(self):
21
+ if not self.solved:
22
+ self.state += 1
23
+ if self.state >= len(self.CODES) - 1:
24
+ self.state = len(self.CODES) - 1
25
+ self.solved = True
26
+ self.apply_text()
27
+ if self.solved:
28
+ self.context.runtime_vars.decoder_powered = True
29
+ core = self.context.functions.get_game_object("ReactorCore")
30
+ core.message(message="restored_decoder", sender=self.obj.name)
31
+
32
+ def scramble(self):
33
+ if not self.solved:
34
+ self.state = 0
35
+ self.apply_text()
36
+
37
+ def apply_text(self):
38
+ panel = self.context.functions.get_game_object("Breaker_DecoderPanel")
39
+ panel.text = self.CODES[self.state]
@@ -0,0 +1,23 @@
1
+ class BreakerGate:
2
+ def __init__(self, obj, context):
3
+ self.obj = obj
4
+ self.context = context
5
+ self.solved = False
6
+
7
+ def update(self, dt):
8
+ if self.solved or not self.obj.received_message:
9
+ return
10
+ self.obj.received_message = False
11
+ self.solve()
12
+
13
+ def solve(self):
14
+ self.solved = True
15
+ self.context.runtime_vars.gate_powered = True
16
+ door = self.context.functions.get_game_object("Solid_DoorGate")
17
+ for i in range(10):
18
+ self.context.add_delay(0.05 * (i + 1), lambda: self.step_door(door))
19
+ core = self.context.functions.get_game_object("ReactorCore")
20
+ core.message(message="restored_gate", sender=self.obj.name)
21
+
22
+ def step_door(self, door):
23
+ door.pos.x += 0.3
@@ -0,0 +1,28 @@
1
+ class BreakerShield:
2
+ def __init__(self, obj, context):
3
+ self.obj = obj
4
+ self.context = context
5
+ self.solved = False
6
+ self.cycles = 0
7
+ self.open_now = False
8
+
9
+ def update(self, dt):
10
+ if self.solved or not self.obj.received_message:
11
+ return
12
+ self.obj.received_message = False
13
+ if self.open_now:
14
+ return
15
+ self.open_now = True
16
+ bar = self.context.functions.get_game_object("Solid_VaultBar")
17
+ bar.pos.y += 2.2
18
+ self.context.add_delay(5.0, lambda: self.close_bar(bar))
19
+
20
+ def close_bar(self, bar):
21
+ bar.pos.y -= 2.2
22
+ self.open_now = False
23
+ self.cycles += 1
24
+ if self.cycles >= 2:
25
+ self.solved = True
26
+ self.context.runtime_vars.shield_powered = True
27
+ core = self.context.functions.get_game_object("ReactorCore")
28
+ core.message(message="restored_shield", sender=self.obj.name)
@@ -0,0 +1,12 @@
1
+ import math
2
+ import time
3
+
4
+
5
+ class Coin:
6
+ def __init__(self, obj, context):
7
+ self.obj = obj
8
+ self.base_y = obj.pos.y
9
+ self.phase = (obj.pos.x + obj.pos.z) * 0.5
10
+
11
+ def update(self, dt):
12
+ self.obj.pos.y = self.base_y + math.sin(time.time() * 2.2 + self.phase) * 0.25
@@ -0,0 +1,13 @@
1
+ class Collector:
2
+ def __init__(self, obj, context):
3
+ self.obj = obj
4
+ self.context = context
5
+
6
+ def update(self, dt):
7
+ if not self.obj.received_message:
8
+ return
9
+ if getattr(self.context.runtime_vars, "reactor_open", False):
10
+ self.context.runtime_vars.won = True
11
+ self.obj.visible = False
12
+ core = self.context.functions.get_game_object("ReactorCore")
13
+ core.visible = False