def game_update(self, t): if self.round_get_has_started(): ships = [] for obj in self.world.getObjectsInArea(self.midpoint, self.__objective_radii[-1] + 28): # add the ship radius so it looks like you get points if you overlap if isinstance(obj, Ship): ships.append(obj) # decrease the time for ships that are moving slowly in the bubble for ship in ships: if ship.body.velocity.length < self.__objective_velocity: ship.player.time += t if ship.player.time >= self.__objective_time: # slowed enough, figure out how many points to give x = 0 for radius in self.__objective_radii: if in_circle(self.midpoint, radius + 28, ship.body.position): break x += 1 ship.body.position = self.player_get_start_position() ship.player.update_score(self.__objective_points[x]) ship.player.time = 0 elif self.__reset_timer: ship.player.time = 0 super(FindTheMiddleGame, self).game_update(t)
def game_update(self, t): if self.round_get_has_started(): ships = [] for obj in self.world.getObjectsInArea( self.midpoint, self.__objective_radii[-1] + 28 ): # add the ship radius so it looks like you get points if you overlap if isinstance(obj, Ship): ships.append(obj) # decrease the time for ships that are moving slowly in the bubble for ship in ships: if ship.body.velocity.length < self.__objective_velocity: ship.player.time += t if ship.player.time >= self.__objective_time: # slowed enough, figure out how many points to give x = 0 for radius in self.__objective_radii: if in_circle(self.midpoint, radius + 28, ship.body.position): break x += 1 ship.body.position = self.player_get_start_position() ship.player.update_score(self.__objective_points[x]) ship.player.time = 0 elif self.__reset_timer: ship.player.time = 0 super(FindTheMiddleGame, self).game_update(t)
def player_get_start_position(self, force=False): # make sure player doesn't spawn in middle pos = (random.randint(50, self.world.width - 50), random.randint(50, self.world.height - 50)) x = 0 while (len(self.world.getObjectsInArea(pos, 75)) > 0 or in_circle(self.midpoint, self.__objective_radii[-1], pos)) and x < 15: x += 1 pos = (random.randint(50, self.world.width - 50), random.randint(50, self.world.height - 50)) return pos