mirror of
https://github.com/BreizhHardware/project_sanic.git
synced 2026-01-18 16:47:25 +01:00
Adjust map boundaries and player movement constraints to prevent off-screen issues
This commit is contained in:
@@ -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"
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user