PyScene 1.1.4__tar.gz → 1.1.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.
Files changed (30) hide show
  1. {pyscene-1.1.4 → pyscene-1.1.6}/PKG-INFO +2 -2
  2. {pyscene-1.1.4 → pyscene-1.1.6}/README.md +1 -1
  3. {pyscene-1.1.4 → pyscene-1.1.6}/pyproject.toml +1 -1
  4. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/Game.py +21 -12
  5. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/Keys.py +11 -0
  6. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/objs/GameObj.py +16 -11
  7. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/objs/Shapes.py +3 -3
  8. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/objs/Tilemap.py +1 -1
  9. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/objs/Timer.py +1 -2
  10. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/objs/animation.py +1 -1
  11. pyscene-1.1.6/test.py +7 -0
  12. pyscene-1.1.4/test.py +0 -28
  13. {pyscene-1.1.4 → pyscene-1.1.6}/.gitignore +0 -0
  14. {pyscene-1.1.4 → pyscene-1.1.6}/LICENSE +0 -0
  15. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/Collisions.py +0 -0
  16. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/Math.py +0 -0
  17. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/Net.py +0 -0
  18. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/__init__.py +0 -0
  19. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/__main__.py +0 -0
  20. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/objs/Collision_shapes.py +0 -0
  21. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/objs/Text.py +0 -0
  22. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/objs/__init__.py +0 -0
  23. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/tools/manager_gui.py +0 -0
  24. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/utils/Assets.py +0 -0
  25. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/utils/Subscreen.py +0 -0
  26. {pyscene-1.1.4 → pyscene-1.1.6}/src/PyScene/utils/__init__.py +0 -0
  27. {pyscene-1.1.4 → pyscene-1.1.6}/tests/flappy_bird.py +0 -0
  28. {pyscene-1.1.4 → pyscene-1.1.6}/tests/pause.png +0 -0
  29. {pyscene-1.1.4 → pyscene-1.1.6}/tests/testColl.py +0 -0
  30. {pyscene-1.1.4 → pyscene-1.1.6}/tests/tileset.png +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: PyScene
3
- Version: 1.1.4
3
+ Version: 1.1.6
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
@@ -21,7 +21,7 @@ There is also a GUI editor being developed alongside PyScene that can be veiwed
21
21
 
22
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.
23
23
 
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
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.6
25
25
 
26
26
  Getting Started Basics:
27
27
 
@@ -6,7 +6,7 @@ There is also a GUI editor being developed alongside PyScene that can be veiwed
6
6
 
7
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.
8
8
 
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
+ PyScene is in developement and API's may change offten, a fully stable version should come with v2.0.0, currently on v1.1.6
10
10
 
11
11
  Getting Started Basics:
12
12
 
@@ -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.4"
6
+ version = "1.1.6"
7
7
  authors = [
8
8
  { name="Sam Fertig", email="sfertig007@gmail.com" },
9
9
  ]
@@ -1,4 +1,5 @@
1
1
  import pygame
2
+ from pygame._sdl2 import Window
2
3
  import sys
3
4
  import os
4
5
 
@@ -12,7 +13,7 @@ class _game:
12
13
  pygame.init()
13
14
  pygame.font.init()
14
15
 
15
- def init(self, width, height, title, bg="black", fps=60, fullscreen=False):
16
+ def init(self, width, height, title, bg="black", fps=60, fullscreen=False, application=False, _no_dir=False):
16
17
  self.__on = True
17
18
  self.width = width
18
19
  self.height = height
@@ -30,8 +31,12 @@ class _game:
30
31
  self.optimize_static_colliders: bool = False
31
32
 
32
33
  #screen
33
- if not fullscreen: self.screen = pygame.display.set_mode((self.width, self.height))
34
- else: self.screen = pygame.display.set_mode((width, height), pygame.SCALED | pygame.FULLSCREEN)
34
+ if fullscreen: self.screen = pygame.display.set_mode((width, height), pygame.SCALED | pygame.FULLSCREEN)
35
+ elif application:
36
+ self.screen = pygame.display.set_mode((width, height), pygame.SCALED | pygame.RESIZABLE)
37
+ sdl2_window = Window.from_display_module()
38
+ sdl2_window.maximize()
39
+ else: self.screen = pygame.display.set_mode((self.width, self.height))
35
40
  pygame.display.set_caption(self.title)
36
41
 
37
42
  Keys._add_net(self) #to accsess events
@@ -60,7 +65,7 @@ class _game:
60
65
  #other flags
61
66
  self.always_global = False
62
67
 
63
- self.__check_dir_files()
68
+ if not _no_dir: self.__check_dir_files()
64
69
 
65
70
  def __check_dir_files(self): #check and create dir and files
66
71
  if os.path.exists(".pyscene"): return
@@ -72,7 +77,7 @@ class _game:
72
77
  if self.active_scene is None: self.queue_creation.append(obj)
73
78
  else: self.active_scene._queue_add(obj)
74
79
  def _queue_remove(self, obj):
75
- if obj in self.objects: self.queue_del.remove(obj)
80
+ if obj in self.objects: self.queue_del.append(obj)
76
81
  else: self.active_scene._queue_remove(obj)
