sverpykit 0.2.14__tar.gz → 0.2.15__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 (28) hide show
  1. {sverpykit-0.2.14 → sverpykit-0.2.15}/PKG-INFO +1 -1
  2. {sverpykit-0.2.14 → sverpykit-0.2.15}/pyproject.toml +1 -1
  3. sverpykit-0.2.15/sverpykit/Collide/Collide.py +57 -0
  4. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/Draw/Draw.py +1 -1
  5. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/Objects/Entity.py +3 -3
  6. sverpykit-0.2.15/sverpykit/Shapes/Circle.py +22 -0
  7. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/__init__.py +7 -1
  8. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/core/FileManager.py +0 -1
  9. sverpykit-0.2.15/sverpykit/core/Json.py +19 -0
  10. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit.egg-info/PKG-INFO +1 -1
  11. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit.egg-info/SOURCES.txt +3 -1
  12. sverpykit-0.2.14/sverpykit/Collide/Collide.py +0 -13
  13. {sverpykit-0.2.14 → sverpykit-0.2.15}/LICENSE +0 -0
  14. {sverpykit-0.2.14 → sverpykit-0.2.15}/README.md +0 -0
  15. {sverpykit-0.2.14 → sverpykit-0.2.15}/setup.cfg +0 -0
  16. /sverpykit-0.2.14/sverpykit/Objects/Platform.py → /sverpykit-0.2.15/sverpykit/Objects/Block.py +0 -0
  17. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/Ui/Button.py +0 -0
  18. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/Ui/DropDown.py +0 -0
  19. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/Ui/SearchBar.py +0 -0
  20. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/Ui/TextBlock.py +0 -0
  21. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/Ui/Window.py +0 -0
  22. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/core/Config.py +0 -0
  23. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/core/Objects.py +0 -0
  24. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/core/Runtime.py +0 -0
  25. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit/core/initialize.py +0 -0
  26. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit.egg-info/dependency_links.txt +0 -0
  27. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit.egg-info/requires.txt +0 -0
  28. {sverpykit-0.2.14 → sverpykit-0.2.15}/sverpykit.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sverpykit
3
- Version: 0.2.14
3
+ Version: 0.2.15
4
4
  Summary: A wrapper for pygame.
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sverpykit"
7
- version = "0.2.14"
7
+ version = "0.2.15"
8
8
  description = "A wrapper for pygame."
9
9
  readme = "README.md"
10
10
  dependencies = [
@@ -0,0 +1,57 @@
1
+ from sverpykit.Shapes import Circle
2
+ import pygame, math
3
+
4
+ class collides:
5
+
6
+ @ staticmethod
7
+ def rect_rect(
8
+ rect1: pygame.Rect,
9
+ rect2: pygame.Rect
10
+ ) -> bool:
11
+ return rect1.colliderect(rect2)
12
+
13
+ @ staticmethod
14
+ def rect_point(
15
+ rect: pygame.Rect,
16
+ point: tuple[int, int]
17
+ ) -> bool:
18
+ return rect.collidepoint(point)
19
+
20
+ @ staticmethod
21
+ def circle_circle(
22
+ circle1: Circle.Circle,
23
+ circle2: Circle.Circle
24
+ ) -> bool:
25
+ """
26
+ :param circle1: The first circle.
27
+ :param circle2: The second circle.
28
+ :return: Returns if the circles collide.
29
+ """
30
+ return math.sqrt(
31
+ math.pow(circle1.center[0] - circle2.center[0], 2) + math.pow(circle1.center[1] - circle2.center[1], 2)
32
+ ) < circle1.diameter/2 + circle2.diameter/2
33
+
34
+ @ staticmethod
35
+ def circle_point(
36
+ circle: Circle.Circle,
37
+ point: tuple[int, int]
38
+ ) -> bool:
39
+ """
40
+ :param circle: The circle.
41
+ :param point: The coordinates of the point.
42
+ :return: Returns if the coordinates are in the circle.
43
+ """
44
+ return math.sqrt(
45
+ math.pow(circle.center[0] - point[0], 2) + math.pow(circle.center[1] - point[1], 2)
46
+ ) < circle.diameter
47
+
48
+ # @ staticmethod
49
+ # def circle_rect(
50
+ # circle: Circle.Circle,
51
+ # rect: pygame.Rect
52
+ # ) -> bool:
53
+ # """
54
+ # :param circle: The circle.
55
+ # :param rect: The rect.
56
+ # :return: Returns if the rectangle collides with the circle.
57
+ # """
@@ -49,7 +49,7 @@ def draw_circle(
49
49
  color: pygame.Color | tuple[int, int, int],
50
50
  center: tuple[int, int],
51
51
  radius: float | int,
52
- width: int,
52
+ width: int = 0,
53
53
  draw_top_left: bool = False,
54
54
  draw_top_right: bool = False,
55
55
  draw_bottom_left: bool = False,
@@ -7,11 +7,11 @@ class Entity:
7
7
  self,
8
8
  hitbox: pygame.Rect,
9
9
  surface: pygame.Surface,
10
- player_events: dict[str, Callable] | None = None,
10
+ events: dict[str, Callable] | None = None,
11
11
  statistics: dict[str, Any] | None = None,
12
12
  states: dict[str, Any] | None = None
13
13
  ):
14
- player_events = player_events if isinstance(player_events, dict)\
14
+ events = events if isinstance(events, dict)\
15
15
  else {}
16
16
  statistics = statistics if isinstance(statistics, dict)\
17
17
  else {}
@@ -37,7 +37,7 @@ class Entity:
37
37
  "key": Entity.key_events,
38
38
  "mouse": Entity.mouse_events
39
39
  }
