VertexEngine 0.1.1__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.
- VertexEngine/__init__.py +33 -0
- VertexEngine/assets.py +17 -0
- VertexEngine/audio.py +25 -0
- VertexEngine/engine.py +68 -0
- VertexEngine/example.py +59 -0
- VertexEngine/scenes.py +28 -0
- vertexengine-0.1.1.dist-info/METADATA +10 -0
- vertexengine-0.1.1.dist-info/RECORD +10 -0
- vertexengine-0.1.1.dist-info/WHEEL +5 -0
- vertexengine-0.1.1.dist-info/top_level.txt +1 -0
VertexEngine/__init__.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# pyqtpygame_sdk/__init__.py
|
|
2
|
+
# Copyright (C) 2025
|
|
3
|
+
# This library/SDK is free. You can redistribute it.
|
|
4
|
+
# Tyrel Gomez (email as annbasilan)
|
|
5
|
+
# annbasilan0828@gmail.com
|
|
6
|
+
"""Vertex 3 is an SDK for RainOS GameDev. It's also supported by many others.
|
|
7
|
+
|
|
8
|
+
Supported OSes
|
|
9
|
+
--------------
|
|
10
|
+
- RainOS
|
|
11
|
+
- Windows
|
|
12
|
+
- MacOS,
|
|
13
|
+
- OS X
|
|
14
|
+
- BeOS
|
|
15
|
+
- FreeBSD
|
|
16
|
+
- IRIX
|
|
17
|
+
- and Linux
|
|
18
|
+
|
|
19
|
+
It is written on top of the excellent Pygame library which is ran on the even more excellent SDL library which runs on every Desktop OS with SDL."""
|
|
20
|
+
import pygame
|
|
21
|
+
from .engine import GameEngine
|
|
22
|
+
from .scenes import Scene, SceneManager
|
|
23
|
+
from .assets import AssetManager
|
|
24
|
+
from .audio import AudioManager
|
|
25
|
+
from pygame.base import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
|
|
26
|
+
from pygame import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
|
|
27
|
+
import sys
|
|
28
|
+
|
|
29
|
+
print(
|
|
30
|
+
"Vertex 3 (SDL {}.{}.{}, Python {}.{}.{})".format( # pylint: disable=consider-using-f-string
|
|
31
|
+
ver, *get_sdl_version() + sys.version_info[0:3]
|
|
32
|
+
)
|
|
33
|
+
)
|
VertexEngine/assets.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from pygame import image
|
|
2
|
+
|
|
3
|
+
class AssetManager:
|
|
4
|
+
def __init__(self):
|
|
5
|
+
self.images = {}
|
|
6
|
+
|
|
7
|
+
def load_image(self, name, path):
|
|
8
|
+
try:
|
|
9
|
+
img = image.load(path) # no convert(), no convert_alpha()
|
|
10
|
+
self.images[name] = img
|
|
11
|
+
return img
|
|
12
|
+
except FileNotFoundError:
|
|
13
|
+
print(f"[Warning] Image '{path}' not found!")
|
|
14
|
+
return None
|
|
15
|
+
|
|
16
|
+
def get_image(self, name):
|
|
17
|
+
return self.images.get(name)
|
VertexEngine/audio.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import pygame
|
|
2
|
+
|
|
3
|
+
class AudioManager:
|
|
4
|
+
def __init__(self):
|
|
5
|
+
pygame.mixer.init()
|
|
6
|
+
self.sounds = {}
|
|
7
|
+
self.music = None
|
|
8
|
+
|
|
9
|
+
def load_sound(self, name, path):
|
|
10
|
+
self.sounds[name] = pygame.mixer.Sound(path)
|
|
11
|
+
|
|
12
|
+
def play_sound(self, name, loops=0):
|
|
13
|
+
if name in self.sounds:
|
|
14
|
+
self.sounds[name].play(loops=loops)
|
|
15
|
+
|
|
16
|
+
def load_music(self, path):
|
|
17
|
+
self.music = path
|
|
18
|
+
pygame.mixer.music.load(path)
|
|
19
|
+
|
|
20
|
+
def play_music(self, loops=-1):
|
|
21
|
+
if self.music:
|
|
22
|
+
pygame.mixer.music.play(loops=loops)
|
|
23
|
+
|
|
24
|
+
def stop_music(self):
|
|
25
|
+
pygame.mixer.music.stop()
|
VertexEngine/engine.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from PyQt6.QtWidgets import QWidget
|
|
2
|
+
from PyQt6.QtGui import QImage, QPainter
|
|
3
|
+
from PyQt6.QtCore import QTimer, Qt
|
|
4
|
+
import pygame
|
|
5
|
+
from Vertex3.scenes import SceneManager
|
|
6
|
+
|
|
7
|
+
pygame.init()
|
|
8
|
+
|
|
9
|
+
class GameEngine(QWidget):
|
|
10
|
+
def __init__(self, width=800, height=600, fps=60, title="Vertex App"):
|
|
11
|
+
super().__init__()
|
|
12
|
+
self.width = width
|
|
13
|
+
self.height = height
|
|
14
|
+
self.fps = fps
|
|
15
|
+
|
|
16
|
+
# Qt key tracking (NOT pygame)
|
|
17
|
+
self.keys_down = set()
|
|
18
|
+
|
|
19
|
+
# pygame surface
|
|
20
|
+
self.screen = pygame.Surface((self.width, self.height))
|
|
21
|
+
|
|
22
|
+
# Scene manager
|
|
23
|
+
self.scene_manager = SceneManager()
|
|
24
|
+
|
|
25
|
+
# Timer
|
|
26
|
+
self.timer = QTimer()
|
|
27
|
+
self.timer.timeout.connect(self.update_frame)
|
|
28
|
+
self.timer.start(1000 // self.fps)
|
|
29
|
+
|
|
30
|
+
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
|
31
|
+
|
|
32
|
+
# ---------------------- RENDER ----------------------
|
|
33
|
+
|
|
34
|
+
def paintEvent(self, event):
|
|
35
|
+
self.screen.fill((50, 50, 100))
|
|
36
|
+
self.scene_manager.draw(self.screen)
|
|
37
|
+
|
|
38
|
+
raw = pygame.image.tostring(self.screen, "RGBA")
|
|
39
|
+
img = QImage(raw, self.width, self.height, QImage.Format.Format_RGBA8888)
|
|
40
|
+
|
|
41
|
+
painter = QPainter(self)
|
|
42
|
+
painter.drawImage(0, 0, img)
|
|
43
|
+
|
|
44
|
+
def resizeEvent(self, event):
|
|
45
|
+
size = event.size()
|
|
46
|
+
self.width = size.width()
|
|
47
|
+
self.height = size.height()
|
|
48
|
+
self.screen = pygame.Surface((self.width, self.height))
|
|
49
|
+
|
|
50
|
+
# ---------------------- UPDATE ----------------------
|
|
51
|
+
|
|
52
|
+
def update_frame(self):
|
|
53
|
+
if not self.hasFocus():
|
|
54
|
+
self.keys_down.clear() # prevent stuck movement
|
|
55
|
+
|
|
56
|
+
if self.scene_manager.current_scene:
|
|
57
|
+
self.scene_manager.current_scene.update()
|
|
58
|
+
|
|
59
|
+
self.update()
|
|
60
|
+
|
|
61
|
+
# ---------------------- KEY INPUT ----------------------
|
|
62
|
+
|
|
63
|
+
def keyPressEvent(self, event):
|
|
64
|
+
self.keys_down.add(event.key())
|
|
65
|
+
|
|
66
|
+
def keyReleaseEvent(self, event):
|
|
67
|
+
if event.key() in self.keys_down:
|
|
68
|
+
self.keys_down.remove(event.key())
|
VertexEngine/example.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from PyQt6.QtWidgets import QApplication
|
|
2
|
+
from engine import GameEngine
|
|
3
|
+
import pygame
|
|
4
|
+
from scenes import Scene
|
|
5
|
+
from assets import AssetManager
|
|
6
|
+
from audio import AudioManager
|
|
7
|
+
import sys
|
|
8
|
+
class MyScene(Scene):
|
|
9
|
+
def __init__(self, engine):
|
|
10
|
+
super().__init__(engine)
|
|
11
|
+
self.assets = AssetManager()
|
|
12
|
+
self.assets.load_image("ball", "ball.png")
|
|
13
|
+
self.x = 100
|
|
14
|
+
self.y = 100
|
|
15
|
+
self.speed = 5
|
|
16
|
+
self.width = engine.width
|
|
17
|
+
self.height = engine.height
|
|
18
|
+
|
|
19
|
+
def update(self):
|
|
20
|
+
# Process pygame events
|
|
21
|
+
for event in pygame.event.get():
|
|
22
|
+
if event.type == pygame.KEYDOWN:
|
|
23
|
+
if event.key == pygame.K_LEFT:
|
|
24
|
+
self.x -= self.speed
|
|
25
|
+
elif event.key == pygame.K_RIGHT:
|
|
26
|
+
self.x += self.speed
|
|
27
|
+
elif event.key == pygame.K_UP:
|
|
28
|
+
self.y -= self.speed
|
|
29
|
+
elif event.key == pygame.K_DOWN:
|
|
30
|
+
self.y += self.speed
|
|
31
|
+
|
|
32
|
+
# Clamp the ball inside the engine window
|
|
33
|
+
self.x = max(0, min(self.x, self.width - 50))
|
|
34
|
+
self.y = max(0, min(self.y, self.height - 50))
|
|
35
|
+
|
|
36
|
+
def draw(self, surface):
|
|
37
|
+
surface.fill((0, 0, 0)) # clear screen
|
|
38
|
+
ball = self.assets.get_image("ball")
|
|
39
|
+
if ball:
|
|
40
|
+
ball_scaled = pygame.transform.scale(ball, (55, 50))
|
|
41
|
+
surface.blit(ball_scaled, (self.x, self.y))
|
|
42
|
+
else:
|
|
43
|
+
pygame.draw.circle(surface, (255, 0, 0), (self.x, self.y), 25)
|
|
44
|
+
|
|
45
|
+
app = QApplication(sys.argv) # ✅ must be first
|
|
46
|
+
|
|
47
|
+
engine = GameEngine()
|
|
48
|
+
engine.resize(800, 600)
|
|
49
|
+
|
|
50
|
+
# Create scene and add to manager
|
|
51
|
+
my_scene = MyScene(engine)
|
|
52
|
+
engine.scene_manager.add_scene("main", my_scene)
|
|
53
|
+
engine.scene_manager.switch_to("main") # make it the active scene
|
|
54
|
+
|
|
55
|
+
# Show the engine
|
|
56
|
+
engine.show()
|
|
57
|
+
|
|
58
|
+
# Start the PyQt6 event loop
|
|
59
|
+
sys.exit(app.exec())
|
VertexEngine/scenes.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class Scene:
|
|
2
|
+
def __init__(self, engine):
|
|
3
|
+
self.engine = engine
|
|
4
|
+
|
|
5
|
+
def update(self):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
def draw(self, surface):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
class SceneManager:
|
|
12
|
+
def __init__(self):
|
|
13
|
+
self.scenes = {}
|
|
14
|
+
self.current_scene = None
|
|
15
|
+
|
|
16
|
+
def add_scene(self, name, scene):
|
|
17
|
+
self.scenes[name] = scene
|
|
18
|
+
|
|
19
|
+
def switch_to(self, name):
|
|
20
|
+
self.current_scene = self.scenes.get(name)
|
|
21
|
+
|
|
22
|
+
def update(self):
|
|
23
|
+
if self.current_scene:
|
|
24
|
+
self.current_scene.update()
|
|
25
|
+
|
|
26
|
+
def draw(self, surface):
|
|
27
|
+
if self.current_scene:
|
|
28
|
+
self.current_scene.draw(surface)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: VertexEngine
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A Library made to make Pygame Apps in PyQt6 windows (They can be embedded since they are technically PyQt6 Windows)
|
|
5
|
+
Author-email: Tyrel Miguel <annbasilan0828@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: pygame>=2.0
|
|
10
|
+
Requires-Dist: PyQt6>=6.7
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
VertexEngine/__init__.py,sha256=RgHX8DTzq6PlFZd2Z_2c09V6a8NuXN9O7HmDFYJjMo0,1038
|
|
2
|
+
VertexEngine/assets.py,sha256=xLn1mgjOuzNGNuvfR4Jn4Rtr-MoEmd65KrUguBlmebk,479
|
|
3
|
+
VertexEngine/audio.py,sha256=c4gKT15lRlA1d9xSjUiDUssg0chDyZ867kQzm0KMFyA,644
|
|
4
|
+
VertexEngine/engine.py,sha256=NKZ8q5JprKtL-Qf5yvfpVsO4bHQHpxZtsvAw8HlhNZ0,2050
|
|
5
|
+
VertexEngine/example.py,sha256=BGf4u0OMDJCvcXq8hcP1fx42LMqxlEXI2qy5V_bDK3U,1921
|
|
6
|
+
VertexEngine/scenes.py,sha256=yzVMZO9IhfxaK6v5-Nab-3KieAitahpKfDqzB0oNm10,641
|
|
7
|
+
vertexengine-0.1.1.dist-info/METADATA,sha256=8Cn3YwPCUMMGpMv_GznycsJpksJafKODKMpOvBzrftk,375
|
|
8
|
+
vertexengine-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
vertexengine-0.1.1.dist-info/top_level.txt,sha256=ONNMJUQViY7bNuEYPB2TaUwj7Jo1Is2yuBY4KOv19wM,13
|
|
10
|
+
vertexengine-0.1.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VertexEngine
|