generated from mwc/project_game
Im proud im understanding what im doing
Im stuck on testing my code Im worried my code isnt doing what i want it to but i cant test it to see
This commit is contained in:
15
obstacle_spawner.py
Normal file
15
obstacle_spawner.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from random import randint
|
||||
from obstacle import Obstacle
|
||||
|
||||
class ObstacleSpawner:
|
||||
display = False
|
||||
|
||||
def play_turn(self, game):
|
||||
width, height = game.board_size
|
||||
game.state['score'] += 1
|
||||
if self.should_spawn_obstacle(game.turn_number):
|
||||
obstacle = Obstacle((randint(0, width - 1), 0))
|
||||
game.add_agent(obstacle)
|
||||
|
||||
def should_spawn_obstacle(self, turn_number):
|
||||
return randint(0, 1000) < turn_number
|
||||
Reference in New Issue
Block a user