GameBox 0.9.1__tar.gz → 0.9.2__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 (31) hide show
  1. {gamebox-0.9.1 → gamebox-0.9.2}/PKG-INFO +1 -1
  2. {gamebox-0.9.1 → gamebox-0.9.2}/pyproject.toml +1 -1
  3. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/helpers/_collisions.py +74 -23
  4. {gamebox-0.9.1 → gamebox-0.9.2}/tests/GettingStarted.py +1 -0
  5. {gamebox-0.9.1 → gamebox-0.9.2}/.gitignore +0 -0
  6. {gamebox-0.9.1 → gamebox-0.9.2}/LICENSE +0 -0
  7. {gamebox-0.9.1 → gamebox-0.9.2}/README.md +0 -0
  8. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/GameLevel_ui/_Animations.py +0 -0
  9. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/GameLevel_ui/_sprites.py +0 -0
  10. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/__init__.py +0 -0
  11. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/_game.py +0 -0
  12. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/basics/__init__.py +0 -0
  13. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/basics/_net.py +0 -0
  14. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/basics/_shapes.py +0 -0
  15. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/basics/cammera.py +0 -0
  16. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/basics/utils.py +0 -0
  17. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/helpers/_Conditions.py +0 -0
  18. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/helpers/_input.py +0 -0
  19. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/player/_player.py +0 -0
  20. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/player/_playerControler.py +0 -0
  21. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/player/_playerPhysics.py +0 -0
  22. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/player/_playerSprite.py +0 -0
  23. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/tilemap/_Editor.py +0 -0
  24. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/tilemap/_collisionDef.py +0 -0
  25. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/tilemap/_editorBrushes.py +0 -0
  26. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/tilemap/_tilemap.py +0 -0
  27. {gamebox-0.9.1 → gamebox-0.9.2}/src/GameBox/ui/_basicUI.py +0 -0
  28. {gamebox-0.9.1 → gamebox-0.9.2}/tests/Player.png +0 -0
  29. {gamebox-0.9.1 → gamebox-0.9.2}/tests/basicScreen.py +0 -0
  30. {gamebox-0.9.1 → gamebox-0.9.2}/tests/levelTiles.png +0 -0
  31. {gamebox-0.9.1 → gamebox-0.9.2}/tests/testMap.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameBox
3
- Version: 0.9.1
3
+ Version: 0.9.2
4
4
  Summary: GameBox is a beginner-friendly Python package built on top of pygame, designed to make 2D game development faster and easier. It provides ready-to-use modules, utilities, and abstractions that let new developers create polished games without needing advanced coding knowledge—while still offering the flexibility for experienced coders to customize and extend.
5
5
  Author-email: Sam Fertig <sfertig007@gmail.com>
6
6
  License-Expression: MIT
@@ -3,7 +3,7 @@ requires = ["hatchling >= 1.26"]
3
3
  build-backend = "hatchling.build"
4
4
  [project]
5
5
  name = "GameBox"
6
- version = "0.9.1"
6
+ version = "0.9.2"
7
7
  authors = [
8
8
  { name="Sam Fertig", email="sfertig007@gmail.com" },
9
9
  ]
@@ -14,34 +14,85 @@ def CheckCollisions(x, y, vx, vy, dim, sample, obj):
14
14
  return x, y, vx, vy
15
15
 
16
16
  def _mainCollisionLogic(collisions, x, y, vx, vy, dim):
17
- # Y-axis collisions
18
- py = y
19
- new_rect = pygame.Rect((x, y), dim)
20
- if Global._debug:
21
- pygame.draw.rect(Global.screen, "green", new_rect, 5)
17
+ offset = 0
18
+
19
+ prev_rect = pygame.Rect(x - vx, y - vy, dim[0], dim[1])
20
+ rect = pygame.Rect(x, y, dim[0], dim[1])
21
+
22
+ # =====================
23
+ # Y AXIS COLLISION
24
+ # =====================
25
+ y_hit = None
26
+
22
27
  for collision in collisions:
23
28
  if Global._debug:
24
- pygame.draw.rect(Global.screen, "yellow", collision, 5)
25
- if collision.colliderect(new_rect):
26
- if vy > 0: # falling
27
- y = collision.top - dim[1]
28
- vy = 0
29
- elif vy < 0: # jumping
30
- y = collision.bottom
31
- vy = 0
32
-
33
- new_rect = pygame.Rect((x, py), dim)
29
+ pygame.draw.rect(Global.screen, "yellow", collision, 2)
30
+
31
+ if collision.colliderect(rect):
32
+ if vy > 0 and prev_rect.bottom <= collision.top:
33
+ if y_hit is None or collision.top < y_hit.top:
34
+ y_hit = collision
35
+ elif vy < 0 and prev_rect.top >= collision.bottom:
36
+ if y_hit is None or collision.bottom > y_hit.bottom:
37
+ y_hit = collision
38
+
39
+ if y_hit:
40
+ if vy > 0:
41
+ y = y_hit.top - dim[1] - offset
42
+ else:
43
+ y = y_hit.bottom + offset
44
+ vy = 0
45
+
46
+ # update rect after Y resolution
47
+ rect.y = y
48
+
49
+ # =====================
50
+ # X AXIS COLLISION
51
+ # =====================
52
+ x_hit = None
53
+
34
54
  for collision in collisions:
35
- if Global._debug:
36
- pygame.draw.rect(Global.screen, "yellow", collision, 5)
37
- if collision.colliderect(new_rect):
38
- if vx > 0:
39
- x = collision.left - dim[0]
40
- elif vx < 0:
41
- x = collision.right
42
- vx = 0
55
+ if collision.colliderect(rect):
56
+
57
+ # ONLY resolve X if we were NOT overlapping horizontally last frame
58
+ if prev_rect.right <= collision.left and vx > 0:
59
+ if x_hit is None or collision.left < x_hit.left:
60
+ x_hit = collision
61
+
62
+ elif prev_rect.left >= collision.right and vx < 0:
63
+ if x_hit is None or collision.right > x_hit.right:
64
+ x_hit = collision
65
+
66
+ if x_hit:
67
+ if vx > 0:
68
+ x = x_hit.left - dim[0] - offset
69
+ else:
70
+ x = x_hit.right + offset
71
+ vx = 0
72
+
73
+ if Global._debug:
74
+ pygame.draw.rect(
75
+ Global.screen,
76
+ "green",
77
+ rect,
78
+ 2
79
+ )
80
+ pygame.draw.rect(
81
+ Global.screen,
82
+ "red",
83
+ prev_rect,
84
+ 1
85
+ )
86
+ pygame.draw.rect(
87
+ Global.screen,
88
+ "blue",
89
+ (x, y, dim[0], dim[1]),
90
+ 2
91
+ )
43
92
 
44
93
  return x, y, vx, vy
94
+
95
+
45
96
 
46
97
  def _checkTilemapCollisions(x, y, vx, vy, dim, sample, obj):
47
98
  if len(Global.tilemap) == 0:
@@ -6,6 +6,7 @@ width, height = 800, 600
6
6
 
7
7
  game = Game(width, height, "blue", "First Game!")
8
8
  screen = game.get_screen()
9
+ game._set_debug(True)
9
10
 
10
11
  cam = Cammera()
11
12
 
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