generated from mwc/project_game
add a alien target and a shooter to hit it
I am actually really proud that i was able to figure out how to make the alien move in every direction randomly.
This commit is contained in:
15
proposal.md/asteroid_spawner.py
Normal file
15
proposal.md/asteroid_spawner.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from random import randint
|
||||
from asteroid 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
|
||||
Reference in New Issue
Block a user