Files
project_game/spawner.py
jwberent 4ff9dbd231 This is my fourth commit. I fixed the issue I was having with the cars breaking apart.
I am very happy that I was able to fix this problem.  I had to email you about this problem and you showed me how this could be completed by creating another class.  This makes so much sense now as you could spawn one part of the car right behind the other to give the illusion that it is one car.
I learned the new skill of using 2 different classes together when making the car 2 wide.
2025-12-06 22:54:28 -05:00

19 lines
560 B
Python

from random import randint
from path import Car
from car_back import CarBack
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):
y = randint(1, height-1)
car3 = Car((0, y))
car3.next = CarBack((1,y))
game.add_agent(car3)
game.add_agent(car3.next)
def should_spawn_car(self, turn_number):
return randint(0, 1000) < turn_number