feat(tractor): implement tank controls
This commit is contained in:
parent
a1d4895a7a
commit
a7db089ce4
@ -25,19 +25,19 @@ class Tractor(pygame.sprite.Sprite):
|
|||||||
surface.blit(self.image, self.rect)
|
surface.blit(self.image, self.rect)
|
||||||
|
|
||||||
|
|
||||||
def move(self, direction):
|
def move(self):
|
||||||
if direction == "up" and self.rect.y > 0:
|
if self.direction == "north" and self.rect.y > 0:
|
||||||
self.rect.y -= TILE_SIZE
|
self.rect.y -= TILE_SIZE
|
||||||
self.log_info()
|
self.log_info()
|
||||||
elif direction == "down" and self.rect.y < 15 * TILE_SIZE:
|
elif self.direction == "south" and self.rect.y < 15 * TILE_SIZE:
|
||||||
self.rect.y += TILE_SIZE
|
self.rect.y += TILE_SIZE
|
||||||
self.log_info()
|
self.log_info()
|
||||||
elif direction == "left" and self.rect.x > 0:
|
elif self.direction == "west" and self.rect.x > 0:
|
||||||
self.rect.x -= TILE_SIZE
|
self.rect.x -= TILE_SIZE
|
||||||
self.log_info()
|
self.log_info()
|
||||||
elif direction == "right" and self.rect.x < 15 * TILE_SIZE:
|
elif self.direction == "east" and self.rect.x < 15 * TILE_SIZE:
|
||||||
self.rect.x += TILE_SIZE
|
self.rect.x += TILE_SIZE
|
||||||
self.log_info()
|
self.log_info()
|
||||||
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
@ -47,9 +47,7 @@ class Tractor(pygame.sprite.Sprite):
|
|||||||
if keys[pygame.K_RIGHT]:
|
if keys[pygame.K_RIGHT]:
|
||||||
self.rotate('right')
|
self.rotate('right')
|
||||||
if keys[pygame.K_UP]:
|
if keys[pygame.K_UP]:
|
||||||
self.move('up')
|
self.move()
|
||||||
if keys[pygame.K_DOWN]:
|
|
||||||
self.move('down')
|
|
||||||
if keys[pygame.K_r]:
|
if keys[pygame.K_r]:
|
||||||
self.water = 50
|
self.water = 50
|
||||||
print(f"💧 replenished water level: {self.water} litres\n")
|
print(f"💧 replenished water level: {self.water} litres\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user