40
- self.accepted_events.update(player_events)
40
+ self.accepted_events.update(events)
41
41
 
42
42
  def key_events(self, keys: dict):
43
43
  pass
@@ -0,0 +1,22 @@
1
+ import pygame
2
+
3
+ class Circle:
4
+ def __init__(
5
+ self,
6
+ center: tuple[int, int],
7
+ diameter: int
8
+ ):
9
+ self.center = center
10
+ self.diameter = diameter
11
+
12
+ def draw(
13
+ self,
14
+ display: pygame.Surface,
15
+ color: tuple[int, int, int]
16
+ ) -> None:
17
+ pygame.draw.circle(
18
+ surface=display,
19
+ color=color,
20
+ center=self.center,
21
+ radius=self.diameter/2
22
+ )
@@ -6,12 +6,18 @@ from .core.Runtime import add_layer, add_game_object, start, update as run_frame
6
6
  from .core.Config import default_exit as quit_game
7
7
  from .core.initialize import set_display, set_frame_method, set_font, set_quit_method, set_tick_method,\
8
8
  set_src_path, max_rate
9
+
10
+ # File Management
11
+ from .core import Json
9
12
  from .core.FileManager import resource_path
10
13
 
14
+ # Collision
15
+ from .Collide.Collide import collides
16
+
11
17
  # Drawing
12
18
  from .Draw.Draw import draw_surface, draw_rect, draw_circle, render_text
13
19
  from .Objects.Entity import Entity
14
- from .Objects.Platform import Platform
20
+ from .Objects.Block import Platform
15
21
 
16
22
  # Ui parts
17
23
  from .Ui.Button import Button
@@ -12,6 +12,5 @@ def resource_path(relative_path: str) -> str:
12
12
  if not os.path.exists(src_path):
13
13
  raise TypeError(f"Please set the src path before you run this function!")
14
14
  if hasattr(sys, '_MEIPASS'):
15
- print("Not supported yet!")
16
15
  return os.path.join(sys._MEIPASS, f"{relative_path}")
17
16
  return os.path.join(src_path, f"{relative_path}")
@@ -0,0 +1,19 @@
1
+ import json
2
+
3
+ def read_json(path: str, obj: int | str | None = None) -> dict | list | int | str:
4
+ with open(path, "r") as f:
5
+ data = json.load(f)
6
+ return data.get(obj, data)
7
+
8
+ def write_json(path: str, obj: dict | list) -> None:
9
+ with open(path, "w") as f:
10
+ json.dump(obj, f, indent=4)
11
+
12
+ def update_json(path: str, obj: dict | list) -> None:
13
+ with open(path, "r") as f:
14
+ data: list | dict = json.load(f)
15
+ if not isinstance(obj, type(data)):
16
+ raise ValueError("Object does not have the same type as JSON file!")
17
+ with open(path, "w") as f:
18
+ data.update(obj) if isinstance(data, dict) else data.extend(obj)
19
+ json.dump(data, f, indent=4)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sverpykit
3
- Version: 0.2.14
3
+ Version: 0.2.15
4
4
  Summary: A wrapper for pygame.
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -9,8 +9,9 @@ sverpykit.egg-info/requires.txt
9
9
  sverpykit.egg-info/top_level.txt
10
10
  sverpykit/Collide/Collide.py
11
11
  sverpykit/Draw/Draw.py
12
+ sverpykit/Objects/Block.py
12
13
  sverpykit/Objects/Entity.py
13
- sverpykit/Objects/Platform.py
14
+ sverpykit/Shapes/Circle.py
14
15
  sverpykit/Ui/Button.py
15
16
  sverpykit/Ui/DropDown.py
16
17
  sverpykit/Ui/SearchBar.py
@@ -18,6 +19,7 @@ sverpykit/Ui/TextBlock.py
18
19
  sverpykit/Ui/Window.py
19
20
  sverpykit/core/Config.py
20
21
  sverpykit/core/FileManager.py
22
+ sverpykit/core/Json.py
21
23
  sverpykit/core/Objects.py
22
24
  sverpykit/core/Runtime.py
23
25
  sverpykit/core/initialize.py
@@ -1,13 +0,0 @@
1
- import pygame
2
-
3
- def rect_rect(
4
- rect1: pygame.Rect,
5
- rect2: pygame.Rect
6
- ):
7
- return rect1.colliderect(rect2)
8
-
9
- def rect_point(
10
- rect: pygame.Rect,
11
- point: tuple[int, int]
12
- ):
13
- return rect.collidepoint(point)
File without changes
File without changes
File without changes