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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import random
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
from gamengine3d import vector3d
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Sway:
|
|
9
|
+
"""Slow pendulum sway for hanging cables and lamps."""
|
|
10
|
+
|
|
11
|
+
def __init__(self, obj, context):
|
|
12
|
+
self.obj = obj
|
|
13
|
+
self.base = vector3d(obj.pos.x, obj.pos.y, obj.pos.z)
|
|
14
|
+
self.phase = random.uniform(0.0, math.tau)
|
|
15
|
+
|
|
16
|
+
def update(self, dt):
|
|
17
|
+
t = time.time() + self.phase
|
|
18
|
+
self.obj.pos.x = self.base.x + math.sin(t * 0.9) * 0.04
|
|
19
|
+
self.obj.pos.z = self.base.z + math.cos(t * 0.7 + 1.2) * 0.04
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from gamengine3d import vector3d
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class VoidGuard:
|
|
5
|
+
"""Respawns the player if they fall into the dark pit below the start block."""
|
|
6
|
+
|
|
7
|
+
RESPAWN_DEPTH = 0.35
|
|
8
|
+
|
|
9
|
+
def __init__(self, obj, context):
|
|
10
|
+
self.obj = obj
|
|
11
|
+
self.start = vector3d(obj.pos.x, obj.pos.y, obj.pos.z)
|
|
12
|
+
|
|
13
|
+
self.controller = None
|
|
14
|
+
for script in obj.scripts:
|
|
15
|
+
inst = script.instance
|
|
16
|
+
if inst is not None and type(inst).__name__ == "PlayerController":
|
|
17
|
+
self.controller = inst
|
|
18
|
+
|
|
19
|
+
def update(self, dt):
|
|
20
|
+
start_feet = self.start.y - self.obj.size.y / 2
|
|
21
|
+
if self.obj.pos.y - self.obj.size.y / 2 < start_feet - self.RESPAWN_DEPTH:
|
|
22
|
+
self.obj.pos.x = self.start.x
|
|
23
|
+
self.obj.pos.y = self.start.y
|
|
24
|
+
self.obj.pos.z = self.start.z
|
|
25
|
+
if self.controller is not None:
|
|
26
|
+
self.controller.velocity = vector3d.zero
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from gamengine3d import Engine, Cuboid, Cylinder, Sphere, Text, Light, Color, vector3d
|
|
4
|
+
|
|
5
|
+
# Transparency showcase.
|
|
6
|
+
#
|
|
7
|
+
# Every GameObject takes `transparency` — a float from 0.0 (fully invisible)
|
|
8
|
+
# to 1.0 (opaque, the default). Transparent objects are drawn back-to-front
|
|
9
|
+
# and alpha-blended over the opaque scene, so glass surfaces really reveal
|
|
10
|
+
# what is behind them. The pulsing ghost objects below show that
|
|
11
|
+
# transparency can also be changed live, every frame, from a script.
|
|
12
|
+
|
|
13
|
+
engine = Engine(
|
|
14
|
+
900, 620,
|
|
15
|
+
background_color=Color.RGB(16, 18, 26),
|
|
16
|
+
ambient_light=0.32,
|
|
17
|
+
name="Transparency Demo",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
EXAMPLE_DIR = Path(__file__).parent
|
|
21
|
+
SCRIPT_DIR = EXAMPLE_DIR / "scripts"
|
|
22
|
+
|
|
23
|
+
FLOOR = Color.RGB(38, 42, 52)
|
|
24
|
+
WALL = Color.RGB(26, 30, 40)
|
|
25
|
+
BACKDROP = [Color.RGB(255, 120, 60), Color.RGB(70, 190, 255), Color.RGB(140, 230, 120)]
|
|
26
|
+
GLASS = Color.RGB(150, 210, 255)
|
|
27
|
+
CORE = Color.RGB(255, 240, 190)
|
|
28
|
+
|
|
29
|
+
# ---------------------------------------------------------------- scene
|
|
30
|
+
floor = Cuboid(pos=vector3d(0, -1.6, 0), size=vector3d(26, 1.2, 26), color=FLOOR, name="Floor")
|
|
31
|
+
engine.add_object(floor)
|
|
32
|
+
wall = Cuboid(pos=vector3d(0, 2, -7), size=vector3d(26, 8, 0.6), color=WALL, name="Wall")
|
|
33
|
+
engine.add_object(wall)
|
|
34
|
+
|
|
35
|
+
# Opaque backdrop — the things you can see *through* the glass
|
|
36
|
+
for i, c in enumerate(BACKDROP):
|
|
37
|
+
engine.add_object(Sphere(
|
|
38
|
+
pos=vector3d(-2.2 + 2.2 * i, 0.4, -4.4),
|
|
39
|
+
radius=1.1,
|
|
40
|
+
color=c,
|
|
41
|
+
name=f"OpaqueBehind{i}",
|
|
42
|
+
))
|
|
43
|
+
engine.add_object(Cuboid(pos=vector3d(0, -0.3, -4.4), size=vector3d(2.4, 0.5, 0.5), color=Color.RGB(255, 255, 255), name="OpaquePlate"))
|
|
44
|
+
|
|
45
|
+
# A glass box, holding a transparent sphere + cylinder and an opaque core
|
|
46
|
+
glass = Cuboid(
|
|
47
|
+
pos=vector3d(0, 0.5, 0), size=vector3d(4.6, 3.2, 4.6), color=GLASS,
|
|
48
|
+
name="GlassBox", transparency=0.22,
|
|
49
|
+
)
|
|
50
|
+
engine.add_object(glass)
|
|
51
|
+
|
|
52
|
+
engine.add_object(Sphere(
|
|
53
|
+
pos=vector3d(-0.9, 0.4, 0.6), radius=0.95, color=Color.RGB(255, 110, 160),
|
|
54
|
+
name="GlassSphere", transparency=0.55,
|
|
55
|
+
))
|
|
56
|
+
engine.add_object(Cylinder(
|
|
57
|
+
pos=vector3d(1.0, 0.3, -0.5), length=1.9, radius=0.62, color=Color.RGB(110, 255, 130),
|
|
58
|
+
name="GlassCylinder", transparency=0.72,
|
|
59
|
+
))
|
|
60
|
+
# Fully opaque inside the glass box — crisply visible through the walls
|
|
61
|
+
engine.add_object(Cuboid(
|
|
62
|
+
pos=vector3d(-0.1, -0.6, -0.2), size=vector3d(0.9, 0.9, 0.9),
|
|
63
|
+
color=CORE, name="SolidCore",
|
|
64
|
+
))
|
|
65
|
+
|
|
66
|
+
# Glass text, next to the box
|
|
67
|
+
ghost_text = Text(
|
|
68
|
+
pos=vector3d(4.2, 2.6, 1.5), text="FADE", scale=vector3d(0.65),
|
|
69
|
+
color=Color.RGB(255, 255, 150), name="GhostText", center=True, transparency=0.45,
|
|
70
|
+
rotation=vector3d(90, 0, 0),
|
|
71
|
+
)
|
|
72
|
+
engine.add_object(ghost_text)
|
|
73
|
+
|
|
74
|
+
# A floating translucent orb that pulses between translucent and almost gone
|
|
75
|
+
orb = Sphere(
|
|
76
|
+
pos=vector3d(-4.2, 2.4, 1.2), radius=0.7,
|
|
77
|
+
color=Color.RGB(200, 130, 255), name="GhostOrb", transparency=0.5,
|
|
78
|
+
)
|
|
79
|
+
engine.add_object(orb)
|
|
80
|
+
|
|
81
|
+
# ---------------------------------------------------------------- lights
|
|
82
|
+
engine.add_light(Light(position=vector3d(0, 7, 3), color=Color.RGB(255, 240, 220), intensity=1.4, name="Key"))
|
|
83
|
+
engine.add_light(Light(position=vector3d(-5, 4, 5), color=Color.RGB(140, 180, 255), intensity=0.55, name="Cool"))
|
|
84
|
+
engine.add_light(Light(position=vector3d(5, 3, 4), color=Color.RGB(255, 170, 110), intensity=0.4, name="Warm"))
|
|
85
|
+
|
|
86
|
+
# ---------------------------------------------------------------- live transparency
|
|
87
|
+
engine.context.pulse_targets = ["GlassBox", "GhostText", "GhostOrb"]
|
|
88
|
+
engine.attach(str(SCRIPT_DIR / "ghost_pulse.py"))
|
|
89
|
+
|
|
90
|
+
engine.camera.move_to(vector3d(0, 2.4, 9))
|
|
91
|
+
engine.camera.look_at(vector3d(0, 0.4, 0))
|
|
92
|
+
engine.run(dynamic_view=True)
|