77
82
  def _get_id(self):
78
83
  self.id += 1
@@ -86,6 +91,9 @@ class _game:
86
91
  def __update_render_queue(self): #update order of the renders based on z-index
87
92
  self.render_queue = sorted(self.objects, key=lambda obj: obj.z_index)
88
93
 
94
+ def _UpRenQ_(self):
95
+ self.__update_render_queue()
96
+
89
97
  def __handle_queue(self):
90
98
  for obj in self.queue_creation: self.objects.append(obj)
91
99
  for obj in self.queue_del: self.objects.remove(obj)
@@ -128,7 +136,8 @@ class _game:
128
136
  self.__handle_queue()
129
137
 
130
138
  #update objs
131
- for obj in self.objects: obj.update()
139
+ for obj in self.objects:
140
+ if obj._active: obj.update()
132
141
  #update scene
133
142
  if self.active_scene is not None:
134
143
  self.active_scene.update()
@@ -159,11 +168,10 @@ class _game:
159
168
  for coll in self.collisions:
160
169
  pygame.draw.rect(self.screen, "yellow", coll, 2)
161
170
 
162
- def quit(self):
171
+ def quit(self, _quit_program=True):
163
172
  self.__on = False
164
173
  pygame.quit()
165
- sys.exit()
166
-
174
+ if _quit_program: sys.exit()
167
175
  def set_title(self, title):
168
176
  self.title = title
169
177
  pygame.display.set_caption(self.title)
@@ -171,10 +179,10 @@ class _game:
171
179
  def Tick(self):
172
180
  self.update()
173
181
  self.render()
174
- def Run(self, _esc=False):
182
+ def Run(self, _esc=False, _quit_program=True):
175
183
  while True:
176
184
  self.Tick()
177
- if _esc and Keys.is_pressed(pygame.K_ESCAPE): self.quit()
185
+ if _esc and Keys.is_pressed(pygame.K_ESCAPE): self.quit(_quit_program)
178
186
  def full_reset(self):
179
187
  self.objects = []
180
188
  self.queue_creation = []
@@ -226,7 +234,8 @@ class Scene:
226
234
  def update(self): pass #user defined
227
235
  def _update(self): #built in method
228
236
  self.__handle_queue()
229
- for obj in self._objects: obj.update()
237
+ for obj in self._objects:
238
+ if obj._active: obj.update()
230
239
 
231
240
  def render(self): pass #user defined
232
241
  def _render(self): #built in method
@@ -61,6 +61,17 @@ class _keys:
61
61
 
62
62
  self.shift = pygame.K_LSHIFT
63
63
 
64
+ #func
65
+ self.f1 = pygame.K_F1
66
+ self.f2 = pygame.K_F2
67
+ self.f3 = pygame.K_F3
68
+ self.f4 = pygame.K_F4
69
+ self.f5 = pygame.K_F5
70
+ self.f6 = pygame.K_F6
71
+ self.f7 = pygame.K_F7
72
+ self.f8 = pygame.K_F8
73
+ self.f9 = pygame.K_F9
74
+
64
75
  #mouse
65
76
  self.mouse_x, self.mouse_y = 0, 0
66
77
 
@@ -7,12 +7,12 @@ class GameObj: #this will be the base class of every game obj
7
7
  self.pos: Vector2D = pos
8
8
  self.vel: Vector2D = Vector2D(0, 0)
9
9
  self.z_index = z_index
10
- self.active = active
10
+ self._active = active
11
11
  self.visible = visible
12
12
  self._id = Game._get_id()
13
13
 
14
- self.__parent: GameObj = None
15
- self.__children: list[GameObj] = []
14
+ self._parent: GameObj = None
15
+ self._children: list[GameObj] = []
16
16
 
17
17
  #add to creation
18
18
  if Game.always_global: Global = True
@@ -22,25 +22,30 @@ class GameObj: #this will be the base class of every game obj
22
22
  self._global = Global
23
23
 
24
24
  def child(self, obj): #obj is a game object
25
- self.__children.append(obj)
25
+ self._children.append(obj)
26
26
  obj.parent(self)
27
27
  return obj #QOF
28
28
 
29
+ def set_z_index(self, new_index):
30
+ self.z_index = new_index
31
+ Game._UpRenQ_()
32
+
29
33
  def parent(self, obj):
30
34
  # 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
35
+ if self._parent and self in self._parent._children:
36
+ self._parent._children.remove(self)
37
+ self._parent = obj
34
38
 
35
39
  def update(self): pass
36
40
  def render(self): pass
37
41
  def destroy(self):
38
42
  Game._queue_remove(self)
39
- for i in self.__children:
43
+ for i in self._children:
40
44
  i.destroy()
41
45
 
42
- if self.__parent: self.__parent.__children.remove(self)
46
+ if self._parent:
47
+ if self in self._parent._children: self._parent._children.remove(self)
43
48
 
44
- self.__children = []
45
- self.__parent = None
49
+ self._children = []
50
+ self._parent = None
46
51
 
