diff --git a/__pycache__/path.cpython-312.pyc b/__pycache__/path.cpython-312.pyc index 5ac2573..4f9af41 100644 Binary files a/__pycache__/path.cpython-312.pyc and b/__pycache__/path.cpython-312.pyc differ diff --git a/__pycache__/person.cpython-312.pyc b/__pycache__/person.cpython-312.pyc index 7d36530..fc622cd 100644 Binary files a/__pycache__/person.cpython-312.pyc and b/__pycache__/person.cpython-312.pyc differ diff --git a/__pycache__/spawner.cpython-312.pyc b/__pycache__/spawner.cpython-312.pyc index 88fd063..94e7506 100644 Binary files a/__pycache__/spawner.cpython-312.pyc and b/__pycache__/spawner.cpython-312.pyc differ diff --git a/new.py b/new.py index 5846492..49ca655 100644 --- a/new.py +++ b/new.py @@ -1,9 +1,10 @@ from retro.game import Game -from person import Spaceship -from spawner import AsteroidSpawner +from person import Person +from spawner import CarSpawner +from path import Car board_size = (25, 25) -ship = Spaceship(board_size) -spawner = AsteroidSpawner() -game = Game([ship, spawner], {"score": 0,"lives":5}, board_size=board_size) +person = Person(board_size) +spawner = CarSpawner() +game = Game([person,spawner], {"score": 0,"lives":3}, board_size=board_size,color="black_on_white") game.play() \ No newline at end of file diff --git a/path.py b/path.py index 547fef0..de0da70 100644 --- a/path.py +++ b/path.py @@ -1,5 +1,5 @@ -class Asteroid: - character = 'O' +class Car: + character = 'OO' def __init__(self, position): self.position = position @@ -23,16 +23,28 @@ class Asteroid: # self.position = new_position def play_turn(self, game): - lives = 5 + lives = 3 width, height = game.board_size if game.turn_number % 2 == 0: x, y = self.position - if y == height - 1: + if x == width - 1: game.remove_agent(self) else: - ship = game.get_agent_by_name('ship') - new_position = (x, y + 1) - if new_position == ship.position: + person = game.get_agent_by_name('person') + new_position = (x+1, y) + + # if game.turn_number % 2 == 1: + # x, y = self.position + #if x == width - 1: + # game.remove_agent(self) + # else: + # person = game.get_agent_by_name('person') + # new_position = (x-1, y) + + + + + if new_position == person.position: lives = lives-1 game.state["lives"] -=1 if game.state["lives"] == 0: diff --git a/person.py b/person.py index a473abf..5ba17e5 100644 --- a/person.py +++ b/person.py @@ -1,5 +1,5 @@ -class Spaceship: - name = "ship" +class Person: + name = "person" character = '^' def __init__(self, board_size): diff --git a/spawner.py b/spawner.py index 884e579..0160ce7 100644 --- a/spawner.py +++ b/spawner.py @@ -1,15 +1,16 @@ from random import randint -from path import Asteroid +from path import Car -class AsteroidSpawner: +class CarSpawner: 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) + if self.should_spawn_car(game.turn_number): + #car = Car((randint(0, width - 1), 0)) + car = Car((0, randint(0, height - 1))) + game.add_agent(car) - def should_spawn_asteroid(self, turn_number): + def should_spawn_car(self, turn_number): return randint(0, 1000) < turn_number \ No newline at end of file