Adjust map boundaries and player movement constraints to prevent off-screen issues

This commit is contained in:
Félix MARQUET
2025-03-27 14:41:57 +01:00
parent 908fc76331
commit c5203b094a
2 changed files with 16 additions and 6 deletions

View File

@@ -8,9 +8,9 @@
"ground": [
{
"id": "main_ground",
"x": 0,
"x": -1000,
"y": 780,
"width": 2400,
"width": 1800,
"height": 200,
"texture": "assets/map/platform/grass_texture.jpg"
},
@@ -21,6 +21,14 @@
"width": 200,
"height": 20,
"is_hole": true
},
{
"id": "main_ground_2",
"x": 1000,
"y": 900,
"width": 1800,
"height": 200,
"texture": "assets/map/platform/grass_texture.jpg"
}
],

View File

@@ -124,10 +124,12 @@ class Player(Entity):
pressed_keys = pygame.key.get_pressed()
if pressed_keys[K_q]:
self.acc.x = -ACC
self.moving = True
if pressed_keys[K_a]:
self.dash(-ACC)
# Check if X is > 0 to prevent player from going off screen
if self.pos.x > 0:
self.acc.x = -ACC
self.moving = True
if pressed_keys[K_a]:
self.dash(-ACC)
if pressed_keys[K_d]:
self.acc.x = ACC
self.moving = True