PyScene 1.1.2__tar.gz → 1.1.4__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.
Files changed (30) hide show
  1. {pyscene-1.1.2 → pyscene-1.1.4}/PKG-INFO +11 -2
  2. {pyscene-1.1.2 → pyscene-1.1.4}/README.md +9 -1
  3. {pyscene-1.1.2 → pyscene-1.1.4}/pyproject.toml +3 -2
  4. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/Game.py +15 -2
  5. pyscene-1.1.4/src/PyScene/objs/GameObj.py +46 -0
  6. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/objs/Text.py +25 -4
  7. pyscene-1.1.2/src/PyScene/objs/GameObj.py +0 -24
  8. {pyscene-1.1.2 → pyscene-1.1.4}/.gitignore +0 -0
  9. {pyscene-1.1.2 → pyscene-1.1.4}/LICENSE +0 -0
  10. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/Collisions.py +0 -0
  11. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/Keys.py +0 -0
  12. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/Math.py +0 -0
  13. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/Net.py +0 -0
  14. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/__init__.py +0 -0
  15. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/__main__.py +0 -0
  16. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/objs/Collision_shapes.py +0 -0
  17. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/objs/Shapes.py +0 -0
  18. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/objs/Tilemap.py +0 -0
  19. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/objs/Timer.py +0 -0
  20. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/objs/__init__.py +0 -0
  21. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/objs/animation.py +0 -0
  22. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/tools/manager_gui.py +0 -0
  23. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/utils/Assets.py +0 -0
  24. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/utils/Subscreen.py +0 -0
  25. {pyscene-1.1.2 → pyscene-1.1.4}/src/PyScene/utils/__init__.py +0 -0
  26. {pyscene-1.1.2 → pyscene-1.1.4}/test.py +0 -0
  27. {pyscene-1.1.2 → pyscene-1.1.4}/tests/flappy_bird.py +0 -0
  28. {pyscene-1.1.2 → pyscene-1.1.4}/tests/pause.png +0 -0
  29. {pyscene-1.1.2 → pyscene-1.1.4}/tests/testColl.py +0 -0
  30. {pyscene-1.1.2 → pyscene-1.1.4}/tests/tileset.png +0 -0
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: PyScene
3
- Version: 1.1.2
3
+ Version: 1.1.4
4
4
  Summary: A python and pygame Game Engine
5
5
  Project-URL: Homepage, https://github.com/sfertig/PyScene
6
6
  Project-URL: Issues, https://github.com/sfertig/PyScene/issues
7
+ Project-URL: GUI-editor, https://github.com/sfertig/PyScene-Studio
7
8
  Author-email: Sam Fertig <sfertig007@gmail.com>
8
9
  License-Expression: MIT
9
10
  License-File: LICENSE
@@ -16,8 +17,16 @@ Description-Content-Type: text/markdown
16
17
 
17
18
  PyScene is a custom python + pygame framework / engine developed to streamline 2d game development.
18
19
  This is not a pygame wrapper, as it goed beyons the basic helper features and dives into a mini engine / framework.
20
+ There is also a GUI editor being developed alongside PyScene that can be veiwed at: https://github.com/sfertig/PyScene-Studio
19
21
 
20
22
  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.
21
23
 
22
- PyScene is in developement and API's may change offten, a fully stable version should come with v2.0.0, currently on v1.1.2
24
+ PyScene is in developement and API's may change offten, a fully stable version should come with v2.0.0, currently on v1.1.4
23
25
 
26
+ Getting Started Basics:
27
+
28
+ 1. Use Game.init(...)
29
+ 2. Create custom Game Objects by inheriting GameObj
30
+ 3. Create a Scene by inheriting Scene
31
+ 4. Use Game.Run(...) #pass in True to have escape close the window
32
+ Not: remenber to use super().__init__(...) is any inherited scene or Game object
@@ -2,8 +2,16 @@
2
2
 
3
3
  PyScene is a custom python + pygame framework / engine developed to streamline 2d game development.
