PyScene 1.0.5__tar.gz → 1.0.6__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.
- {pyscene-1.0.5 → pyscene-1.0.6}/PKG-INFO +3 -1
- {pyscene-1.0.5 → pyscene-1.0.6}/README.md +2 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/pyproject.toml +1 -1
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/Game.py +11 -11
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/__init__.py +1 -1
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/objs/GameObj.py +1 -1
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/objs/Shapes.py +12 -12
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/objs/Text.py +8 -8
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/objs/animation.py +8 -8
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/utils/Assets.py +4 -4
- {pyscene-1.0.5/tests → pyscene-1.0.6}/test.py +11 -2
- {pyscene-1.0.5 → pyscene-1.0.6}/.gitignore +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/LICENSE +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/Collisions.py +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/Keys.py +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/Math.py +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/Net.py +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/objs/Collision_shapes.py +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/objs/__init__.py +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/utils/Subscreen.py +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/src/PyScene/utils/__init__.py +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/tests/flappy_bird.py +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/tests/pause.png +0 -0
- {pyscene-1.0.5 → pyscene-1.0.6}/tests/testColl.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: PyScene
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.6
|
|
4
4
|
Summary: A small example package
|
|
5
5
|
Project-URL: Homepage, https://github.com/sfertig/PyScene
|
|
6
6
|
Project-URL: Issues, https://github.com/sfertig/PyScene/issues
|
|
@@ -18,3 +18,5 @@ PyScene is a custom python + pygame framework / engine developed to streamline 2
|
|
|
18
18
|
|
|
19
19
|
Please Note: This engine is still in development and many features, like tilemaps and audio, are a work in progress. It also lack any form of documentation, I ask for patience as docs will be rolled out once the core features are more solidified.
|
|
20
20
|
|
|
21
|
+
PyScene is in developement and API's may change offten, a fully stable version should come with v2.0.0, currently on v1.0.6
|
|
22
|
+
|
|
@@ -4,3 +4,5 @@ PyScene is a custom python + pygame framework / engine developed to streamline 2
|
|
|
4
4
|
|
|
5
5
|
Please Note: This engine is still in development and many features, like tilemaps and audio, are a work in progress. It also lack any form of documentation, I ask for patience as docs will be rolled out once the core features are more solidified.
|
|
6
6
|
|
|
7
|
+
PyScene is in developement and API's may change offten, a fully stable version should come with v2.0.0, currently on v1.0.6
|
|
8
|
+
|
|
@@ -134,11 +134,11 @@ class _game:
|
|
|
134
134
|
if _clear: self.screen.fill(self.bg)
|
|
135
135
|
#render call
|
|
136
136
|
if self.active_scene is None:
|
|
137
|
-
for obj in self.render_queue: obj.render(
|
|
137
|
+
for obj in self.render_queue: obj.render()
|
|
138
138
|
#render scene
|
|
139
139
|
else:
|
|
140
|
-
self.active_scene.render(
|
|
141
|
-
self.active_scene._render(
|
|
140
|
+
self.active_scene.render()
|
|
141
|
+
self.active_scene._render()
|
|
142
142
|
if self.show_collisions: self.__render_collisions()
|
|
143
143
|
#update screen
|
|
144
144
|
pygame.display.flip()
|
|
@@ -179,11 +179,11 @@ class _game:
|
|
|
179
179
|
self.queue_del_coll = []
|
|
180
180
|
self._update_coll = False
|
|
181
181
|
|
|
182
|
-
def
|
|
182
|
+
def _set_scene(self, scene=None):
|
|
183
183
|
if self.active_scene is not None: self.active_scene.destroy()
|
|
184
184
|
self._clear_all_collisions_()
|
|
185
|
-
self.active_scene =
|
|
186
|
-
if self.active_scene: self.active_scene.on_change()
|
|
185
|
+
self.active_scene = scene
|
|
186
|
+
#if self.active_scene: self.active_scene.on_change()
|
|
187
187
|
|
|
188
188
|
|
|
189
189
|
class Scene:
|
|
@@ -194,8 +194,8 @@ class Scene:
|
|
|
194
194
|
self._render_queue = []
|
|
195
195
|
self.queue_creation = []
|
|
196
196
|
self.queue_del = []
|
|
197
|
-
Game.scenes[name] = self.__class__
|
|
198
|
-
Game.
|
|
197
|
+
if name not in Game.scenes: Game.scenes[name] = self.__class__
|
|
198
|
+
Game._set_scene(self)
|
|
199
199
|
|
|
200
200
|
def on_change(self): pass
|
|
201
201
|
|
|
@@ -204,13 +204,13 @@ class Scene:
|
|
|
204
204
|
self.__handle_queue()
|
|
205
205
|
for obj in self._objects: obj.update()
|
|
206
206
|
|
|
207
|
-
def render(self
|
|
208
|
-
def _render(self
|
|
207
|
+
def render(self): pass #user defined
|
|
208
|
+
def _render(self): #built in method
|
|
209
209
|
#update render queue based on global objects
|
|
210
210
|
_length = len(self._objects)+len(Game.objects)
|
|
211
211
|
if _length != len(self._render_queue): self.__update_render_queue()
|
|
212
212
|
#render
|
|
213
|
-
for obj in self._render_queue: obj.render(
|
|
213
|
+
for obj in self._render_queue: obj.render()
|
|
214
214
|
|
|
215
215
|
def _queue_add(self, obj): self.queue_creation.append(obj)
|
|
216
216
|
def _queue_remove(self, obj): self.queue_del.append(obj)
|
|
@@ -16,6 +16,6 @@ class GameObj: #this will be the base class of every game obj
|
|
|
16
16
|
else: Game.queue_creation.append(self) #if obj is just global anyway
|
|
17
17
|
|
|
18
18
|
def update(self): pass
|
|
19
|
-
def render(self
|
|
19
|
+
def render(self): pass
|
|
20
20
|
def destroy(self): Game._queue_remove(self)
|
|
21
21
|
|
|
@@ -5,8 +5,8 @@ from ..Game import Game
|
|
|
5
5
|
from .GameObj import GameObj
|
|
6
6
|
|
|
7
7
|
class Rect(GameObj):
|
|
8
|
-
def __init__(self, x, y, w, h, color, z_index=0, width=0, active=True, visible=True, offset=True):
|
|
9
|
-
super().__init__(Vector2D(x, y), z_index, active, visible)
|
|
8
|
+
def __init__(self, x, y, w, h, color, z_index=0, width=0, active=True, visible=True, offset=True, Global=False):
|
|
9
|
+
super().__init__(Vector2D(x, y), z_index, active, visible, Global)
|
|
10
10
|
self.dim = Vector2D(w, h)
|
|
11
11
|
self.color = color
|
|
12
12
|
self.rect = pygame.Rect((x, y), (w, h))
|
|
@@ -16,30 +16,30 @@ class Rect(GameObj):
|
|
|
16
16
|
def update(self):
|
|
17
17
|
if self.pos.to_int() != self.rect.topleft: self.rect.topleft = self.pos.to_int()
|
|
18
18
|
|
|
19
|
-
def render(self
|
|
19
|
+
def render(self):
|
|
20
20
|
if not self.visible: return
|
|
21
|
-
cam.draw_rect(self.rect, self.color, self.width, self.offset)
|
|
21
|
+
Game.cam.draw_rect(self.rect, self.color, self.width, self.offset)
|
|
22
22
|
|
|
23
23
|
class Circle(GameObj):
|
|
24
|
-
def __init__(self, x, y, r, color, z_index=0, width=0, active=True, visible=True, offset=True):
|
|
25
|
-
super().__init__(Vector2D(x, y), z_index, active, visible)
|
|
24
|
+
def __init__(self, x, y, r, color, z_index=0, width=0, active=True, visible=True, offset=True, Global=False):
|
|
25
|
+
super().__init__(Vector2D(x, y), z_index, active, visible, Global)
|
|
26
26
|
self.radius = r
|
|
27
27
|
self.color = color
|
|
28
28
|
self.width = width
|
|
29
29
|
self.offset = offset
|
|
30
30
|
|
|
31
|
-
def render(self
|
|
31
|
+
def render(self):
|
|
32
32
|
if not self.visible: return
|
|
33
|
-
cam.draw_circle(self.pos, self.radius, self.color, self.width, self.offset)
|
|
33
|
+
Game.cam.draw_circle(self.pos, self.radius, self.color, self.width, self.offset)
|
|
34
34
|
|
|
35
35
|
class Line(GameObj):
|
|
36
|
-
def __init__(self, x1, y1, x2, y2, color, z_index=0, width=1, active=True, visible=True, offset=True):
|
|
37
|
-
super().__init__(Vector2D(x1, y1), z_index, active, visible)
|
|
36
|
+
def __init__(self, x1, y1, x2, y2, color, z_index=0, width=1, active=True, visible=True, offset=True, Global=False):
|
|
37
|
+
super().__init__(Vector2D(x1, y1), z_index, active, visible, Global)
|
|
38
38
|
self.end = Vector2D(x2, y2)
|
|
39
39
|
self.color = color
|
|
40
40
|
self.width = width
|
|
41
41
|
self.offset = offset
|
|
42
42
|
|
|
43
|
-
def render(self
|
|
43
|
+
def render(self):
|
|
44
44
|
if not self.visible: return
|
|
45
|
-
cam.draw_line(self.pos, self.end, self.color, self.width, self.offset)
|
|
45
|
+
Game.cam.draw_line(self.pos, self.end, self.color, self.width, self.offset)
|
|
@@ -4,8 +4,8 @@ from .GameObj import GameObj
|
|
|
4
4
|
import pygame
|
|
5
5
|
|
|
6
6
|
class Text(GameObj):
|
|
7
|
-
def __init__(self, font, text, color, pos=Vector2D(0, 0), align="center", z_index=0, active=True, visible=True, offset=True):
|
|
8
|
-
super().__init__(pos, z_index, active, visible)
|
|
7
|
+
def __init__(self, font, text, color, pos=Vector2D(0, 0), align="center", z_index=0, active=True, visible=True, offset=True, Global=False):
|
|
8
|
+
super().__init__(pos, z_index, active, visible, Global)
|
|
9
9
|
self.font = font
|
|
10
10
|
self.text = text
|
|
11
11
|
self.color = color
|
|
@@ -34,17 +34,17 @@ class Text(GameObj):
|
|
|
34
34
|
self.pos = new_pos
|
|
35
35
|
self.rect = self.surface.get_rect(**{self.align: self.pos})
|
|
36
36
|
|
|
37
|
-
def render(self
|
|
37
|
+
def render(self):
|
|
38
38
|
if not self.visible: return
|
|
39
|
-
cam.draw_text(self.surface, self.rect, self.offset)
|
|
39
|
+
Game.cam.draw_text(self.surface, self.rect, self.offset)
|
|
40
40
|
|
|
41
41
|
class Image(GameObj):
|
|
42
|
-
def __init__(self, image, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, offset=True):
|
|
43
|
-
super().__init__(pos, z_index, active, visible)
|
|
42
|
+
def __init__(self, image, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, offset=True, Global=False):
|
|
43
|
+
super().__init__(pos, z_index, active, visible, Global)
|
|
44
44
|
self.image = image
|
|
45
45
|
self.offset = offset
|
|
46
46
|
|
|
47
|
-
def render(self
|
|
47
|
+
def render(self):
|
|
48
48
|
if not self.visible: return
|
|
49
|
-
cam.draw_image(self.image, self.pos, self.offset)
|
|
49
|
+
Game.cam.draw_image(self.image, self.pos, self.offset)
|
|
50
50
|
|
|
@@ -5,8 +5,8 @@ from .GameObj import GameObj
|
|
|
5
5
|
from ..Game import Game
|
|
6
6
|
|
|
7
7
|
class Animation(GameObj):
|
|
8
|
-
def __init__(self, image, size, fps, loop=True, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, offset=True):
|
|
9
|
-
super().__init__(pos, z_index, active, visible)
|
|
8
|
+
def __init__(self, image, size, fps, loop=True, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, offset=True, Global=False):
|
|
9
|
+
super().__init__(pos, z_index, active, visible, Global)
|
|
10
10
|
self.offset = offset
|
|
11
11
|
self.image = image
|
|
12
12
|
self.size = size
|
|
@@ -64,13 +64,13 @@ class Animation(GameObj):
|
|
|
64
64
|
|
|
65
65
|
def copy(self):
|
|
66
66
|
return Animation(self.image, self.size, self.fps, self.loop)
|
|
67
|
-
def render(self
|
|
67
|
+
def render(self):
|
|
68
68
|
if not self.visible: return
|
|
69
|
-
cam.draw_image(self.get_image(), self.pos, self.offset)
|
|
69
|
+
Game.cam.draw_image(self.get_image(), self.pos, self.offset)
|
|
70
70
|
|
|
71
71
|
class AnimationManager(GameObj):
|
|
72
|
-
def __init__(self, animations: dict[str, Animation], current_anim=None, z_index=0, active=True, visible=True, offset=True):
|
|
73
|
-
super().__init__(Vector2D(0, 0), z_index, active, visible)
|
|
72
|
+
def __init__(self, animations: dict[str, Animation], current_anim=None, z_index=0, active=True, visible=True, offset=True, Global=False):
|
|
73
|
+
super().__init__(Vector2D(0, 0), z_index, active, visible, Global)
|
|
74
74
|
self.animations = animations
|
|
75
75
|
self.current_anim = current_anim
|
|
76
76
|
|
|
@@ -111,6 +111,6 @@ class AnimationManager(GameObj):
|
|
|
111
111
|
return
|
|
112
112
|
return self.animations[self.current_anim]
|
|
113
113
|
|
|
114
|
-
def render(self
|
|
114
|
+
def render(self):
|
|
115
115
|
if not self.visible: return
|
|
116
|
-
self.get_animation().render(
|
|
116
|
+
self.get_animation().render()
|
|
@@ -84,13 +84,13 @@ class _assets:
|
|
|
84
84
|
def new_font(self, name, path, size):
|
|
85
85
|
self.fonts[name] = pygame.font.Font(path, size)
|
|
86
86
|
|
|
87
|
-
def new_animation(self, name, image, size=16, fps=3, loop=True, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, offset=True):
|
|
88
|
-
self.animations[name] = Animation(image, size, fps, loop, pos, z_index, active, visible, offset)
|
|
89
|
-
def new_anim_nIMG(self, name, size=16, fps=3, path=None, rect=None, scale=1.0, colorKey=(0, 0, 0), sWidth=None, sHeight=None, loop=True, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, offset=True):
|
|
87
|
+
def new_animation(self, name, image, size=16, fps=3, loop=True, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, offset=True, Global=False):
|
|
88
|
+
self.animations[name] = Animation(image, size, fps, loop, pos, z_index, active, visible, offset, Global)
|
|
89
|
+
def new_anim_nIMG(self, name, size=16, fps=3, path=None, rect=None, scale=1.0, colorKey=(0, 0, 0), sWidth=None, sHeight=None, loop=True, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, offset=True, Global=False):
|
|
90
90
|
#create image
|
|
91
91
|
self.new_image(name, path, rect, scale, colorKey, sWidth, sHeight)
|
|
92
92
|
#create animation
|
|
93
|
-
self.new_animation(name, self.images[name], size*scale, fps, loop, pos, z_index, active, visible, offset)
|
|
93
|
+
self.new_animation(name, self.images[name], size*scale, fps, loop, pos, z_index, active, visible, offset, Global)
|
|
94
94
|
|
|
95
95
|
def new_sound(self, name, path):
|
|
96
96
|
self.sounds[name] = pygame.mixer.Sound(path)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from src import *
|
|
1
|
+
from src.PyScene import *
|
|
2
2
|
import pygame
|
|
3
3
|
|
|
4
4
|
|
|
@@ -15,7 +15,16 @@ class player(GameObj):
|
|
|
15
15
|
self.pos += (Keys.get_vector(Keys.a, Keys.d, Keys.w, Keys.s, False)*150)*Game.dt
|
|
16
16
|
self.anim.pos = self.pos #positions stay linked
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
class Test(Scene):
|
|
19
|
+
def __init__(self):
|
|
20
|
+
super().__init__("Test")
|
|
21
|
+
player()
|
|
22
|
+
|
|
23
|
+
Test()
|
|
24
|
+
|
|
25
|
+
Game.Tick()
|
|
26
|
+
print(Game.objects)
|
|
27
|
+
print(Game.active_scene._objects)
|
|
19
28
|
|
|
20
29
|
Game.Run()
|
|
21
30
|
|
|
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
|