diff --git a/1_snake_game/3_moving_block_and_timer.py b/1_snake_game/3_moving_block_and_timer.py index 6dc9ca0..62e5209 100644 --- a/1_snake_game/3_moving_block_and_timer.py +++ b/1_snake_game/3_moving_block_and_timer.py @@ -4,39 +4,39 @@ from pygame.locals import * import time + class Snake: def __init__(self, surface): self.parent_screen = surface self.block = pygame.image.load("resources/block.jpg").convert() self.x = 100 self.y = 100 - self.direction = 'down' + self.direction = "down" def move_left(self): - self.direction = 'left' + self.direction = "left" def move_right(self): - self.direction = 'right' + self.direction = "right" def move_up(self): - self.direction = 'up' + self.direction = "up" def move_down(self): - self.direction = 'down' + self.direction = "down" def walk(self): - if self.direction == 'left': + if self.direction == "left": self.x -= 10 - if self.direction == 'right': + if self.direction == "right": self.x += 10 - if self.direction == 'up': + if self.direction == "up": self.y -= 10 - if self.direction == 'down': + if self.direction == "down": self.y += 10 self.draw() - def draw(self): self.parent_screen.fill((110, 110, 5)) @@ -77,10 +77,9 @@ def run(self): self.snake.walk() - time.sleep(.2) + time.sleep(0.2) + -if __name__ == '__main__': +if __name__ == "__main__": game = Game() game.run() - -