GameBox 0.9.1__py3-none-any.whl → 0.9.2__py3-none-any.whl

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.
@@ -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:
@@ -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
@@ -8,7 +8,7 @@ GameBox/basics/_shapes.py,sha256=Rbkd0lrpxGvbVdwL98_iovFtqB1USI5Qk6umJPR0CIc,131
8
8
  GameBox/basics/cammera.py,sha256=eP7cNkTruZ9CDf94VGTsjgdI4NNnWjN-ilCHgGLYNSs,941
9
9
  GameBox/basics/utils.py,sha256=w6H34MhxcNoX58iQtlvbT5-4GXefy3RIMTxZGP9fSxA,432
10
10
  GameBox/helpers/_Conditions.py,sha256=FSqwJWL0QBvCQmSyzhL5LtudhP5c-tRzC_8xuQENsGw,1946
11
- GameBox/helpers/_collisions.py,sha256=b8eBnEYbgYFxQ4m6xpAeAaNkYosbP5xUOIlT40sztBs,4503
11
+ GameBox/helpers/_collisions.py,sha256=q29j6N1bNh7hp9OoX5ipODLf4n6FjPzGb8vNSZ_x4Oc,5692
12
12
  GameBox/helpers/_input.py,sha256=97bPxM5dkonRywOhj11lgHVQVicuLAKYi_w8EPM0Af8,1963
13
13
  GameBox/player/_player.py,sha256=HU7iOBoHj5oXJTA-lHmwPZbFt8CXm-IPzK3NWBGzRhM,1872
14
14
  GameBox/player/_playerControler.py,sha256=XEb87RFlgLFoXnXqxIS4lpzHN0wywMNCX5y-NIhw0cs,1715
@@ -19,7 +19,7 @@ GameBox/tilemap/_collisionDef.py,sha256=VxWcfz3nlhyYI_Hemp-LvC6IDC-YN6wIdRaU8Asg
19
19
  GameBox/tilemap/_editorBrushes.py,sha256=GFfRV0OB3t9sFb37eO3sB8Cmwyd5i_q64q5IjYlkx1k,7247
20
20
  GameBox/tilemap/_tilemap.py,sha256=SEQlokpsUO9zQkLMF-j6amx1FqNeD2eM2CRFj3zCnZ8,3330
21
21
  GameBox/ui/_basicUI.py,sha256=LnlQ-YNHFypohjal3eYRws9H52iCLUyRuZWg6n5Fg0o,1007
22
- gamebox-0.9.1.dist-info/METADATA,sha256=XghkrBPlIfxU7NdxwlbVZq6Hhz4U-qJp7H9ydOlgalw,1059
23
- gamebox-0.9.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
24
- gamebox-0.9.1.dist-info/licenses/LICENSE,sha256=gcuuhKKc5-dwvyvHsXjlC9oM6N5gZ6umYbC8ewW1Yvg,35821
25
- gamebox-0.9.1.dist-info/RECORD,,
22
+ gamebox-0.9.2.dist-info/METADATA,sha256=8FWr5TfY0d3CxfiJlDUAPO1oq0AfDAmfqVyu8H7oir4,1059
23
+ gamebox-0.9.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
24
+ gamebox-0.9.2.dist-info/licenses/LICENSE,sha256=gcuuhKKc5-dwvyvHsXjlC9oM6N5gZ6umYbC8ewW1Yvg,35821
25
+ gamebox-0.9.2.dist-info/RECORD,,