generated from mwc/project_game
I am getting very close to finishing the project. I was having a problem where I made the symbol for the cars 'OO' and only one of the 'O' was leaving the screen when it made it to the far right of the screen. I emailed you and you said to only make the symbol 'O' and spawn 2 right next to each other. I figured out how to do this by myself but am now trying to figure out why they are breaking apart.
24 lines
760 B
Python
24 lines
760 B
Python
from random import randint
|
|
from path import Car
|
|
|
|
class CarSpawner:
|
|
display = False
|
|
|
|
def play_turn(self, game):
|
|
width, height = game.board_size
|
|
game.state['score'] += 1
|
|
if self.should_spawn_car(game.turn_number):
|
|
#car = Car((randint(0, width - 1), 0))
|
|
|
|
#car = Car((0, randint(0, height - 1)))
|
|
#car2 = Car((30,randint(0, height - 1)))
|
|
#game.add_agent(car)
|
|
#game.add_agent(car2)
|
|
y = randint(0, height - 1)
|
|
car3 = Car((0, y))
|
|
car4 = Car((1,y))
|
|
game.add_agent(car3)
|
|
game.add_agent(car4)
|
|
|
|
def should_spawn_car(self, turn_number):
|
|
return randint(0, 1000) < turn_number |