class Game: def __init__(self, resources: Resources) -> None: self.camera = Vector2d(0, 0) self.stopwatch = Stopwatch(resources) # Objective 4: Create a Player # YOUR CODE HERE... # Objective 5: Create a Map # YOUR CODE HERE... def update(self, controller: Controller) -> None: if controller.has_input(Input.RESTART): self.stopwatch.reset() # Objective 4: Put the player back at the start # YOUR CODE HERE... # Objective 6: Call the player update method # YOUR CODE HERE... # Objective 7: Call the move_camera function with a focus on the player position # YOUR CODE HERE... # Objective 8: Update the stopwatch according to the player tile # YOUR CODE HERE... def render(self, renderer: Renderer) -> None: # Objective 4: Render the player # YOUR CODE HERE... # Objective 5: Render the tilemap # YOUR CODE HERE... self.stopwatch.render(renderer)
class Game: def __init__(self, resources: Resources) -> None: self.camera = Vector2d(0, 0) self.stopwatch = Stopwatch(resources) # Objective 4: Create a Player self.player = Player(resources) # Objective 5: Create a Map self.map = Map(resources) def update(self, controller: Controller) -> None: if controller.has_input(Input.RESTART): self.stopwatch.reset() # Objective 4: Put the player back at the start self.player.restart() # Objective 6: Call the player update method # YOUR CODE HERE... self.player.update(controller, self.map) # Objective 7: Call the move_camera function with a focus on the player position # YOUR CODE HERE... move_camera(self.camera, self.player.pos) # Objective 8: Update the stopwatch according to the player tile # YOUR CODE HERE... value = self.map.get_tile(self.player.pos) if value == Tile.START: self.stopwatch.start() elif value == Tile.FINISH: self.stopwatch.stop() else: self.stopwatch.step() def render(self, renderer: Renderer) -> None: # Objective 4: Render the player # YOUR CODE HERE... self.player.render(renderer, self.camera) # Objective 5: Render the tilemap # YOUR CODE HERE... self.map.render(renderer, self.camera) self.stopwatch.render(renderer)