From ced50f53d433721465354c989038223e53974022 Mon Sep 17 00:00:00 2001 From: ayabusa Date: Wed, 23 Oct 2024 12:04:04 +0200 Subject: [PATCH] upgraded movement system to slide against walls --- game.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/game.py b/game.py index 7efc497..12ed342 100644 --- a/game.py +++ b/game.py @@ -166,6 +166,10 @@ class Player: if(game.test_collision(pygame.Rect(new_x-50, new_y-50, 100, 100), game.collisions) == False): self.x = new_x self.y = new_y + elif(game.test_collision(pygame.Rect(self.x-50, new_y-50, 100, 100), game.collisions) == False): + self.y = new_y + elif(game.test_collision(pygame.Rect(new_x-50, self.y-50, 100, 100), game.collisions) == False): + self.x = new_x class Game: def __init__(self):