Parcourir la source

fluidification des mouvements en bordure de monde

Hvrnbi il y a 2 semaines
Parent
commit
e2cd30da8b
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 12 0
      player.py

+ 12 - 0
player.py

@@ -48,6 +48,9 @@ class Player:
                         self.y -= self.world.gap // 2 + self.world.tile_height // 2
                         self.next_move = "down"
                         self.picture = PLAYER_LD
+                    else:
+                        self.next_move = "down"
+                        self.move("left")
 
                 elif self.next_move == "down":
                     if self.y + self.world.gap // 2 + self.world.tile_height // 2 <= self.world.bottom_border:
@@ -55,6 +58,9 @@ class Player:
                         self.y += self.world.gap // 2 + self.world.tile_height // 2
                         self.next_move = "up"
                         self.picture = PLAYER_LU
+                    else:
+                        self.next_move = "up"
+                        self.move("left")
 
         elif direction == "right":
             if self.x + self.world.gap + 3 * self.world.tile_width // 4 <= self.world.right_border:
@@ -64,6 +70,9 @@ class Player:
                         self.y -= self.world.gap // 2 + self.world.tile_height // 2
                         self.next_move = "down"
                         self.picture = PLAYER_RD
+                    else:
+                        self.next_move = "down"
+                        self.move("right")
 
                 elif self.next_move == "down":
                     if self.y + self.world.gap // 2 + self.world.tile_height // 2 <= self.world.bottom_border:
@@ -71,4 +80,7 @@ class Player:
                         self.y += self.world.gap // 2 + self.world.tile_height // 2
                         self.next_move = "up"
                         self.picture = PLAYER_RU
+                    else:
+                        self.next_move = "up"
+                        self.move("right")