upgraded movement system to slide against walls

This commit is contained in:
ayabusa 2024-10-23 12:04:04 +02:00
parent 093e054aaf
commit ced50f53d4

View File

@ -166,6 +166,10 @@ class Player:
if(game.test_collision(pygame.Rect(new_x-50, new_y-50, 100, 100), game.collisions) == False): if(game.test_collision(pygame.Rect(new_x-50, new_y-50, 100, 100), game.collisions) == False):
self.x = new_x self.x = new_x
self.y = new_y 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: class Game:
def __init__(self): def __init__(self):