4
4
  This is not a pygame wrapper, as it goed beyons the basic helper features and dives into a mini engine / framework.
5
+ There is also a GUI editor being developed alongside PyScene that can be veiwed at: https://github.com/sfertig/PyScene-Studio
5
6
 
6
7
  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.
7
8
 
8
- PyScene is in developement and API's may change offten, a fully stable version should come with v2.0.0, currently on v1.1.2
9
+ PyScene is in developement and API's may change offten, a fully stable version should come with v2.0.0, currently on v1.1.4
9
10
 
11
+ Getting Started Basics:
12
+
13
+ 1. Use Game.init(...)
14
+ 2. Create custom Game Objects by inheriting GameObj
15
+ 3. Create a Scene by inheriting Scene
16
+ 4. Use Game.Run(...) #pass in True to have escape close the window
17
+ Not: remenber to use super().__init__(...) is any inherited scene or Game object
@@ -3,7 +3,7 @@ requires = ["hatchling >= 1.26"]
3
3
  build-backend = "hatchling.build"
4
4
  [project]
5
5
  name = "PyScene"
6
- version = "1.1.2"
6
+ version = "1.1.4"
7
7
  authors = [
8
8
  { name="Sam Fertig", email="sfertig007@gmail.com" },
9
9
  ]
@@ -19,4 +19,5 @@ license-files = ["LICEN[CS]E*"]
19
19
 
20
20
  [project.urls]
21
21
  Homepage = "https://github.com/sfertig/PyScene"
22
- Issues = "https://github.com/sfertig/PyScene/issues"
22
+ Issues = "https://github.com/sfertig/PyScene/issues"
23
+ GUI-editor = "https://github.com/sfertig/PyScene-Studio"
@@ -72,7 +72,7 @@ class _game:
72
72
  if self.active_scene is None: self.queue_creation.append(obj)
73
73
  else: self.active_scene._queue_add(obj)
74
74
  def _queue_remove(self, obj):
75
- if obj in self.objects: self.objects.remove(obj)
75
+ if obj in self.objects: self.queue_del.remove(obj)
76
76
  else: self.active_scene._queue_remove(obj)
77
77
  def _get_id(self):
78
78
  self.id += 1
@@ -190,7 +190,20 @@ class _game:
190
190
  self.queue_creation_coll = []
191
191
  self.queue_del_coll = []
192
192
  self._update_coll = False
193
-
193
+ def clear_global_objs(self):
194
+ self.objects = []
195
+ self.queue_creation = []
196
+ self.queue_del = []
197
+ self.render_queue = []
198
+ def clear_scene_objs(self):
199
+ if self.active_scene is not None:
200
+ self.active_scene._objects = []
201
+ self.active_scene.queue_creation = []
202
+ self.active_scene.queue_del = []
203
+ self.active_scene._render_queue = []
204
+ def clear_all_objs(self):
205
+ self.clear_global_objs()
206
+ self.clear_scene_objs()
194
207
  def _set_scene(self, scene=None):
195
208
  if self.active_scene is not None: self.active_scene.destroy()
196
209
  self._clear_all_collisions_()
@@ -0,0 +1,46 @@
1
+ import pygame
2
+ from ..Math import Vector2D
3
+ from ..Game import Game
4
+
5
+ class GameObj: #this will be the base class of every game obj
6
+ def __init__(self, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, Global=False):
7
+ self.pos: Vector2D = pos
8
+ self.vel: Vector2D = Vector2D(0, 0)
9
+ self.z_index = z_index
10
+ self.active = active
11
+ self.visible = visible
12
+ self._id = Game._get_id()
13
+
14
+ self.__parent: GameObj = None
15
+ self.__children: list[GameObj] = []
16
+
17
+ #add to creation
18
+ if Game.always_global: Global = True
19
+ if not Global: Game._queue_add(self)
20
+ else: Game.queue_creation.append(self) #if obj is just global anyway
21
+
22
+ self._global = Global
23
+
24
+ def child(self, obj): #obj is a game object
25
+ self.__children.append(obj)
26
+ obj.parent(self)
27
+ return obj #QOF
28
+
29
+ def parent(self, obj):
30
+ # If we already have a parent, remove ourselves from its list first
31
+ if self.__parent and self in self.__parent.__children:
32
+ self.__parent.__children.remove(self)
33
+ self.__parent = obj
34
+
35
+ def update(self): pass
36
+ def render(self): pass
37
+ def destroy(self):
38
+ Game._queue_remove(self)
39
+ for i in self.__children:
40
+ i.destroy()
41
+
42
+ if self.__parent: self.__parent.__children.remove(self)
43
+
44
+ self.__children = []
45
+ self.__parent = None
46
+
@@ -18,9 +18,28 @@ class Text(GameObj):
18
18
 
