def create_standard_world(): player = Player(Ship(max_speed=5, cargo=3, acceleration=1, decceleration=3), speed_x=0, speed_y=0, x=10, y=360, nb_pop=0, money=0, nb_missil=1) w = World([MapImage(), player], screen, player) w.add_starting_harbour( StartingHarbour(Constants.COAST_OFFSET() - 10, 100, 25, 1, player)) w.add_starting_harbour( StartingHarbour(Constants.COAST_OFFSET() - 2, 200, 12, 2, player)) w.add_starting_harbour( StartingHarbour(Constants.COAST_OFFSET() - 5, 560, 5, 3, player)) w.add_ending_harbour( EndingHarbour(Constants.SCREEN_WIDTH() - Constants.COAST_OFFSET() - 50, 180, 3, player)) w.add_ending_harbour( EndingHarbour(Constants.SCREEN_WIDTH() - Constants.COAST_OFFSET() - 55, 500, 3, player)) w.add_sprite(BuySpeed(800, 500, player)) w.add_sprite(BuyCargo(654, 300, player)) w.add_sprite(BuyMissile(200, 200, player)) return w
def object_advance(self): if self.rect.x < Constants.COAST_OFFSET(): self.rect.x = Constants.COAST_OFFSET() self.set_speed_x(0) if self.rect.x > Constants.SCREEN_WIDTH( ) - self.rect.width - Constants.COAST_OFFSET(): self.rect.x = Constants.SCREEN_WIDTH( ) - self.rect.width - Constants.COAST_OFFSET() self.set_speed_x(0) self.rect.x += self.speed_x if self.rect.y < 0: self.rect.y = 0 self.set_speed_y(0) if self.rect.y > Constants.GAME_AREA_HEIGHT() - self.rect.height: self.rect.y = Constants.GAME_AREA_HEIGHT() - self.rect.height self.set_speed_y(0) self.rect.y += self.speed_y