@@ -5,7 +5,7 @@ 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, Global=False):
8
+ def __init__(self, x, y, w, h, color, width=0, z_index=0, active=True, visible=True, offset=True, Global=False):
9
9
  super().__init__(Vector2D(x, y), z_index, active, visible, Global)
10
10
  self.dim = Vector2D(w, h)
11
11
  self.color = color
@@ -23,7 +23,7 @@ class Rect(GameObj):
23
23
  pygame.draw.rect(screen, self.color, self.rect, self.width)
24
24
 
25
25
  class Circle(GameObj):
26
- def __init__(self, x, y, r, color, z_index=0, width=0, active=True, visible=True, offset=True, Global=False):
26
+ def __init__(self, x, y, r, color, width=0, z_index=0, active=True, visible=True, offset=True, Global=False):
27
27
  super().__init__(Vector2D(x, y), z_index, active, visible, Global)
28
28
  self.radius = r
29
29
  self.color = color
@@ -37,7 +37,7 @@ class Circle(GameObj):
37
37
  pygame.draw.circle(screen, self.color, self.pos.to_int(), self.radius, self.width)
38
38
 
39
39
  class Line(GameObj):
40
- def __init__(self, x1, y1, x2, y2, color, z_index=0, width=1, active=True, visible=True, offset=True, Global=False):
40
+ def __init__(self, x1, y1, x2, y2, color, width=1, z_index=0, active=True, visible=True, offset=True, Global=False):
41
41
  super().__init__(Vector2D(x1, y1), z_index, active, visible, Global)
42
42
  self.end = Vector2D(x2, y2)
43
43
  self.color = color
@@ -7,7 +7,7 @@ from ..Math import Vector2D
7
7
  from ..utils import SubScreen
8
8
 
9
9
  class Tilemap(GameObj):
10
- def __init__(self, name, tileset, size=16, z_index=0, active=True, visible=True, Global=False ):
10
+ def __init__(self, name, tileset, size=16, z_index=0, active=True, visible=True, offset=True, Global=False ):
11
11
  super().__init__(Vector2D(0, 0), z_index, active, visible, Global)
12
12
  self.name = name
13
13
  self.tileset: dict[list[int], pygame.surface.Surface] = tileset
@@ -3,7 +3,7 @@ from ..Game import Game
3
3
  from ..Math import Vector2D
4
4
 
5
5
  class Timer(GameObj):
6
- def __init__(self, duration, active=True, Global=False):
6
+ def __init__(self, duration, z_index=0, active=True, visible=True, offset=True, Global=False):
7
7
  super().__init__(Vector2D(0, 0), 0, active, True, Global)
8
8
  self.duration = duration
9
9
  self.elapsed = 0.0
@@ -21,7 +21,6 @@ class Timer(GameObj):
21
21
  return self.elapsed
22
22
 
23
23
  def update(self):
24
- if not self.active: return
25
24
  if self.running:
26
25
  self.elapsed += Game.dt
27
26
  if self.elapsed >= self.duration:
@@ -65,7 +65,7 @@ class Animation(GameObj):
65
65
  return self
66
66
 
67
67
  def copy(self):
68
- return Animation(self.image, self.size, self.fps, self.loop, self.pos, self.z_index, self.active, self.visible, self.offset, self._global)
68
+ return Animation(self.image, self.size, self.fps, self.loop, self.pos, self.z_index, self._active, self.visible, self.offset, self._global)
69
69
  def render(self):
70
70
  Game.cam.draw_image(self.get_image(), self.pos, self.offset)
71
71
  def render_to(self, screen):
pyscene-1.1.6/test.py ADDED
@@ -0,0 +1,7 @@
1
+ from src.PyScene import *
2
+
3
+ Game.init(640, 360, "Test - 01", "darkblue", application=True) #init game with width, height, title, background color and application mode
4
+
5
+
6
+ Game.Run(True) #or you can have a manual game loop with Game.Tick or using Game.update and Game.render
7
+ #Also passing true will make the window close if ascape is presed
pyscene-1.1.4/test.py DELETED
@@ -1,28 +0,0 @@
1
- from src.PyScene import *
2
- import pygame
3
-
4
-
5
- Game.init(640, 360, "Test - 01", "darkblue", fullscreen=False)
6
-
7
- class Player(GameObj):
8
- def __init__(self):
9
- super().__init__(Vector2D(0, 0), 0)
10
- self.rect = Rect(0, 0, 16, 16, "green")
11
-
12
- def update(self):
13
- self.vel = (Keys.get_vector(Keys.a, Keys.d, Keys.w, Keys.s, False)*150)*Game.dt
14
- self.pos += self.vel
15
- self.rect.pos = self.pos
16
-
17
- Game.cam.pos.x = -Game.width/2
18
- Game.cam.pos.y = -Game.height/2
19
- Player()
20
-
21
- Assets.new_tileset("tests/tileset.png", "tileset")
22
- t = Tilemap("test", Assets.get_tileset("tileset"), 16, -1)
23
-
24
- #t.tilemap[(0, 0)] = (1, 0)
25
- #t.tilemap[(0, 1)] = (1, 1)
26
- #t.dirty = True
27
-
28
- Game.Run(True)
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