fix(tractor): prevent tractor from moving off board
This commit is contained in:
parent
8dceac3ebe
commit
af87ff2475
@ -23,13 +23,13 @@ class Tractor(pygame.sprite.Sprite):
|
||||
load_dotenv(find_dotenv())
|
||||
TILE_SIZE = int(os.getenv("TILE_SIZE"))
|
||||
|
||||
if direction == "up":
|
||||
if direction == "up" and self.rect.y > 0:
|
||||
self.rect.y -= TILE_SIZE
|
||||
elif direction == "down":
|
||||
elif direction == "down" and self.rect.y < 15 * TILE_SIZE:
|
||||
self.rect.y += TILE_SIZE
|
||||
elif direction == "left":
|
||||
elif direction == "left" and self.rect.x > 0:
|
||||
self.rect.x -= TILE_SIZE
|
||||
elif direction == "right":
|
||||
elif direction == "right" and self.rect.x < 15 * TILE_SIZE:
|
||||
self.rect.x += TILE_SIZE
|
||||
|
||||
def update(self):
|
||||
|
Loading…
Reference in New Issue
Block a user