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.
- gamengine3d/__init__.py +18 -0
- gamengine3d/assets/__init__.py +0 -0
- gamengine3d/assets/circular_crosshair.png +0 -0
- gamengine3d/assets/plus_sign_crosshair.png +0 -0
- gamengine3d/cli.py +83 -0
- gamengine3d/context.py +319 -0
- gamengine3d/engine.py +715 -0
- gamengine3d/examples/__init__.py +0 -0
- gamengine3d/examples/basics.py +66 -0
- gamengine3d/examples/parkour.py +285 -0
- gamengine3d/examples/player_movement.py +161 -0
- gamengine3d/examples/reactor.py +526 -0
- gamengine3d/examples/scripts/__init__.py +0 -0
- gamengine3d/examples/scripts/bouncer.py +18 -0
- gamengine3d/examples/scripts/breaker_coil.py +17 -0
- gamengine3d/examples/scripts/breaker_decoder.py +39 -0
- gamengine3d/examples/scripts/breaker_gate.py +23 -0
- gamengine3d/examples/scripts/breaker_shield.py +28 -0
- gamengine3d/examples/scripts/coin.py +12 -0
- gamengine3d/examples/scripts/collector.py +13 -0
- gamengine3d/examples/scripts/confetti.py +27 -0
- gamengine3d/examples/scripts/director.py +213 -0
- gamengine3d/examples/scripts/drone.py +21 -0
- gamengine3d/examples/scripts/ghost_pulse.py +24 -0
- gamengine3d/examples/scripts/horror_atmosphere.py +96 -0
- gamengine3d/examples/scripts/interact.py +45 -0
- gamengine3d/examples/scripts/orbiter.py +25 -0
- gamengine3d/examples/scripts/player_controller.py +165 -0
- gamengine3d/examples/scripts/pulse.py +22 -0
- gamengine3d/examples/scripts/reactor_core.py +29 -0
- gamengine3d/examples/scripts/spin.py +13 -0
- gamengine3d/examples/scripts/sway.py +19 -0
- gamengine3d/examples/scripts/void_guard.py +26 -0
- gamengine3d/examples/transparency.py +92 -0
- gamengine3d/game_objects.py +975 -0
- gamengine3d/helper.py +720 -0
- gamengine3d/obj_reader.py +29 -0
- gamengine3d/objects/0.obj +964 -0
- gamengine3d/objects/1.obj +48 -0
- gamengine3d/objects/2.obj +983 -0
- gamengine3d/objects/3.obj +1623 -0
- gamengine3d/objects/4.obj +163 -0
- gamengine3d/objects/5.obj +861 -0
- gamengine3d/objects/6.obj +1314 -0
- gamengine3d/objects/7.obj +70 -0
- gamengine3d/objects/8.obj +1932 -0
- gamengine3d/objects/9.obj +1458 -0
- gamengine3d/objects/A_capital.obj +124 -0
- gamengine3d/objects/B_capital.obj +1118 -0
- gamengine3d/objects/C_capital.obj +1082 -0
- gamengine3d/objects/D_capital.obj +548 -0
- gamengine3d/objects/E_capital.obj +128 -0
- gamengine3d/objects/F_capital.obj +108 -0
- gamengine3d/objects/G_capital.obj +1125 -0
- gamengine3d/objects/H_capital.obj +128 -0
- gamengine3d/objects/I_capital.obj +48 -0
- gamengine3d/objects/J_capital.obj +454 -0
- gamengine3d/objects/K_capital.obj +125 -0
- gamengine3d/objects/L_capital.obj +68 -0
- gamengine3d/objects/M_capital.obj +163 -0
- gamengine3d/objects/N_capital.obj +112 -0
- gamengine3d/objects/O_capital.obj +968 -0
- gamengine3d/objects/P_capital.obj +620 -0
- gamengine3d/objects/Q_capital.obj +1362 -0
- gamengine3d/objects/R_capital.obj +1036 -0
- gamengine3d/objects/S_capital.obj +1346 -0
- gamengine3d/objects/T_capital.obj +88 -0
- gamengine3d/objects/U_capital.obj +860 -0
- gamengine3d/objects/V_capital.obj +81 -0
- gamengine3d/objects/W_capital.obj +147 -0
- gamengine3d/objects/X_capital.obj +136 -0
- gamengine3d/objects/Y_capital.obj +103 -0
- gamengine3d/objects/Z_capital.obj +90 -0
- gamengine3d/objects/__init__.py +0 -0
- gamengine3d/objects/a.obj +1920 -0
- gamengine3d/objects/ampersand.obj +2186 -0
- gamengine3d/objects/asterisk.obj +2512 -0
- gamengine3d/objects/at.obj +2682 -0
- gamengine3d/objects/b.obj +1104 -0
- gamengine3d/objects/backslash.obj +48 -0
- gamengine3d/objects/brace_close.obj +1179 -0
- gamengine3d/objects/brace_open.obj +1179 -0
- gamengine3d/objects/bracket_close.obj +88 -0
- gamengine3d/objects/bracket_open.obj +88 -0
- gamengine3d/objects/c.obj +1082 -0
- gamengine3d/objects/caret.obj +81 -0
- gamengine3d/objects/colon.obj +912 -0
- gamengine3d/objects/comma.obj +675 -0
- gamengine3d/objects/d.obj +861 -0
- gamengine3d/objects/dash.obj +48 -0
- gamengine3d/objects/dollar.obj +1671 -0
- gamengine3d/objects/dot.obj +532 -0
- gamengine3d/objects/doublequote.obj +114 -0
- gamengine3d/objects/e.obj +1094 -0
- gamengine3d/objects/equals.obj +76 -0
- gamengine3d/objects/exclamation.obj +1336 -0
- gamengine3d/objects/f.obj +660 -0
- gamengine3d/objects/g.obj +2694 -0
- gamengine3d/objects/greater.obj +81 -0
- gamengine3d/objects/h.obj +628 -0
- gamengine3d/objects/hash.obj +332 -0
- gamengine3d/objects/i.obj +558 -0
- gamengine3d/objects/j.obj +824 -0
- gamengine3d/objects/k.obj +104 -0
- gamengine3d/objects/l.obj +48 -0
- gamengine3d/objects/less.obj +81 -0
- gamengine3d/objects/m.obj +1177 -0
- gamengine3d/objects/n.obj +628 -0
- gamengine3d/objects/o.obj +968 -0
- gamengine3d/objects/p.obj +861 -0
- gamengine3d/objects/paren_close.obj +554 -0
- gamengine3d/objects/paren_open.obj +554 -0
- gamengine3d/objects/percent.obj +1767 -0
- gamengine3d/objects/plus.obj +128 -0
- gamengine3d/objects/q.obj +861 -0
- gamengine3d/objects/question.obj +1306 -0
- gamengine3d/objects/r.obj +608 -0
- gamengine3d/objects/s.obj +1478 -0
- gamengine3d/objects/semicolon.obj +1185 -0
- gamengine3d/objects/singlequote.obj +70 -0
- gamengine3d/objects/slash.obj +48 -0
- gamengine3d/objects/t.obj +639 -0
- gamengine3d/objects/u.obj +618 -0
- gamengine3d/objects/underscore.obj +48 -0
- gamengine3d/objects/v.obj +81 -0
- gamengine3d/objects/w.obj +147 -0
- gamengine3d/objects/x.obj +136 -0
- gamengine3d/objects/y.obj +92 -0
- gamengine3d/objects/z.obj +90 -0
- gamengine3d/renderer.py +1390 -0
- gamengine3d/shaders/__init__.py +0 -0
- gamengine3d/shaders/default.frag +143 -0
- gamengine3d/shaders/default.vert +43 -0
- gamengine3d/shaders/depth.frag +2 -0
- gamengine3d/shaders/depth.vert +9 -0
- gamengine3d-0.5.0.dist-info/METADATA +177 -0
- gamengine3d-0.5.0.dist-info/RECORD +141 -0
- gamengine3d-0.5.0.dist-info/WHEEL +5 -0
- gamengine3d-0.5.0.dist-info/entry_points.txt +2 -0
- gamengine3d-0.5.0.dist-info/licenses/LICENSE.txt +21 -0
- gamengine3d-0.5.0.dist-info/top_level.txt +1 -0
|
File without changes
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from gamengine3d import Engine, Cuboid, Sphere, vector3d, Light, Color
|
|
2
|
+
|
|
3
|
+
engine = Engine(
|
|
4
|
+
800, 600,
|
|
5
|
+
background_color=Color.RGB(30, 30, 40),
|
|
6
|
+
ambient_light=0.3,
|
|
7
|
+
name="Basics Demo"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
# Floor with subtle texture-like coloring
|
|
11
|
+
floor = Cuboid(
|
|
12
|
+
pos=vector3d(0, -0.5, 0),
|
|
13
|
+
size=vector3d(20, 1, 20),
|
|
14
|
+
color=Color.RGB(40, 40, 50),
|
|
15
|
+
name="Floor"
|
|
16
|
+
)
|
|
17
|
+
engine.add_object(floor)
|
|
18
|
+
|
|
19
|
+
# Central column
|
|
20
|
+
column = Cuboid(
|
|
21
|
+
pos=vector3d(0, 1.5, 0),
|
|
22
|
+
size=vector3d(0.5, 3, 0.5),
|
|
23
|
+
color=Color.RGB(100, 100, 120),
|
|
24
|
+
name="Column"
|
|
25
|
+
)
|
|
26
|
+
engine.add_object(column)
|
|
27
|
+
|
|
28
|
+
# Add a nice warm light
|
|
29
|
+
light = Light(
|
|
30
|
+
position=vector3d(0, 5, 3),
|
|
31
|
+
color=Color.RGB(255, 200, 150),
|
|
32
|
+
intensity=1.5,
|
|
33
|
+
name="WarmLight"
|
|
34
|
+
)
|
|
35
|
+
engine.add_light(light)
|
|
36
|
+
|
|
37
|
+
# Add ambient fill
|
|
38
|
+
ambient = Light(
|
|
39
|
+
position=vector3d(0, 10, 0),
|
|
40
|
+
color=Color.RGB(100, 100, 110),
|
|
41
|
+
intensity=0.2,
|
|
42
|
+
name="Ambient"
|
|
43
|
+
)
|
|
44
|
+
engine.add_light(ambient)
|
|
45
|
+
|
|
46
|
+
# A decorative sphere
|
|
47
|
+
sphere = Sphere(
|
|
48
|
+
pos=vector3d(-2, 2, -3),
|
|
49
|
+
radius=1.2,
|
|
50
|
+
color=Color.RGB(180, 120, 200),
|
|
51
|
+
name="DecorativeSphere"
|
|
52
|
+
)
|
|
53
|
+
engine.add_object(sphere)
|
|
54
|
+
|
|
55
|
+
# Another sphere on the other side
|
|
56
|
+
sphere2 = Sphere(
|
|
57
|
+
pos=vector3d(2, 2, 3),
|
|
58
|
+
radius=1.0,
|
|
59
|
+
color=Color.RGB(120, 180, 255),
|
|
60
|
+
name="DecorativeSphere2"
|
|
61
|
+
)
|
|
62
|
+
engine.add_object(sphere2)
|
|
63
|
+
|
|
64
|
+
engine.camera.move_to(vector3d(0, 3, 8))
|
|
65
|
+
engine.camera.look_at(vector3d(0, 1.5, 0))
|
|
66
|
+
engine.run(dynamic_view=False)
|
|
@@ -0,0 +1,285 @@
|
|
|
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(1, 2, 4),
|
|
9
|
+
ambient_light=0.05,
|
|
10
|
+
name="Parkour 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 = 48.0
|
|
19
|
+
ROOM_Z = 38.0
|
|
20
|
+
HEIGHT = 26.0
|
|
21
|
+
RIM = 5.0 # rim floor width around the central void
|
|
22
|
+
VOID_BOTTOM = -30.0 # deep dark floor of the pit
|
|
23
|
+
|
|
24
|
+
RUST = Color.RGB(86, 56, 40) # the start disc
|
|
25
|
+
GUNMETAL = Color.RGB(108, 112, 120)
|
|
26
|
+
EMBER = Color.RGB(150, 36, 34) # the summit disc, heated and glowing
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def solid(name, pos, size, color, emit=False):
|
|
30
|
+
obj = Cuboid(pos=pos, size=size, color=color, name=f"Solid_{name}", emit=emit)
|
|
31
|
+
engine.add_object(obj)
|
|
32
|
+
return obj
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
_prop_count = [0]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def deco(pos, size, color, emit=False):
|
|
39
|
+
_prop_count[0] += 1
|
|
40
|
+
obj = Cuboid(name=f"Prop{_prop_count[0]:03d}", pos=pos, size=size, color=color, emit=emit)
|
|
41
|
+
engine.add_object(obj)
|
|
42
|
+
return obj
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def disc(name, x, z, r, top_y, col, emit=False):
|
|
46
|
+
"""A floating disc platform: a thin cylinder over an invisible slab
|
|
47
|
+
of the same top height (only Cuboids can be landed on)."""
|
|
48
|
+
side = r * 1.41421 # square slab whose corners touch the disc circle
|
|
49
|
+
slab = Cuboid(
|
|
50
|
+
pos=vector3d(x, top_y - 0.1, z),
|
|
51
|
+
size=vector3d(side, 0.2, side),
|
|
52
|
+
color=col,
|
|
53
|
+
name=f"Solid_{name}",
|
|
54
|
+
)
|
|
55
|
+
slab.visible = False # invisible collision surface; the disc shows where to land
|
|
56
|
+
engine.add_object(slab)
|
|
57
|
+
engine.add_object(Cylinder(
|
|
58
|
+
pos=vector3d(x, top_y - 0.15, z),
|
|
59
|
+
length=0.3,
|
|
60
|
+
radius=r,
|
|
61
|
+
color=col,
|
|
62
|
+
name=f"Disc_{name}",
|
|
63
|
+
emit=emit,
|
|
64
|
+
))
|
|
65
|
+
engine.add_object(Cylinder(
|
|
66
|
+
pos=vector3d(x, (top_y - 0.3 + VOID_BOTTOM) / 2, z),
|
|
67
|
+
length=(top_y - 0.3) - VOID_BOTTOM,
|
|
68
|
+
radius=0.18,
|
|
69
|
+
color=Color.RGB(44, 48, 56),
|
|
70
|
+
name=f"Col_{name}",
|
|
71
|
+
))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# ---------------------------------------------------------------- Room + void
|
|
75
|
+
|
|
76
|
+
ceiling = solid("Ceiling", vector3d(0, HEIGHT + 0.5, 0), vector3d(ROOM_X, 1, ROOM_Z), Color.RGB(4, 5, 8))
|
|
77
|
+
ceiling.shadow_caster = False
|
|
78
|
+
solid("Wall_Back", vector3d(0, 2.0, -ROOM_Z / 2), vector3d(ROOM_X, HEIGHT, 0.2), Color.RGB(20, 22, 28))
|
|
79
|
+
solid("Wall_Front", vector3d(0, 2.0, ROOM_Z / 2), vector3d(ROOM_X, HEIGHT, 0.2), Color.RGB(20, 22, 28))
|
|
80
|
+
solid("Wall_Left", vector3d(-ROOM_X / 2, 2.0, 0), vector3d(0.2, HEIGHT, ROOM_Z), Color.RGB(20, 22, 28))
|
|
81
|
+
solid("Wall_Right", vector3d(ROOM_X / 2, 2.0, 0), vector3d(0.2, HEIGHT, ROOM_Z), Color.RGB(20, 22, 28))
|
|
82
|
+
|
|
83
|
+
# Ring of floor around an open pit. Four non-overlapping slabs, all top at y=0.
|
|
84
|
+
half_void_x = ROOM_X / 2 - RIM # 19
|
|
85
|
+
half_void_z = ROOM_Z / 2 - RIM # 14
|
|
86
|
+
solid("Rim_Left", vector3d(-(ROOM_X / 2 + half_void_x) / 2, -0.5, 0), vector3d(RIM, 1, ROOM_Z - 2 * RIM), Color.RGB(26, 27, 33))
|
|
87
|
+
solid("Rim_Right", vector3d((ROOM_X / 2 + half_void_x) / 2, -0.5, 0), vector3d(RIM, 1, ROOM_Z - 2 * RIM), Color.RGB(26, 27, 33))
|
|
88
|
+
solid("Rim_Back", vector3d(0, -0.5, -(ROOM_Z / 2 + half_void_z) / 2), vector3d(ROOM_X - 2 * RIM, 1, RIM), Color.RGB(26, 27, 33))
|
|
89
|
+
solid("Rim_Front", vector3d(0, -0.5, (ROOM_Z / 2 + half_void_z) / 2), vector3d(ROOM_X - 2 * RIM, 1, RIM), Color.RGB(26, 27, 33))
|
|
90
|
+
|
|
91
|
+
# Far-down dark slab so the pit reads as bottomless.
|
|
92
|
+
void_floor = solid("VoidFloor", vector3d(0, VOID_BOTTOM - 0.5, 0),
|
|
93
|
+
vector3d(2 * half_void_x + 4, 1, 2 * half_void_z + 4),
|
|
94
|
+
Color.RGB(2, 3, 5))
|
|
95
|
+
void_floor.shadow_caster = False
|
|
96
|
+
|
|
97
|
+
# ---------------------------------------------------------------- Big disc course
|
|
98
|
+
|
|
99
|
+
RISE = 0.8
|
|
100
|
+
# (x, z, radius, top_y) — one big serpentine crossing the whole arena.
|
|
101
|
+
# Every pair of neighbouring discs is spaced wider than their radii summed,
|
|
102
|
+
# so there is always a clear gap (start/summit are r2.0, most are r1.4).
|
|
103
|
+
DISC_T = 1.2
|
|
104
|
+
DISCS = [
|
|
105
|
+
(-14, -12, 2.0, DISC_T), # 1 start, just off the back rim
|
|
106
|
+
(-11, -9, 1.4, DISC_T + RISE),
|
|
107
|
+
(-8, -7, 1.4, DISC_T + 2 * RISE),
|
|
108
|
+
(-5, -5, 1.4, DISC_T + 3 * RISE),
|
|
109
|
+
(-2, -7, 1.4, DISC_T + 4 * RISE),
|
|
110
|
+
(1, -5, 1.4, DISC_T + 5 * RISE),
|
|
111
|
+
(4, -7, 1.4, DISC_T + 6 * RISE),
|
|
112
|
+
(7, -5, 1.4, DISC_T + 7 * RISE),
|
|
113
|
+
(9, -2, 1.4, DISC_T + 8 * RISE),
|
|
114
|
+
(8, 1, 1.4, DISC_T + 9 * RISE),
|
|
115
|
+
(5, 3, 1.4, DISC_T + 10 * RISE),
|
|
116
|
+
(2, 5, 1.4, DISC_T + 11 * RISE),
|
|
117
|
+
(-1, 7, 1.4, DISC_T + 12 * RISE),
|
|
118
|
+
(-4, 5, 1.4, DISC_T + 13 * RISE),
|
|
119
|
+
(-5, 2, 1.4, DISC_T + 14 * RISE),
|
|
120
|
+
(-2, -1, 2.0, DISC_T + 15 * RISE), # summit disc
|
|
121
|
+
]
|
|
122
|
+
for i, (x, z, r, t) in enumerate(DISCS, start=1):
|
|
123
|
+
if i == 1:
|
|
124
|
+
disc(f"Pla{i}", x, z, r, t, RUST)
|
|
125
|
+
elif i == len(DISCS):
|
|
126
|
+
disc(f"Pla{i}", x, z, r, t, EMBER, emit=True)
|
|
127
|
+
else:
|
|
128
|
+
disc(f"Pla{i}", x, z, r, t, GUNMETAL)
|
|
129
|
+
|
|
130
|
+
# ---------------------------------------------------------------- Horrors of the walls & floor
|
|
131
|
+
|
|
132
|
+
def attach_sway(obj):
|
|
133
|
+
obj.attach(str(SCRIPT_DIR / "sway.py"), engine.context)
|
|
134
|
+
return obj
|
|
135
|
+
|
|
136
|
+
# Blood trails down the back wall.
|
|
137
|
+
for x, h in ((-12.4, 2.6), (-12.0, 1.5), (-11.6, 0.8), (6.1, 2.0), (5.7, 1.1)):
|
|
138
|
+
deco(vector3d(x, h / 2, -18.92), vector3d(0.08, h, 0.06), Color.RGB(66, 9, 11))
|
|
139
|
+
|
|
140
|
+
# Rust blooms on the side walls.
|
|
141
|
+
deco(vector3d(-23.88, 11.0, -6), vector3d(0.1, 3.4, 2.6), Color.RGB(48, 31, 22))
|
|
142
|
+
deco(vector3d(23.88, 6.0, 8), vector3d(0.1, 4.2, 1.4), Color.RGB(52, 34, 24))
|
|
143
|
+
|
|
144
|
+
# Wall vents.
|
|
145
|
+
deco(vector3d(-23.86, 9.0, 5), vector3d(0.12, 1.4, 1.6), Color.RGB(34, 36, 42))
|
|
146
|
+
for sy in (8.6, 9.0, 9.4):
|
|
147
|
+
deco(vector3d(-23.78, sy, 5), vector3d(0.14, 0.05, 1.2), Color.RGB(18, 19, 23))
|
|
148
|
+
deco(vector3d(23.86, 12.0, -7), vector3d(0.12, 1.2, 1.5), Color.RGB(34, 36, 42))
|
|
149
|
+
for sy in (11.6, 12.0, 12.4):
|
|
150
|
+
deco(vector3d(23.78, sy, -7), vector3d(0.14, 0.05, 1.1), Color.RGB(18, 19, 23))
|
|
151
|
+
|
|
152
|
+
# Faint hazard strips along the four void edges (glow faintly in the dark).
|
|
153
|
+
deco(vector3d(0, 0.01, -half_void_z + 0.06), vector3d(2 * half_void_x - 0.6, 0.02, 0.14), Color.RGB(120, 42, 8), emit=True)
|
|
154
|
+
deco(vector3d(0, 0.01, half_void_z - 0.06), vector3d(2 * half_void_x - 0.6, 0.02, 0.14), Color.RGB(120, 42, 8), emit=True)
|
|
155
|
+
deco(vector3d(-half_void_x + 0.06, 0.01, 0), vector3d(0.14, 0.02, 2 * half_void_z - 0.6), Color.RGB(120, 42, 8), emit=True)
|
|
156
|
+
deco(vector3d(half_void_x - 0.06, 0.01, 0), vector3d(0.14, 0.02, 2 * half_void_z - 0.6), Color.RGB(120, 42, 8), emit=True)
|
|
157
|
+
|
|
158
|
+
# Wet, glistening patches on the rim floor.
|
|
159
|
+
for px, pz, sx, sz in ((-21.5, -11.0, 1.4, 2.2), (21.0, 13.0, 1.1, 1.9), (-6.0, -16.5, 1.7, 1.2), (10.0, 16.5, 1.3, 1.6)):
|
|
160
|
+
deco(vector3d(px, 0.02, pz), vector3d(sx, 0.02, sz), Color.RGB(7, 10, 14))
|
|
161
|
+
|
|
162
|
+
# Dead monoliths in the four corners.
|
|
163
|
+
for mx, mz, mh in (-21.8, -16.8, 7.0), (21.8, -16.8, 8.0), (-21.8, 16.8, 6.4), (21.8, 16.8, 7.0):
|
|
164
|
+
deco(vector3d(mx, mh / 2, mz), vector3d(1.0, mh, 1.0), Color.RGB(11, 12, 16))
|
|
165
|
+
|
|
166
|
+
# Hanging cables and lamps, slow-swaying.
|
|
167
|
+
for hx, hz, bottom, radius, color, lamp in (
|
|
168
|
+
(-16.0, 10.0, 19.0, 0.05, Color.RGB(24, 26, 30), True),
|
|
169
|
+
(12.0, 14.0, 16.0, 0.05, Color.RGB(24, 26, 30), True),
|
|
170
|
+
(18.0, -15.0, 18.0, 0.04, Color.RGB(20, 22, 26), False),
|
|
171
|
+
(-18.0, 16.0, 17.0, 0.04, Color.RGB(20, 22, 26), False),
|
|
172
|
+
):
|
|
173
|
+
engine.add_object(attach_sway(Cylinder(
|
|
174
|
+
pos=vector3d(hx, (bottom + HEIGHT) / 2, hz),
|
|
175
|
+
length=HEIGHT - bottom,
|
|
176
|
+
radius=radius,
|
|
177
|
+
color=color,
|
|
178
|
+
name=f"Cable{int(hx)}_{int(hz)}",
|
|
179
|
+
)))
|
|
180
|
+
if lamp:
|
|
181
|
+
attach_sway(deco(vector3d(hx, bottom - 0.4, hz), vector3d(0.5, 0.4, 0.5), Color.RGB(30, 32, 36)))
|
|
182
|
+
|
|
183
|
+
# ---------------------------------------------------------------- Coins
|
|
184
|
+
|
|
185
|
+
coin_positions = [(DISCS[i - 1][0], DISCS[i - 1][3] + 0.95, DISCS[i - 1][1]) for i in (2, 4, 6, 8, 10, 12, 14, 16)]
|
|
186
|
+
|
|
187
|
+
for i, pos in enumerate(coin_positions):
|
|
188
|
+
coin = Sphere(
|
|
189
|
+
pos=vector3d(*pos),
|
|
190
|
+
radius=0.16,
|
|
191
|
+
color=Color.RGB(255, 205, 80),
|
|
192
|
+
emit=True,
|
|
193
|
+
name=f"Coin{i}",
|
|
194
|
+
)
|
|
195
|
+
coin.shadow_caster = False
|
|
196
|
+
coin.attach(str(SCRIPT_DIR / "coin.py"), engine.context)
|
|
197
|
+
engine.add_object(coin)
|
|
198
|
+
|
|
199
|
+
# ---------------------------------------------------------------- A broken light rig
|
|
200
|
+
|
|
201
|
+
def light(position, color, intensity, name):
|
|
202
|
+
l = Light(position=position, color=color, intensity=intensity, show=False, name=name)
|
|
203
|
+
engine.add_light(l)
|
|
204
|
+
l.shadow_caster = False
|
|
205
|
+
|
|
206
|
+
# Main ceiling lamp: strobes, stutters, occasionally dies.
|
|
207
|
+
light(vector3d(0, 25, 0), Color.RGB(205, 220, 245), 1.0, "Main")
|
|
208
|
+
# A weak constant gloom so the arena never goes fully blind.
|
|
209
|
+
light(vector3d(0, 18, 4), Color.RGB(170, 195, 230), 0.28, "ColdGloom")
|
|
210
|
+
# Red lamp above the rusted start disc.
|
|
211
|
+
light(vector3d(DISCS[0][0], DISCS[0][3] + 4.5, DISCS[0][1]), Color.RGB(255, 60, 40), 0.9, "StartLamp")
|
|
212
|
+
# Warm failing lamps on the hanging cables.
|
|
213
|
+
light(vector3d(-16.0, 18.2, 10.0), Color.RGB(255, 150, 60), 0.9, "LampA")
|
|
214
|
+
light(vector3d(12.0, 15.4, 14.0), Color.RGB(255, 170, 70), 0.8, "LampB")
|
|
215
|
+
# Coloured glows around the course.
|
|
216
|
+
light(vector3d(-12, 7, 4), Color.RGB(255, 120, 150), 0.5, "GlowPink")
|
|
217
|
+
light(vector3d(11, 10, -2), Color.RGB(150, 255, 90), 0.5, "GlowLime")
|
|
218
|
+
light(vector3d(2, 13, 11), Color.RGB(120, 180, 255), 0.5, "GlowBlue")
|
|
219
|
+
light(vector3d(-2, 15, -9), Color.RGB(255, 220, 90), 0.5, "GlowYellow")
|
|
220
|
+
# Deep in the pit: things that breathe.
|
|
221
|
+
light(vector3d(0, -10, 0), Color.RGB(255, 40, 200), 0.5, "VoidMagenta")
|
|
222
|
+
light(vector3d(-8, -18, 8), Color.RGB(255, 120, 0), 0.4, "VoidAmber")
|
|
223
|
+
light(vector3d(8, -22, -8), Color.RGB(0, 255, 210), 0.4, "VoidTeal")
|
|
224
|
+
light(vector3d(0, -26, 12), Color.RGB(90, 0, 25), 0.35, "VoidCrimson")
|
|
225
|
+
# The summit eye.
|
|
226
|
+
light(vector3d(DISCS[-1][0], DISCS[-1][3] + 2.6, DISCS[-1][1]), Color.RGB(255, 30, 25), 0.8, "Summit")
|
|
227
|
+
|
|
228
|
+
engine.attach(str(SCRIPT_DIR / "horror_atmosphere.py"))
|
|
229
|
+
|
|
230
|
+
# A small beating red eye above the summit disc.
|
|
231
|
+
eye = Sphere(
|
|
232
|
+
pos=vector3d(DISCS[-1][0], DISCS[-1][3] + 0.8, DISCS[-1][1]),
|
|
233
|
+
radius=0.22,
|
|
234
|
+
color=Color.RGB(255, 40, 30),
|
|
235
|
+
emit=True,
|
|
236
|
+
name="SummitEye",
|
|
237
|
+
)
|
|
238
|
+
eye.shadow_caster = False
|
|
239
|
+
engine.add_object(eye)
|
|
240
|
+
|
|
241
|
+
# ---------------------------------------------------------------- HUD
|
|
242
|
+
|
|
243
|
+
score_hud = Text(
|
|
244
|
+
pos=vector3d(0, 4.6, -ROOM_Z / 2 + 0.18),
|
|
245
|
+
text="coins:0_of_8",
|
|
246
|
+
color=Color.RGB(235, 190, 70),
|
|
247
|
+
scale=vector3d(0.6),
|
|
248
|
+
spacing=0.12,
|
|
249
|
+
rotation=vector3d(90, 0, 0),
|
|
250
|
+
center=True,
|
|
251
|
+
emit=True,
|
|
252
|
+
name="Hud_Score",
|
|
253
|
+
)
|
|
254
|
+
engine.add_object(score_hud)
|
|
255
|
+
|
|
256
|
+
engine.add_object(Text(
|
|
257
|
+
pos=vector3d(0, 3.4, -ROOM_Z / 2 + 0.18),
|
|
258
|
+
text="run:shift.light:f.its_watching",
|
|
259
|
+
color=Color.RGB(120, 125, 135),
|
|
260
|
+
scale=vector3d(0.3),
|
|
261
|
+
spacing=0.12,
|
|
262
|
+
rotation=vector3d(90, 0, 0),
|
|
263
|
+
center=True,
|
|
264
|
+
name="Hud_Help",
|
|
265
|
+
))
|
|
266
|
+
|
|
267
|
+
# ---------------------------------------------------------------- Player
|
|
268
|
+
|
|
269
|
+
start = DISCS[0]
|
|
270
|
+
player = Cuboid(
|
|
271
|
+
name="Player",
|
|
272
|
+
color=Color.RGB(255, 60, 60),
|
|
273
|
+
size=vector3d(0.5, 1.8, 0.5),
|
|
274
|
+
pos=vector3d(start[0], start[3] + 0.9, start[1]),
|
|
275
|
+
visible=False,
|
|
276
|
+
)
|
|
277
|
+
player.attach(str(SCRIPT_DIR / "player_controller.py"), engine.context)
|
|
278
|
+
player.attach(str(SCRIPT_DIR / "void_guard.py"), engine.context)
|
|
279
|
+
engine.add_object(player)
|
|
280
|
+
|
|
281
|
+
engine.camera.move_to(vector3d(start[0] + 5, start[3] + 4, start[1]))
|
|
282
|
+
engine.camera.look_at(vector3d(0, 12, 0))
|
|
283
|
+
engine.context.set_mouse_look(True)
|
|
284
|
+
|
|
285
|
+
engine.run(dynamic_view=False)
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from gamengine3d import Engine, Cuboid, Sphere, Text, Light, Color, vector3d
|
|
3
|
+
|
|
4
|
+
# ---------------------------------------------------------------- Engine
|
|
5
|
+
|
|
6
|
+
engine = Engine(
|
|
7
|
+
1280, 800,
|
|
8
|
+
background_color=Color.RGB(8, 10, 14),
|
|
9
|
+
ambient_light=0.16,
|
|
10
|
+
name="Player Movement 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 = 18.0
|
|
19
|
+
HALF = ROOM / 2
|
|
20
|
+
HEIGHT = 5.0
|
|
21
|
+
FLOOR_TOP = 0.05
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def solid(name, pos, size, color):
|
|
25
|
+
obj = Cuboid(pos=pos, size=size, color=color, name=f"Solid_{name}")
|
|
26
|
+
engine.add_object(obj)
|
|
27
|
+
return obj
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# ---------------------------------------------------------------- Room
|
|
31
|
+
|
|
32
|
+
solid("Floor", vector3d(0, -0.45, 0), vector3d(ROOM, 1, ROOM), Color.RGB(46, 48, 58))
|
|
33
|
+
ceiling = solid("Ceiling", vector3d(0, HEIGHT + 0.45, 0), vector3d(ROOM, 1, ROOM), Color.RGB(26, 28, 36))
|
|
34
|
+
ceiling.shadow_caster = False
|
|
35
|
+
solid("Wall_Left", vector3d(-HALF, 2.5, 0), vector3d(0.2, HEIGHT, ROOM), Color.RGB(94, 68, 54))
|
|
36
|
+
solid("Wall_Right", vector3d(HALF, 2.5, 0), vector3d(0.2, HEIGHT, ROOM), Color.RGB(94, 68, 54))
|
|
37
|
+
solid("Wall_Back", vector3d(0, 2.5, -HALF), vector3d(ROOM, HEIGHT, 0.2), Color.RGB(34, 62, 68))
|
|
38
|
+
solid("Wall_Front", vector3d(0, 2.5, HALF), vector3d(ROOM, HEIGHT, 0.2), Color.RGB(56, 42, 66))
|
|
39
|
+
|
|
40
|
+
# Corner pillars
|
|
41
|
+
for px in (-5.5, 5.5):
|
|
42
|
+
for pz in (-5.5, 5.5):
|
|
43
|
+
solid(f"Pillar_{px:g}_{pz:g}", vector3d(px, 2.5, pz), vector3d(0.8, 4.6, 0.8), Color.RGB(70, 74, 92))
|
|
44
|
+
|
|
45
|
+
# Two tables (top slab + legs)
|
|
46
|
+
def add_table(cx, cz):
|
|
47
|
+
top_y = FLOOR_TOP + 0.6 + 0.075
|
|
48
|
+
solid(f"Table_{cx:g}_{cz:g}", vector3d(cx, top_y, cz), vector3d(2.8, 0.15, 1.4), Color.RGB(120, 80, 52))
|
|
49
|
+
for lx in (-1.2, 1.2):
|
|
50
|
+
for lz in (-0.55, 0.55):
|
|
51
|
+
solid(f"TableLeg_{cx:g}_{cz:g}_{lx:g}_{lz:g}", vector3d(cx + lx, FLOOR_TOP + 0.3, cz + lz), vector3d(0.12, 0.6, 0.12), Color.RGB(70, 50, 40))
|
|
52
|
+
|
|
53
|
+
add_table(-2.8, 2.8)
|
|
54
|
+
add_table(2.8, -2.8)
|
|
55
|
+
|
|
56
|
+
# Crate stacks
|
|
57
|
+
def add_crates(pos, size, count, colors):
|
|
58
|
+
y = FLOOR_TOP + size / 2
|
|
59
|
+
for i in range(count):
|
|
60
|
+
solid(f"Crate_{pos.x:g}_{pos.z:g}_{i}", vector3d(pos.x, y, pos.z), vector3d(size), colors[i % len(colors)])
|
|
61
|
+
y += size
|
|
62
|
+
|
|
63
|
+
add_crates(vector3d(-7.4, 0, -7.4), 1.0, 3, [Color.RGB(140, 96, 52), Color.RGB(150, 108, 56), Color.RGB(120, 60, 48)])
|
|
64
|
+
add_crates(vector3d(7.0, 0, 6.2), 0.85, 2, [Color.RGB(140, 96, 52), Color.RGB(120, 60, 48)])
|
|
65
|
+
|
|
66
|
+
# ---------------------------------------------------------------- Coins
|
|
67
|
+
|
|
68
|
+
coin_positions = [
|
|
69
|
+
vector3d(0, 1.1, 0),
|
|
70
|
+
vector3d(3.2, 1.2, 2.9),
|
|
71
|
+
vector3d(-2.9, 1.2, -3.3),
|
|
72
|
+
vector3d(5.5, 1.5, -5.5),
|
|
73
|
+
vector3d(-5.5, 1.3, 5.5),
|
|
74
|
+
vector3d(7.0, 2.4, 6.2),
|
|
75
|
+
vector3d(-7.4, 3.4, -7.4),
|
|
76
|
+
vector3d(1.8, 0.9, -7.0),
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
for i, pos in enumerate(coin_positions):
|
|
80
|
+
coin = Sphere(
|
|
81
|
+
pos=pos,
|
|
82
|
+
radius=0.16,
|
|
83
|
+
color=Color.RGB(255, 205, 80),
|
|
84
|
+
emit=True,
|
|
85
|
+
name=f"Coin{i}",
|
|
86
|
+
)
|
|
87
|
+
coin.shadow_caster = False
|
|
88
|
+
coin.attach(str(SCRIPT_DIR / "coin.py"), engine.context)
|
|
89
|
+
engine.add_object(coin)
|
|
90
|
+
|
|
91
|
+
# ---------------------------------------------------------------- Lights
|
|
92
|
+
|
|
93
|
+
engine.add_light(Light(
|
|
94
|
+
position=vector3d(0, 4.7, 0),
|
|
95
|
+
color=Color.RGB(255, 225, 180),
|
|
96
|
+
intensity=1.6,
|
|
97
|
+
show=True,
|
|
98
|
+
name="CeilingCenter",
|
|
99
|
+
))
|
|
100
|
+
blue_fill = Light(
|
|
101
|
+
position=vector3d(6, 4.7, 6),
|
|
102
|
+
color=Color.RGB(120, 190, 255),
|
|
103
|
+
intensity=1.1,
|
|
104
|
+
show=True,
|
|
105
|
+
name="CeilingBlue",
|
|
106
|
+
)
|
|
107
|
+
engine.add_light(blue_fill)
|
|
108
|
+
warm_fill = Light(
|
|
109
|
+
position=vector3d(-6, 4.7, 6),
|
|
110
|
+
color=Color.RGB(255, 190, 120),
|
|
111
|
+
intensity=1.1,
|
|
112
|
+
show=True,
|
|
113
|
+
name="CeilingWarm",
|
|
114
|
+
)
|
|
115
|
+
engine.add_light(warm_fill)
|
|
116
|
+
blue_fill.shadow_caster = False
|
|
117
|
+
warm_fill.shadow_caster = False
|
|
118
|
+
|
|
119
|
+
# ---------------------------------------------------------------- HUD
|
|
120
|
+
|
|
121
|
+
score_hud = Text(
|
|
122
|
+
pos=vector3d(0, 3.2, -HALF + 0.18),
|
|
123
|
+
text="coins:0_of_8",
|
|
124
|
+
color=Color.RGB(255, 205, 80),
|
|
125
|
+
scale=vector3d(0.55),
|
|
126
|
+
spacing=0.12,
|
|
127
|
+
rotation=vector3d(90, 0, 0),
|
|
128
|
+
center=True,
|
|
129
|
+
emit=True,
|
|
130
|
+
name="Hud_Score",
|
|
131
|
+
)
|
|
132
|
+
engine.add_object(score_hud)
|
|
133
|
+
|
|
134
|
+
engine.add_object(Text(
|
|
135
|
+
pos=vector3d(0, 1.55, -HALF + 0.18),
|
|
136
|
+
text="move:w_a_s_d,jump:space,sprint:shift,light:f,mouse:m,esc:release",
|
|
137
|
+
color=Color.RGB(185, 195, 205),
|
|
138
|
+
scale=vector3d(0.28),
|
|
139
|
+
spacing=0.12,
|
|
140
|
+
rotation=vector3d(90, 0, 0),
|
|
141
|
+
center=True,
|
|
142
|
+
name="Hud_Help",
|
|
143
|
+
))
|
|
144
|
+
|
|
145
|
+
# ---------------------------------------------------------------- Player
|
|
146
|
+
|
|
147
|
+
player = Cuboid(
|
|
148
|
+
name="Player",
|
|
149
|
+
color=Color.RGB(255, 60, 60),
|
|
150
|
+
size=vector3d(0.5, 1.8, 0.5),
|
|
151
|
+
pos=vector3d(0, FLOOR_TOP + 0.9, 6.2),
|
|
152
|
+
visible=False,
|
|
153
|
+
)
|
|
154
|
+
player.attach(str(SCRIPT_DIR / "player_controller.py"), engine.context)
|
|
155
|
+
engine.add_object(player)
|
|
156
|
+
|
|
157
|
+
engine.camera.move_to(vector3d(0, 1.65, 6.2))
|
|
158
|
+
engine.camera.look_at(vector3d(0, 1, -3))
|
|
159
|
+
engine.context.set_mouse_look(True)
|
|
160
|
+
|
|
161
|
+
engine.run(dynamic_view=False)
|