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.
- GameBox/helpers/_collisions.py +74 -23
- {gamebox-0.9.1.dist-info → gamebox-0.9.2.dist-info}/METADATA +1 -1
- {gamebox-0.9.1.dist-info → gamebox-0.9.2.dist-info}/RECORD +5 -5
- {gamebox-0.9.1.dist-info → gamebox-0.9.2.dist-info}/WHEEL +0 -0
- {gamebox-0.9.1.dist-info → gamebox-0.9.2.dist-info}/licenses/LICENSE +0 -0
GameBox/helpers/_collisions.py
CHANGED
|
@@ -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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if vx > 0:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
vx
|
|
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.
|
|
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=
|
|
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.
|
|
23
|
-
gamebox-0.9.
|
|
24
|
-
gamebox-0.9.
|
|
25
|
-
gamebox-0.9.
|
|
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,,
|
|
File without changes
|
|
File without changes
|