19
19
  def _update_surface(self):
20
20
  """Internal method to re-render surface only when text changes."""
21
- self.surface = self.font.render(str(self.text), False, self.color) # False for sharp pixel fonts!
22
- # Dynamically set rect based on alignment (topleft, center, topright, etc.)
23
- self.rect = self.surface.get_rect(**{self.align: self.pos.to_int()})
21
+ self.surface = self.font.render(str(self.text), False, self.color)
22
+ self._apply_alignment()
23
+
24
+ def _apply_alignment(self):
25
+ """Safely positions the rect based on single or multi-coordinate alignment."""
26
+ xy = self.pos.to_int() # Assuming this returns (x, y)
27
+
28
+ # Group single-coordinate attributes by which axis they care about
29
+ x_aligns = {"left", "right", "centerx", "x"}
30
+ y_aligns = {"top", "bottom", "centery", "y"}
31
+
32
+ if self.align in x_aligns:
33
+ # Create a default rect at (0,0), then assign the specific X coordinate
34
+ self.rect = self.surface.get_rect()
35
+ setattr(self.rect, self.align, xy[0])
36
+ elif self.align in y_aligns:
37
+ # Create a default rect at (0,0), then assign the specific Y coordinate
38
+ self.rect = self.surface.get_rect()
39
+ setattr(self.rect, self.align, xy[1])
40
+ else:
41
+ # Multi-coordinate alignments (center, topleft, etc.) safely accept the full tuple
42
+ self.rect = self.surface.get_rect(**{self.align: xy})
24
43
 
25
44
  def set_text(self, new_text, color=None):
26
45
  """Only call this when the string actually changes!"""
@@ -32,13 +51,15 @@ class Text(GameObj):
32
51
 
33
52
  def set_pos(self, new_pos: Vector2D):
34
53
  self.pos = new_pos
35
- self.rect = self.surface.get_rect(**{self.align: self.pos.to_int()})
54
+ self._apply_alignment()
36
55
 
37
56
  def render(self):
38
57
  Game.cam.draw_text(self.surface, self.rect, self.offset)
58
+
39
59
  def render_to(self, surface):
40
60
  surface.blit(self.surface, self.rect)
41
61
 
62
+
42
63
  class Image(GameObj):
43
64
  def __init__(self, image, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, offset=True, Global=False):
44
65
  super().__init__(pos, z_index, active, visible, Global)
@@ -1,24 +0,0 @@
1
- import pygame
2
- from ..Math import Vector2D
3
- from ..Game import Game
4
-
5
- class GameObj: #this will be the base class of every game obj
6
- def __init__(self, pos=Vector2D(0, 0), z_index=0, active=True, visible=True, Global=False):
7
- self.pos: Vector2D = pos
8
- self.vel: Vector2D = Vector2D(0, 0)
9
- self.z_index = z_index
10
- self.active = active
11
- self.visible = visible
12
- self._id = Game._get_id()
13
-
14
- #add to creation
15
- if Game.always_global: Global = True
16
- if not Global: Game._queue_add(self)
17
- else: Game.queue_creation.append(self) #if obj is just global anyway
18
-
19
- self._global = Global
20
-
21
- def update(self): pass
22
- def render(self): pass
23
- def destroy(self): Game._queue_remove(self)
24
-
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