generated from mwc/project_game
A recent success that I am proud of is that I was able to give the player the ability to move up, down, left, and right. When implementing the ability to move up and down it seemed that the code was opposite of what I expected it to be. I was able to figure out how to implement it the correct way.
15 lines
466 B
Python
15 lines
466 B
Python
from random import randint
|
|
from path import Asteroid
|
|
|
|
class AsteroidSpawner:
|
|
display = False
|
|
|
|
def play_turn(self, game):
|
|
width, height = game.board_size
|
|
game.state['score'] += 1
|
|
if self.should_spawn_asteroid(game.turn_number):
|
|
asteroid = Asteroid((randint(0, width - 1), 0))
|
|
game.add_agent(asteroid)
|
|
|
|
def should_spawn_asteroid(self, turn_number):
|
|
return randint(0, 1000) < turn_number |