def test_simulate(): snake = Snake() snake.simulate() assert type(snake.head_location[0]) is int assert type(snake.head_location[1]) is int for i, val1 in enumerate(snake.snake_matrix): for j, val2 in enumerate(snake.snake_matrix[i]): assert type(snake.snake_matrix[i][j]) is int
snake.right() elif event.key == pygame.K_UP and not snake.turned: snake.up() elif event.key == pygame.K_DOWN and not snake.turned: snake.down() elif event.key == pygame.K_q: """Restart Game""" del snake snake = Snake() HUD.reset_score() spider.reset() screen.fill(WHITE) # --- Game logic if snake.alive: snake.simulate() spider.simulate() if snake.head_location == food.location: snake.eat() food.consumed() HUD.add_score(DIFFICULTY) if snake.head_location == spider.location: HUD.add_score(spider.score()) snake.eat() spider.consumed() # --- Drawing if snake.alive: food.draw(screen) snake.draw(screen) spider.draw(screen)