GameBox 0.9.0__py3-none-any.whl → 0.9.1__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/GameLevel_ui/_sprites.py +1 -59
- GameBox/_game.py +21 -0
- GameBox/basics/_net.py +2 -0
- GameBox/basics/_shapes.py +1 -45
- GameBox/basics/cammera.py +0 -39
- GameBox/helpers/_Conditions.py +9 -18
- GameBox/helpers/_collisions.py +6 -3
- GameBox/helpers/_input.py +0 -4
- GameBox/player/_player.py +1 -18
- GameBox/player/_playerSprite.py +3 -3
- GameBox/tilemap/_tilemap.py +0 -14
- GameBox/ui/_basicUI.py +7 -36
- {gamebox-0.9.0.dist-info → gamebox-0.9.1.dist-info}/METADATA +1 -1
- gamebox-0.9.1.dist-info/RECORD +25 -0
- gamebox-0.9.0.dist-info/RECORD +0 -25
- {gamebox-0.9.0.dist-info → gamebox-0.9.1.dist-info}/WHEEL +0 -0
- {gamebox-0.9.0.dist-info → gamebox-0.9.1.dist-info}/licenses/LICENSE +0 -0
GameBox/GameLevel_ui/_sprites.py
CHANGED
|
@@ -77,44 +77,7 @@ def split_image(image, tileDim, startPos):
|
|
|
77
77
|
return image.subsurface((x, y, tileDim[0], tileDim[1]))
|
|
78
78
|
|
|
79
79
|
class Animated_Sprite2D:
|
|
80
|
-
"""
|
|
81
|
-
A class for animated 2D sprites.
|
|
82
|
-
|
|
83
|
-
Args:
|
|
84
|
-
pos (tuple): The position of the sprite in world space.
|
|
85
|
-
image (str or pygame.Surface): The image of the sprite.
|
|
86
|
-
imageDim (tuple): The dimensions of the image.
|
|
87
|
-
tileDim (tuple): The dimensions of the tiles in the image.
|
|
88
|
-
frames (int): The number of frames in the animation.
|
|
89
|
-
speed (float): The speed of the animation.
|
|
90
|
-
scale (float): The scale of the sprite.
|
|
91
|
-
collision (bool): Whether the sprite has collision.
|
|
92
|
-
dirrection (int): The direction of the sprite.
|
|
93
|
-
|
|
94
|
-
Attributes:
|
|
95
|
-
animation (Animation): The animation of the sprite.
|
|
96
|
-
collision (bool): Whether the sprite has collision.
|
|
97
|
-
dir (int): The direction of the sprite.
|
|
98
|
-
pos (tuple): The position of the sprite in world space.
|
|
99
|
-
scale (float): The scale of the sprite.
|
|
100
|
-
image (pygame.Surface): The current frame of the animation.
|
|
101
|
-
__worldPos__ (bool): Whether the sprite is in world space.
|
|
102
|
-
|
|
103
|
-
Methods:
|
|
104
|
-
update (None): Updates the sprite.
|
|
105
|
-
__remove__ (None): Removes the sprite from the game.
|
|
106
|
-
switch_dirrection (None): Switches the direction of the sprite.
|
|
107
|
-
move_by (x, y): Moves the sprite by (x, y) in world space.
|
|
108
|
-
move_to (x, y): Moves the sprite to (x, y) in world space.
|
|
109
|
-
get_pos (None): Returns the position of the sprite in world space.
|
|
110
|
-
rescale (scale): Rescales the sprite by the given scale.
|
|
111
|
-
"""
|
|
112
|
-
|
|
113
80
|
def __init__(self, pos, image, imageDim, tileDim, frames, speed, scale = 1.0, collision = True, dirrection = 1):
|
|
114
|
-
"""
|
|
115
|
-
|
|
116
|
-
"""
|
|
117
|
-
|
|
118
81
|
self.animation = Animation(image, tileDim, (0, 0), frames, speed)
|
|
119
82
|
self.collision = collision
|
|
120
83
|
self.dir = dirrection
|
|
@@ -167,27 +130,6 @@ class Animated_Sprite2D:
|
|
|
167
130
|
self.image = pygame.transform.scale_by(self.image, scale)
|
|
168
131
|
|
|
169
132
|
class AnimationPlayer2D:
|
|
170
|
-
"""
|
|
171
|
-
Class for playing animations in a 2D game.
|
|
172
|
-
|
|
173
|
-
Attributes:
|
|
174
|
-
pos (tuple): Position of the AnimationPlayer2D.
|
|
175
|
-
scale (float): Scale of the AnimationPlayer2D.
|
|
176
|
-
anims (dict): Dictionary of animations that can be played, where the key is the name of the animation and the value is an instance of Animated_Sprite2D.
|
|
177
|
-
currentAnim (str): The name of the currently playing animation.
|
|
178
|
-
|
|
179
|
-
Methods:
|
|
180
|
-
update (None): Updates the currently playing animation.
|
|
181
|
-
add_animation (name, image, imageDim, tileDim, frames, speed, scale = 1.0, collision = True, dirrection = 1): Adds an animation to the AnimationPlayer2D.
|
|
182
|
-
remove_animation (name: str): Removes an animation from the AnimationPlayer2D.
|
|
183
|
-
set_worldPos (worldPos: bool): Sets the world position of all animations in the AnimationPlayer2D.
|
|
184
|
-
__remove__ (None): Removes the AnimationPlayer2D from the game.
|
|
185
|
-
set_scale (scale: float): Sets the scale of all animations in the AnimationPlayer2D.
|
|
186
|
-
set_animation (anim: str): Sets the currently playing animation.
|
|
187
|
-
move_by (x, y): Moves the AnimationPlayer2D by (x, y) in world space.
|
|
188
|
-
move_to (x, y): Moves the AnimationPlayer2D to (x, y) in world space.
|
|
189
|
-
get_pos (None): Returns the position of the AnimationPlayer2D in world space.
|
|
190
|
-
"""
|
|
191
133
|
def __init__(self, pos, scale):
|
|
192
134
|
self.pos = pos
|
|
193
135
|
self.scale = scale
|
|
@@ -218,7 +160,7 @@ class AnimationPlayer2D:
|
|
|
218
160
|
|
|
219
161
|
def __remove__(self):
|
|
220
162
|
if self in Global.game.objs:
|
|
221
|
-
Global.game.objs.remove(self)
|
|
163
|
+
Global.game.objs.remove(self)\
|
|
222
164
|
|
|
223
165
|
def set_scale(self, scale: float):
|
|
224
166
|
for anim in self.anims:
|
GameBox/_game.py
CHANGED
|
@@ -57,4 +57,25 @@ class Game:
|
|
|
57
57
|
if hasattr(obj, "_quit") and callable(obj._quit):
|
|
58
58
|
obj._quit()
|
|
59
59
|
|
|
60
|
+
def _set_debug(self, debug: bool):
|
|
61
|
+
"""
|
|
62
|
+
Set the debug mode for the game. This will show / hide debuging information
|
|
63
|
+
like collisions. Note: This feture is for development and testing purposes only.
|
|
64
|
+
|
|
65
|
+
Parameters:
|
|
66
|
+
debug (bool): The debug mode.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
None
|
|
70
|
+
"""
|
|
71
|
+
Global._debug = debug
|
|
72
|
+
def _get_debug_state(self):
|
|
73
|
+
"""
|
|
74
|
+
Get the debug mode for the game.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
bool: The debug mode.
|
|
78
|
+
"""
|
|
79
|
+
return Global._debug
|
|
80
|
+
|
|
60
81
|
|
GameBox/basics/_net.py
CHANGED
GameBox/basics/_shapes.py
CHANGED
|
@@ -4,26 +4,7 @@ import numpy as np
|
|
|
4
4
|
from ..basics._net import Global
|
|
5
5
|
|
|
6
6
|
class Rect:
|
|
7
|
-
"""
|
|
8
|
-
A rectangle shape used for rendering and collision detection.
|
|
9
|
-
|
|
10
|
-
Args:
|
|
11
|
-
pos (tuple): The position of the rectangle.
|
|
12
|
-
size (tuple): The size of the rectangle.
|
|
13
|
-
color (tuple, optional): The color of the rectangle. Defaults to (0,0,0).
|
|
14
|
-
collision (bool, optional): Whether the rectangle should be used for collision detection. Defaults to True.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
7
|
def __init__(self, pos: tuple, size: tuple, color: tuple = (0, 0, 0), collision: bool = True):
|
|
18
|
-
"""
|
|
19
|
-
Initialize the rectangle object.
|
|
20
|
-
|
|
21
|
-
Args:
|
|
22
|
-
pos (tuple): The position of the rectangle.
|
|
23
|
-
size (tuple): The size of the rectangle.
|
|
24
|
-
color (tuple, optional): The color of the rectangle. Defaults to (0,0,0).
|
|
25
|
-
collision (bool, optional): Whether the rectangle should be used for collision detection. Defaults to True.
|
|
26
|
-
"""
|
|
27
8
|
self.x, self.y = pos
|
|
28
9
|
self.width, self.height = size
|
|
29
10
|
self.color = color
|
|
@@ -31,12 +12,6 @@ class Rect:
|
|
|
31
12
|
self.collision = collision
|
|
32
13
|
|
|
33
14
|
def update(self):
|
|
34
|
-
"""
|
|
35
|
-
Update the rectangle object.
|
|
36
|
-
|
|
37
|
-
This method updates the position and size of the rectangle based on the camera's position and scale.
|
|
38
|
-
It then renders the rectangle to the screen and adds it to the collision detection list if necessary.
|
|
39
|
-
"""
|
|
40
15
|
width = self.width * Global.cam.scale
|
|
41
16
|
height = self.height * Global.cam.scale
|
|
42
17
|
if (Global.cam.follow) != (self):
|
|
@@ -46,18 +21,11 @@ class Rect:
|
|
|
46
21
|
x = self.x
|
|
47
22
|
y = self.y
|
|
48
23
|
|
|
49
|
-
rect = pygame.Rect(x, y, width,
|
|
24
|
+
rect = pygame.Rect(x, y, width ,height)
|
|
50
25
|
if self.collision: Global.collisions.append(rect)
|
|
51
26
|
pygame.draw.rect(Global.screen, self.color, rect)
|
|
52
27
|
|
|
53
28
|
def move(self, x, y):
|
|
54
|
-
"""
|
|
55
|
-
Move the rectangle object.
|
|
56
|
-
|
|
57
|
-
Args:
|
|
58
|
-
x (int): The x-coordinate to move the rectangle by.
|
|
59
|
-
y (int): The y-coordinate to move the rectangle by.
|
|
60
|
-
"""
|
|
61
29
|
if (Global.cam.follow) != (self):
|
|
62
30
|
self.x += x
|
|
63
31
|
self.y += y
|
|
@@ -65,13 +33,6 @@ class Rect:
|
|
|
65
33
|
Global.cam._move(x, y)
|
|
66
34
|
|
|
67
35
|
def move_to(self, x, y):
|
|
68
|
-
"""
|
|
69
|
-
Move the rectangle object to a specific position.
|
|
70
|
-
|
|
71
|
-
Args:
|
|
72
|
-
x (int): The x-coordinate to move the rectangle to.
|
|
73
|
-
y (int): The y-coordinate to move the rectangle to.
|
|
74
|
-
"""
|
|
75
36
|
if (Global.cam.follow) != (self):
|
|
76
37
|
self.x = x
|
|
77
38
|
self.y = y
|
|
@@ -80,9 +41,4 @@ class Rect:
|
|
|
80
41
|
Global.cam.y = y
|
|
81
42
|
|
|
82
43
|
def __remove__(self):
|
|
83
|
-
"""
|
|
84
|
-
Remove the rectangle object from the game.
|
|
85
|
-
|
|
86
|
-
This method removes the rectangle object from the game's object list.
|
|
87
|
-
"""
|
|
88
44
|
Global.game.objs.remove(self)
|
GameBox/basics/cammera.py
CHANGED
|
@@ -6,17 +6,7 @@ from ._net import Global
|
|
|
6
6
|
from ..basics.utils import moveTward
|
|
7
7
|
|
|
8
8
|
class Cammera:
|
|
9
|
-
"""
|
|
10
|
-
A class for the camera object.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
9
|
def __init__(self, scale: float = 1.0):
|
|
14
|
-
"""
|
|
15
|
-
Initialize the camera object.
|
|
16
|
-
|
|
17
|
-
Args:
|
|
18
|
-
scale (float): The scale of the camera (default: 1.0)
|
|
19
|
-
"""
|
|
20
10
|
self.x = 0
|
|
21
11
|
self.y = 0
|
|
22
12
|
Global.game.objs.append(self)
|
|
@@ -26,50 +16,21 @@ class Cammera:
|
|
|
26
16
|
self.scale = scale
|
|
27
17
|
|
|
28
18
|
def _move(self, x: int, y: int):
|
|
29
|
-
"""
|
|
30
|
-
Move the camera by (x, y).
|
|
31
|
-
|
|
32
|
-
Args:
|
|
33
|
-
x (int): The x component of the movement
|
|
34
|
-
y (int): The y component of the movement
|
|
35
|
-
"""
|
|
36
19
|
self.x += x
|
|
37
20
|
self.y += y
|
|
38
21
|
|
|
39
22
|
def update(self):
|
|
40
|
-
"""
|
|
41
|
-
Update the camera position based on the follow target.
|
|
42
|
-
"""
|
|
43
23
|
return
|
|
44
24
|
if self.follow is not None:
|
|
45
25
|
self.x = (self.follow.x - self.diff[0])
|
|
46
26
|
self.y = (self.follow.y - self.diff[1])
|
|
47
27
|
|
|
48
28
|
def set_follow_target(self, target: object):
|
|
49
|
-
"""
|
|
50
|
-
Set the follow target for the camera.
|
|
51
|
-
|
|
52
|
-
Args:
|
|
53
|
-
target (object): The object to follow
|
|
54
|
-
"""
|
|
55
29
|
self.follow = target
|
|
56
30
|
print(target)
|
|
57
31
|
self.diff = (target.x - self.x, target.y - self.y)
|
|
58
32
|
|
|
59
33
|
def set_scale(self, scale: float = 1.0):
|
|
60
|
-
"""
|
|
61
|
-
Set the scale of the camera.
|
|
62
|
-
|
|
63
|
-
Args:
|
|
64
|
-
scale (float): The scale of the camera (default: 1.0)
|
|
65
|
-
"""
|
|
66
34
|
self.scale = scale
|
|
67
|
-
|
|
68
35
|
def change_scale(self, scale: float = 1.0):
|
|
69
|
-
"""
|
|
70
|
-
Change the scale of the camera by the given amount.
|
|
71
|
-
|
|
72
|
-
Args:
|
|
73
|
-
scale (float): The amount to change the scale by (default: 1.0)
|
|
74
|
-
"""
|
|
75
36
|
self.scale += scale
|
GameBox/helpers/_Conditions.py
CHANGED
|
@@ -5,22 +5,14 @@ from ..basics.utils import zeroOut
|
|
|
5
5
|
from ..basics._net import Global
|
|
6
6
|
|
|
7
7
|
class _Conditions:
|
|
8
|
-
"""
|
|
9
|
-
Class containing the predefined conditions for the game.
|
|
10
|
-
Conditions are in the format of 'C' followed by the command ('v' for velocity), and dir (^ up, _ down, < left, > right, # none, ~ any)
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
8
|
def __init__(self):
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
self.
|
|
19
|
-
self.
|
|
20
|
-
self.
|
|
21
|
-
self.velocity_right = 'CV>' # velocity right
|
|
22
|
-
self.velocity_none = 'CV#' # velocity none
|
|
23
|
-
self.velocity_any = 'CV~' # velocity any
|
|
9
|
+
#conditions start with 'C' and then command ('v' for velocity), and dir (^ up, _ down, < left, > right, # none, ~ any)
|
|
10
|
+
self.velocity_up = 'CV^'
|
|
11
|
+
self.velocity_down = 'CV_'
|
|
12
|
+
self.velocity_left = 'CV<'
|
|
13
|
+
self.velocity_right = 'CV>'
|
|
14
|
+
self.velocity_none = 'CV#'
|
|
15
|
+
self.velocity_any = 'CV~'
|
|
24
16
|
|
|
25
17
|
Conditions = _Conditions()
|
|
26
18
|
Global.cond = Conditions
|
|
@@ -43,9 +35,8 @@ class Condition_check:
|
|
|
43
35
|
|
|
44
36
|
def _resolve_velocities(self, velocities, cond):
|
|
45
37
|
vx, vy = velocities
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
vy = zeroOut(vy, Max)
|
|
38
|
+
vx = zeroOut(vx, 0.1)
|
|
39
|
+
vy = zeroOut(vy, 0.1)
|
|
49
40
|
dir = cond[2]
|
|
50
41
|
print(vx, vy, dir)
|
|
51
42
|
#resolve in order up, down, left, right, none, any
|
GameBox/helpers/_collisions.py
CHANGED
|
@@ -17,9 +17,11 @@ def _mainCollisionLogic(collisions, x, y, vx, vy, dim):
|
|
|
17
17
|
# Y-axis collisions
|
|
18
18
|
py = y
|
|
19
19
|
new_rect = pygame.Rect((x, y), dim)
|
|
20
|
-
|
|
20
|
+
if Global._debug:
|
|
21
|
+
pygame.draw.rect(Global.screen, "green", new_rect, 5)
|
|
21
22
|
for collision in collisions:
|
|
22
|
-
|
|
23
|
+
if Global._debug:
|
|
24
|
+
pygame.draw.rect(Global.screen, "yellow", collision, 5)
|
|
23
25
|
if collision.colliderect(new_rect):
|
|
24
26
|
if vy > 0: # falling
|
|
25
27
|
y = collision.top - dim[1]
|
|
@@ -30,7 +32,8 @@ def _mainCollisionLogic(collisions, x, y, vx, vy, dim):
|
|
|
30
32
|
|
|
31
33
|
new_rect = pygame.Rect((x, py), dim)
|
|
32
34
|
for collision in collisions:
|
|
33
|
-
|
|
35
|
+
if Global._debug:
|
|
36
|
+
pygame.draw.rect(Global.screen, "yellow", collision, 5)
|
|
34
37
|
if collision.colliderect(new_rect):
|
|
35
38
|
if vx > 0:
|
|
36
39
|
x = collision.left - dim[0]
|
GameBox/helpers/_input.py
CHANGED
|
@@ -4,9 +4,6 @@ from ..basics._net import Global
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class _keys:
|
|
7
|
-
"""
|
|
8
|
-
A class that holds all the key bindings for the game
|
|
9
|
-
"""
|
|
10
7
|
def __init__(self):
|
|
11
8
|
|
|
12
9
|
#alphabet
|
|
@@ -64,7 +61,6 @@ class _keys:
|
|
|
64
61
|
|
|
65
62
|
#mouse
|
|
66
63
|
self.mouse_x, self.mouse_y = 0, 0
|
|
67
|
-
|
|
68
64
|
def init(self): Global.game.objs.append(self)
|
|
69
65
|
|
|
70
66
|
def is_pressed(self, key):
|
GameBox/player/_player.py
CHANGED
|
@@ -9,38 +9,21 @@ from ..player._playerSprite import _playerSprite
|
|
|
9
9
|
from ..GameLevel_ui._sprites import Sprite_2d
|
|
10
10
|
|
|
11
11
|
class Player:
|
|
12
|
-
"""
|
|
13
|
-
Initialize a Player object.
|
|
14
|
-
|
|
15
|
-
Parameters:
|
|
16
|
-
pos (tuple): The position of the Player in world space.
|
|
17
|
-
size (tuple): The size of the Player in world space.
|
|
18
|
-
color (tuple): The color of the Player (default: (0, 0, 0)).
|
|
19
|
-
gravity (bool): Whether the Player is affected by gravity (default: False).
|
|
20
|
-
|
|
21
|
-
Returns:
|
|
22
|
-
None
|
|
23
|
-
"""
|
|
24
12
|
def __init__(self, pos: tuple, size: tuple, color: tuple = (0, 0, 0), gravity: bool = False):
|
|
25
|
-
# Set the position and size of the Player
|
|
26
13
|
self.x, self.y = pos
|
|
27
14
|
self.screenPos = pos
|
|
28
15
|
self.dim = size
|
|
29
16
|
self.color = color
|
|
30
17
|
self.width, self.height = size
|
|
31
18
|
|
|
32
|
-
# Set whether the Player is affected by gravity
|
|
33
19
|
self.gravity = gravity
|
|
34
20
|
|
|
35
|
-
# State of the Player (e.g. "jumping", "standing", etc.)
|
|
36
21
|
self.state = ""
|
|
37
|
-
|
|
38
|
-
# Add the Player to the game
|
|
22
|
+
|
|
39
23
|
Global.game.objs.append(self)
|
|
40
24
|
Global.player.pos = pos
|
|
41
25
|
Global.player.player = self
|
|
42
26
|
|
|
43
|
-
# Initialize the sprite for the Player
|
|
44
27
|
self.sprite = _playerSprite(self)
|
|
45
28
|
|
|
46
29
|
|
GameBox/player/_playerSprite.py
CHANGED
|
@@ -50,7 +50,7 @@ class _playerSprite:
|
|
|
50
50
|
self.sprite.__worldPos__ = False
|
|
51
51
|
self.sprite.__remove__()
|
|
52
52
|
|
|
53
|
-
def add_animated_sprite_2d(self, image, imageDim, tileDim, frames, speed, scale = 1.0, collision =
|
|
53
|
+
def add_animated_sprite_2d(self, image, imageDim, tileDim, frames, speed, scale = 1.0, collision = True, dirrection = 1):
|
|
54
54
|
self.sprite = Animated_Sprite2D((self.player.x, self.player.y), image, imageDim, tileDim, frames, speed, scale, collision, dirrection)
|
|
55
55
|
if Global.cam.follow == self.player:
|
|
56
56
|
self.sprite.__worldPos__ = False
|
|
@@ -66,8 +66,8 @@ class _playerSprite:
|
|
|
66
66
|
self.sprite.set_worldPos(False)
|
|
67
67
|
self.sprite.__remove__()
|
|
68
68
|
|
|
69
|
-
def add_animation(self, name, image, imageDim, tileDim, frames, speed, scale = 1.0,
|
|
70
|
-
self.sprite.add_animation(name, image, imageDim, tileDim, frames, speed, scale,
|
|
69
|
+
def add_animation(self, name, image, imageDim, tileDim, frames, speed, scale = 1.0, dirrection = 1):
|
|
70
|
+
self.sprite.add_animation(name, image, imageDim, tileDim, frames, speed, scale, False, dirrection)
|
|
71
71
|
self.sprite.__remove__()
|
|
72
72
|
self.sprite.set_worldPos(False)
|
|
73
73
|
|
GameBox/tilemap/_tilemap.py
CHANGED
|
@@ -9,20 +9,6 @@ from ._Editor import _tilemapEditor
|
|
|
9
9
|
|
|
10
10
|
class TileMap:
|
|
11
11
|
def __init__(self, tileSet: str, tileDim: tuple, tileScale: float, mapDim: tuple, mapFill: int, saveFile = None):
|
|
12
|
-
"""
|
|
13
|
-
Constructor for TileMap object.
|
|
14
|
-
|
|
15
|
-
Args:
|
|
16
|
-
tileSet (str): filepath to tileset image
|
|
17
|
-
tileDim (tuple): dimensions of a single tile
|
|
18
|
-
tileScale (float): scale of tiles relative to tileset image
|
|
19
|
-
mapDim (tuple): dimensions of the map
|
|
20
|
-
mapFill (int): default tile id to fill map with
|
|
21
|
-
saveFile (str): filepath to save map to (default is None)
|
|
22
|
-
|
|
23
|
-
Returns:
|
|
24
|
-
None
|
|
25
|
-
"""
|
|
26
12
|
self.tilesetFile = tileSet
|
|
27
13
|
self.mapFile = saveFile
|
|
28
14
|
self.tileDim = (tileDim[0] * tileScale, tileDim[1] * tileScale)
|
GameBox/ui/_basicUI.py
CHANGED
|
@@ -8,58 +8,29 @@ from ..GameLevel_ui._sprites import Sprite_2d
|
|
|
8
8
|
class Image:
|
|
9
9
|
def __init__(self, pos: tuple, image, scale: float = 1.0):
|
|
10
10
|
"""
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
Initialize an Image UI element.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
pos: Tuple (x, y) for the image position
|
|
15
|
+
image: Either a file path (str) or pygame.Surface object
|
|
16
|
+
scale: Scale factor for the image (default: 1.0)
|
|
17
|
+
"""
|
|
18
18
|
#add to game
|
|
19
19
|
self.image = Sprite_2d(pos, image, scale)
|
|
20
20
|
self.image.__remove__()
|
|
21
21
|
Global.game.ui_objs.append(self)
|
|
22
22
|
|
|
23
23
|
def move_by(self, x: int, y: int):
|
|
24
|
-
"""
|
|
25
|
-
Move the image by (x, y) in world space.
|
|
26
|
-
|
|
27
|
-
Args:
|
|
28
|
-
x: int, the x component of the movement
|
|
29
|
-
y: int, the y component of the movement
|
|
30
|
-
"""
|
|
31
24
|
self.image.move_by(x, y)
|
|
32
25
|
|
|
33
26
|
def move_to(self, x: int, y: int):
|
|
34
|
-
"""
|
|
35
|
-
Move the image to (x, y) in world space.
|
|
36
|
-
|
|
37
|
-
Args:
|
|
38
|
-
x: int, the x component of the position
|
|
39
|
-
y: int, the y component of the position
|
|
40
|
-
"""
|
|
41
27
|
self.image.move_to(x, y)
|
|
42
28
|
|
|
43
29
|
def get_pos(self):
|
|
44
|
-
"""
|
|
45
|
-
Get the position of the image in world space.
|
|
46
|
-
|
|
47
|
-
Returns:
|
|
48
|
-
tuple: (x, y) the position of the image
|
|
49
|
-
"""
|
|
50
30
|
return self.image.get_pos()
|
|
51
31
|
|
|
52
32
|
def rescale(self, scale: float):
|
|
53
|
-
"""
|
|
54
|
-
Rescale the image by the given scale.
|
|
55
|
-
|
|
56
|
-
Args:
|
|
57
|
-
scale: float, the scale factor
|
|
58
|
-
"""
|
|
59
33
|
self.image.rescale(scale)
|
|
60
34
|
|
|
61
35
|
def update(self):
|
|
62
|
-
"""
|
|
63
|
-
Update the image by drawing it on the screen.
|
|
64
|
-
"""
|
|
65
36
|
Global.screen.blit(self.image.image, self.image.pos)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: GameBox
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.1
|
|
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
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
GameBox/__init__.py,sha256=HVJfnUcXHAjp4wIR_uz4u9lwLZpiChdvzf6y0aPvkj8,1025
|
|
2
|
+
GameBox/_game.py,sha256=cxlY7skQHK2OXnqgdusXwfc_0hDy7Hu3oq8o5iKzSLU,2252
|
|
3
|
+
GameBox/GameLevel_ui/_Animations.py,sha256=nza-F3Rii6VWAvIkSKNr1CpkJXxq4jLqZcYfb0Sk1hI,1051
|
|
4
|
+
GameBox/GameLevel_ui/_sprites.py,sha256=lRtMuGtd-5kfUPmJ_20j5fOmWdaIhKxfcCdVYM4oazc,5664
|
|
5
|
+
GameBox/basics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
GameBox/basics/_net.py,sha256=65qMVXyILKGE8VnJcW_jxmJ1UxmENktbHvRWaTq5U0A,839
|
|
7
|
+
GameBox/basics/_shapes.py,sha256=Rbkd0lrpxGvbVdwL98_iovFtqB1USI5Qk6umJPR0CIc,1314
|
|
8
|
+
GameBox/basics/cammera.py,sha256=eP7cNkTruZ9CDf94VGTsjgdI4NNnWjN-ilCHgGLYNSs,941
|
|
9
|
+
GameBox/basics/utils.py,sha256=w6H34MhxcNoX58iQtlvbT5-4GXefy3RIMTxZGP9fSxA,432
|
|
10
|
+
GameBox/helpers/_Conditions.py,sha256=FSqwJWL0QBvCQmSyzhL5LtudhP5c-tRzC_8xuQENsGw,1946
|
|
11
|
+
GameBox/helpers/_collisions.py,sha256=b8eBnEYbgYFxQ4m6xpAeAaNkYosbP5xUOIlT40sztBs,4503
|
|
12
|
+
GameBox/helpers/_input.py,sha256=97bPxM5dkonRywOhj11lgHVQVicuLAKYi_w8EPM0Af8,1963
|
|
13
|
+
GameBox/player/_player.py,sha256=HU7iOBoHj5oXJTA-lHmwPZbFt8CXm-IPzK3NWBGzRhM,1872
|
|
14
|
+
GameBox/player/_playerControler.py,sha256=XEb87RFlgLFoXnXqxIS4lpzHN0wywMNCX5y-NIhw0cs,1715
|
|
15
|
+
GameBox/player/_playerPhysics.py,sha256=-6u-TZH_i78bwFMZwCIHP0VnQA0nOlcQtkq07rxwKwg,2919
|
|
16
|
+
GameBox/player/_playerSprite.py,sha256=7j9hqesdOvyyP4jF83VJRbpno_oYgOt31rdYKezVknk,3519
|
|
17
|
+
GameBox/tilemap/_Editor.py,sha256=98JcwAvL6JgSG2S-V-527lwpfzbE-A-BbezCI9EfTyI,1027
|
|
18
|
+
GameBox/tilemap/_collisionDef.py,sha256=VxWcfz3nlhyYI_Hemp-LvC6IDC-YN6wIdRaU8AsgipU,1621
|
|
19
|
+
GameBox/tilemap/_editorBrushes.py,sha256=GFfRV0OB3t9sFb37eO3sB8Cmwyd5i_q64q5IjYlkx1k,7247
|
|
20
|
+
GameBox/tilemap/_tilemap.py,sha256=SEQlokpsUO9zQkLMF-j6amx1FqNeD2eM2CRFj3zCnZ8,3330
|
|
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,,
|
gamebox-0.9.0.dist-info/RECORD
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
GameBox/__init__.py,sha256=HVJfnUcXHAjp4wIR_uz4u9lwLZpiChdvzf6y0aPvkj8,1025
|
|
2
|
-
GameBox/_game.py,sha256=l55gMoNTbFrMBYJzwK8RX8oP414qBtyDik9bmcuexys,1675
|
|
3
|
-
GameBox/GameLevel_ui/_Animations.py,sha256=nza-F3Rii6VWAvIkSKNr1CpkJXxq4jLqZcYfb0Sk1hI,1051
|
|
4
|
-
GameBox/GameLevel_ui/_sprites.py,sha256=BmfTi4_gnP2rlIOH6luG8cJjXwNRArBmyy_0iYrE7I0,8579
|
|
5
|
-
GameBox/basics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
GameBox/basics/_net.py,sha256=zXuw1YkC3Qobx6sAl2u3fvp_ghJsfHem6L59NTmTfRE,802
|
|
7
|
-
GameBox/basics/_shapes.py,sha256=2bSlNMJlRKHSHljmiD7nn9Kh8VEFPHygxzzONGvvgfs,3008
|
|
8
|
-
GameBox/basics/cammera.py,sha256=MPsl-H2hMOfmPPfPiyfT--wGkUSCR1i3ZMo9Qnb9ChE,1895
|
|
9
|
-
GameBox/basics/utils.py,sha256=w6H34MhxcNoX58iQtlvbT5-4GXefy3RIMTxZGP9fSxA,432
|
|
10
|
-
GameBox/helpers/_Conditions.py,sha256=LY0sVuIR_3ZewDDx-Ud9WoM3HFhLh9rR2RaiRSd1Gr4,2350
|
|
11
|
-
GameBox/helpers/_collisions.py,sha256=VJy26jaJOLjnKFD_i5MBhsKg0OHXpqJVcMU0PcACgrI,4414
|
|
12
|
-
GameBox/helpers/_input.py,sha256=KyhqkLykI6czIhvu3BLISmFkbw_6PRzCuK48LVV4zM8,2041
|
|
13
|
-
GameBox/player/_player.py,sha256=GsWAERz9SWRD3qEyBQDLXo85OLEPTP5m_5sI4CHLRL0,2486
|
|
14
|
-
GameBox/player/_playerControler.py,sha256=XEb87RFlgLFoXnXqxIS4lpzHN0wywMNCX5y-NIhw0cs,1715
|
|
15
|
-
GameBox/player/_playerPhysics.py,sha256=-6u-TZH_i78bwFMZwCIHP0VnQA0nOlcQtkq07rxwKwg,2919
|
|
16
|
-
GameBox/player/_playerSprite.py,sha256=4Zhy94TWbsgXQTRM4xwIMHo5YPFmsfb1xjM3dmv207g,3542
|
|
17
|
-
GameBox/tilemap/_Editor.py,sha256=98JcwAvL6JgSG2S-V-527lwpfzbE-A-BbezCI9EfTyI,1027
|
|
18
|
-
GameBox/tilemap/_collisionDef.py,sha256=VxWcfz3nlhyYI_Hemp-LvC6IDC-YN6wIdRaU8AsgipU,1621
|
|
19
|
-
GameBox/tilemap/_editorBrushes.py,sha256=GFfRV0OB3t9sFb37eO3sB8Cmwyd5i_q64q5IjYlkx1k,7247
|
|
20
|
-
GameBox/tilemap/_tilemap.py,sha256=K_L7jNWrmVnnOSrrqj0aasVuJMHsTpScGj3adrnKJC0,3820
|
|
21
|
-
GameBox/ui/_basicUI.py,sha256=gP8jhKo7cHH5GlKNH4DFqEziX9dIv0YxsaoFceteB1k,1778
|
|
22
|
-
gamebox-0.9.0.dist-info/METADATA,sha256=4IQDtldYyMYbzsRyZP8fkj5DWErEL_CYib1nQO8BkEo,1059
|
|
23
|
-
gamebox-0.9.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
24
|
-
gamebox-0.9.0.dist-info/licenses/LICENSE,sha256=gcuuhKKc5-dwvyvHsXjlC9oM6N5gZ6umYbC8ewW1Yvg,35821
|
|
25
|
-
gamebox-0.9.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|