gamengine3d 1.7.0__tar.gz → 1.8.1__tar.gz
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-1.7.0 → gamengine3d-1.8.1}/PKG-INFO +3 -1
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/README.md +2 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/context.py +13 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/engine.py +29 -1
- gamengine3d-1.8.1/gamengine3d/examples/messages_demo.py +22 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/examples/player_movement.py +0 -1
- gamengine3d-1.8.1/gamengine3d/examples/scripts/message_receiver.py +12 -0
- gamengine3d-1.8.1/gamengine3d/examples/scripts/messanger_script.py +10 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/examples/the_everything_demo.py +0 -2
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/game_objects.py +9 -1
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/helper.py +10 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d.egg-info/PKG-INFO +3 -1
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d.egg-info/SOURCES.txt +3 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/pyproject.toml +1 -1
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/LICENSE.txt +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/__init__.py +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/cli.py +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/examples/__init__.py +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/examples/basics.py +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/examples/scripts/cylinder.py +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/examples/scripts/player_movement.py +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/examples/scripts/settings.py +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/shaders/__init__.py +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/shaders/default.frag +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/shaders/default.vert +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/shaders/depth.frag +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d/shaders/depth.vert +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d.egg-info/dependency_links.txt +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d.egg-info/entry_points.txt +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d.egg-info/requires.txt +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/gamengine3d.egg-info/top_level.txt +0 -0
- {gamengine3d-1.7.0 → gamengine3d-1.8.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gamengine3d
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.1
|
|
4
4
|
Summary: A Unity-like 3D engine in Python using pygame
|
|
5
5
|
Author-email: Samarth Javagal <samarthjavagal@gmail.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -78,3 +78,5 @@ This minimal PlayerController shows how to attach a script to an object and resp
|
|
|
78
78
|
You can run any built-in demo with ``gamengine3d demo <demo_name>`` and see all available options using ``gamengine3d demo -h``.
|
|
79
79
|
|
|
80
80
|
The 2d version of ```gamengine3d``` is out under ``gamengine2d``
|
|
81
|
+
|
|
82
|
+
Check out the full documentation for this package here: [Package Docs](https://sites.google.com/view/samarthsprojects/python-packages/gamengine3d)
|
|
@@ -60,3 +60,5 @@ This minimal PlayerController shows how to attach a script to an object and resp
|
|
|
60
60
|
You can run any built-in demo with ``gamengine3d demo <demo_name>`` and see all available options using ``gamengine3d demo -h``.
|
|
61
61
|
|
|
62
62
|
The 2d version of ```gamengine3d``` is out under ``gamengine2d``
|
|
63
|
+
|
|
64
|
+
Check out the full documentation for this package here: [Package Docs](https://sites.google.com/view/samarthsprojects/python-packages/gamengine3d)
|
|
@@ -6,6 +6,8 @@ import importlib
|
|
|
6
6
|
|
|
7
7
|
class Functions:
|
|
8
8
|
def __init__(self):
|
|
9
|
+
self.save_scene = lambda filename: None
|
|
10
|
+
self.load_scene = lambda filename: None
|
|
9
11
|
self.draw_cube = lambda pos=vector3d.zero, size=vector3d(3), color=Color.light_blue: None
|
|
10
12
|
self.draw_sphere = lambda pos=vector3d.zero, radius=2, color=Color.light_red, segments=32, rings=16: None
|
|
11
13
|
self.draw_cylinder = lambda pos=vector3d.zero, length=2, radius=.5, color=Color.light_yellow, segments=32: None
|
|
@@ -147,6 +149,7 @@ class Context:
|
|
|
147
149
|
self.scheduled_callers: list[ScheduledCaller] = []
|
|
148
150
|
self.runtime_vars = RuntimeVars()
|
|
149
151
|
self.exit = False
|
|
152
|
+
self.current_caller = None
|
|
150
153
|
|
|
151
154
|
def on_key_press(self, key, callback, args=None, dt=False):
|
|
152
155
|
if args is None:
|
|
@@ -210,3 +213,13 @@ class Context:
|
|
|
210
213
|
max_id = max([caller.caller_id for caller in self.scheduled_callers])
|
|
211
214
|
caller_id = max_id + 1
|
|
212
215
|
self.scheduled_callers.append(ScheduledCaller(n_times, callback, delay, caller_id))
|
|
216
|
+
|
|
217
|
+
def push_caller(self, gameobject):
|
|
218
|
+
self.current_caller = gameobject
|
|
219
|
+
|
|
220
|
+
def clear_caller(self):
|
|
221
|
+
self.current_caller = None
|
|
222
|
+
|
|
223
|
+
def send_message(self, target_name, message):
|
|
224
|
+
target = self.functions.get_game_object(target_name)
|
|
225
|
+
target.message(message=message, sender=self.current_caller.name)
|
|
@@ -15,6 +15,7 @@ class Engine:
|
|
|
15
15
|
self.window_name = name
|
|
16
16
|
self.background_color = background_color
|
|
17
17
|
self.scripts = []
|
|
18
|
+
self.script_paths = []
|
|
18
19
|
|
|
19
20
|
flags = pygame.DOUBLEBUF | pygame.OPENGL
|
|
20
21
|
if self.resizable:
|
|
@@ -48,6 +49,8 @@ class Engine:
|
|
|
48
49
|
self.context.functions.remove_light = self.remove_light
|
|
49
50
|
self.context.functions.remove_object = self.remove_object
|
|
50
51
|
self.context.functions.is_colliding_pos = self.is_colliding_pos
|
|
52
|
+
self.context.functions.save_scene = self.save_scene
|
|
53
|
+
self.context.functions.load_scene = self.load_scene
|
|
51
54
|
|
|
52
55
|
self.context.game_objects = self.gameobjects
|
|
53
56
|
self.context.engine = self
|
|
@@ -139,6 +142,7 @@ class Engine:
|
|
|
139
142
|
script.update(dt)
|
|
140
143
|
|
|
141
144
|
for obj in self.gameobjects:
|
|
145
|
+
self.context.push_caller(obj)
|
|
142
146
|
obj.update(dt)
|
|
143
147
|
obj.draw(self.renderer)
|
|
144
148
|
|
|
@@ -257,8 +261,13 @@ class Engine:
|
|
|
257
261
|
def attach(self, path):
|
|
258
262
|
script = Script(self, path, self.context)
|
|
259
263
|
script.init_instance()
|
|
264
|
+
self.script_paths.append(path)
|
|
260
265
|
self.scripts.append(script)
|
|
261
266
|
|
|
267
|
+
def attach_scripts(self, scripts):
|
|
268
|
+
for path in scripts:
|
|
269
|
+
self.attach(path)
|
|
270
|
+
|
|
262
271
|
def init_scripts(self):
|
|
263
272
|
for script in self.scripts:
|
|
264
273
|
script.init_instance()
|
|
@@ -273,7 +282,7 @@ class Engine:
|
|
|
273
282
|
all_lights.append(light.serialize())
|
|
274
283
|
|
|
275
284
|
with open(filename, "w") as f:
|
|
276
|
-
json.dump({"game-objects": all_gameobjects, "lights": all_lights}, f, indent=4)
|
|
285
|
+
json.dump({"game-objects": all_gameobjects, "lights": all_lights, "engine": self.serialize()}, f, indent=4)
|
|
277
286
|
|
|
278
287
|
def load_scene(self, filename):
|
|
279
288
|
with open(filename, "r") as f:
|
|
@@ -296,3 +305,22 @@ class Engine:
|
|
|
296
305
|
elif gameobject["type"] == "cylinder":
|
|
297
306
|
obj = Cylinder.deserialize(gameobject, self.context)
|
|
298
307
|
self.add_object(obj)
|
|
308
|
+
|
|
309
|
+
engine = data["engine"]
|
|
310
|
+
self.deserialize(engine)
|
|
311
|
+
|
|
312
|
+
def serialize(self):
|
|
313
|
+
return {
|
|
314
|
+
"ambient_light": self.renderer.ambient,
|
|
315
|
+
"background_color": self.background_color.to_rgb(),
|
|
316
|
+
"scripts": self.script_paths,
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
def deserialize(self, data):
|
|
320
|
+
ambient_light = data["ambient_light"]
|
|
321
|
+
background_color = data["background_color"]
|
|
322
|
+
scripts = data["scripts"]
|
|
323
|
+
|
|
324
|
+
self.renderer.ambient = ambient_light
|
|
325
|
+
self.background_color = Color.RGB(*background_color)
|
|
326
|
+
self.attach_scripts(scripts)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from gamengine3d import Engine, Cuboid, vector3d, Light, Color
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
EXAMPLE_DIR = Path(__file__).parent
|
|
5
|
+
messanger_script = EXAMPLE_DIR / "scripts" / "messanger_script.py"
|
|
6
|
+
receiver_script = EXAMPLE_DIR / "scripts" / "message_receiver.py"
|
|
7
|
+
|
|
8
|
+
engine = Engine(1200, 800, name="Messages Demo")
|
|
9
|
+
|
|
10
|
+
cuboid = Cuboid(name="Cuboid1")
|
|
11
|
+
cuboid.attach(messanger_script, engine.context)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
cuboid2 = Cuboid(name="Cuboid2", pos=vector3d(6, 3, 6), color=Color.light_blue)
|
|
15
|
+
cuboid2.attach(receiver_script, engine.context)
|
|
16
|
+
engine.add_object(cuboid2)
|
|
17
|
+
|
|
18
|
+
engine.add_light(Light(position=vector3d(0, 5, .0001), color=Color.white))
|
|
19
|
+
|
|
20
|
+
engine.add_object(cuboid)
|
|
21
|
+
|
|
22
|
+
engine.run()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from gamengine3d import Cuboid, Context
|
|
2
|
+
|
|
3
|
+
class MessageReceiver:
|
|
4
|
+
def __init__(self, obj: Cuboid, context: Context):
|
|
5
|
+
self.obj = obj
|
|
6
|
+
self.context = context
|
|
7
|
+
|
|
8
|
+
def update(self, dt):
|
|
9
|
+
if self.obj.received_message:
|
|
10
|
+
print("Message Received!")
|
|
11
|
+
print(self.obj.messages[-1])
|
|
12
|
+
print("-"*10)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from gamengine3d import Cuboid, Context
|
|
2
|
+
|
|
3
|
+
class MessangerScript:
|
|
4
|
+
def __init__(self, obj: Cuboid, context: Context):
|
|
5
|
+
self.obj = obj
|
|
6
|
+
self.context = context
|
|
7
|
+
|
|
8
|
+
def update(self, dt):
|
|
9
|
+
if "space" in self.context.keys_held:
|
|
10
|
+
self.context.send_message("Cuboid2", "The Space Bar has been pressed!")
|
|
@@ -3,18 +3,22 @@ from itertools import product
|
|
|
3
3
|
from pyrr import Matrix44
|
|
4
4
|
import math
|
|
5
5
|
|
|
6
|
-
from .helper import Color, vector3d, Renderer, Script
|
|
6
|
+
from .helper import Color, vector3d, Renderer, Script, Message
|
|
7
7
|
|
|
8
8
|
class GameObject:
|
|
9
9
|
def __init__(self, name):
|
|
10
10
|
self.name = name
|
|
11
11
|
self.scripts = []
|
|
12
12
|
self.script_paths = []
|
|
13
|
+
self.messages = []
|
|
14
|
+
self.received_message = False
|
|
13
15
|
|
|
14
16
|
def update(self, dt):
|
|
15
17
|
for script in self.scripts:
|
|
16
18
|
script.update(dt)
|
|
17
19
|
|
|
20
|
+
self.received_message = False
|
|
21
|
+
|
|
18
22
|
def draw(self, renderer: Renderer):
|
|
19
23
|
pass
|
|
20
24
|
|
|
@@ -35,6 +39,10 @@ class GameObject:
|
|
|
35
39
|
for script in self.scripts:
|
|
36
40
|
script.init_instance()
|
|
37
41
|
|
|
42
|
+
def message(self, message, sender):
|
|
43
|
+
self.messages.append(Message(message=message, sender=sender))
|
|
44
|
+
self.received_message = True
|
|
45
|
+
|
|
38
46
|
class Cuboid(GameObject):
|
|
39
47
|
def __init__(self, pos: vector3d = vector3d.zero,
|
|
40
48
|
size: vector3d = vector3d(5),
|
|
@@ -8,6 +8,7 @@ import importlib.resources as pkg_resources
|
|
|
8
8
|
import numpy as np
|
|
9
9
|
from pyrr import Matrix44
|
|
10
10
|
import os
|
|
11
|
+
import time
|
|
11
12
|
|
|
12
13
|
class classproperty(property):
|
|
13
14
|
def __get__(self, cls, owner):
|
|
@@ -728,3 +729,12 @@ class Script:
|
|
|
728
729
|
|
|
729
730
|
class EngineError(Exception):
|
|
730
731
|
pass
|
|
732
|
+
|
|
733
|
+
class Message:
|
|
734
|
+
def __init__(self, message, sender):
|
|
735
|
+
self.message = message
|
|
736
|
+
self.sender = sender
|
|
737
|
+
self.time = time.time()
|
|
738
|
+
|
|
739
|
+
def __repr__(self):
|
|
740
|
+
return f"Message({self.message=}, {self.sender=}, {self.time=})"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gamengine3d
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.1
|
|
4
4
|
Summary: A Unity-like 3D engine in Python using pygame
|
|
5
5
|
Author-email: Samarth Javagal <samarthjavagal@gmail.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -78,3 +78,5 @@ This minimal PlayerController shows how to attach a script to an object and resp
|
|
|
78
78
|
You can run any built-in demo with ``gamengine3d demo <demo_name>`` and see all available options using ``gamengine3d demo -h``.
|
|
79
79
|
|
|
80
80
|
The 2d version of ```gamengine3d``` is out under ``gamengine2d``
|
|
81
|
+
|
|
82
|
+
Check out the full documentation for this package here: [Package Docs](https://sites.google.com/view/samarthsprojects/python-packages/gamengine3d)
|
|
@@ -15,9 +15,12 @@ gamengine3d.egg-info/requires.txt
|
|
|
15
15
|
gamengine3d.egg-info/top_level.txt
|
|
16
16
|
gamengine3d/examples/__init__.py
|
|
17
17
|
gamengine3d/examples/basics.py
|
|
18
|
+
gamengine3d/examples/messages_demo.py
|
|
18
19
|
gamengine3d/examples/player_movement.py
|
|
19
20
|
gamengine3d/examples/the_everything_demo.py
|
|
20
21
|
gamengine3d/examples/scripts/cylinder.py
|
|
22
|
+
gamengine3d/examples/scripts/message_receiver.py
|
|
23
|
+
gamengine3d/examples/scripts/messanger_script.py
|
|
21
24
|
gamengine3d/examples/scripts/player_movement.py
|
|
22
25
|
gamengine3d/examples/scripts/settings.py
|
|
23
26
|
gamengine3d/shaders/__init__.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|