def reset(self, stage=None): self.counter.reset() R.stop_music() config.reset() self.camera.set_speed(0.2) stage_id = stage if stage != None else 1 if stage_id == 1: self.stage = Stage1(self) elif stage_id == 2: self.stage = Stage2(self) elif stage_id == 3: self.stage = Stage3(self) elif stage_id == 4: self.stage = Stage4(self) elif stage_id == 5: self.stage = Stage5(self) self.player.jump(v=500) self.camera.set_speed(0.05) self.timer.restart() self.is_pause = False self.is_stop = False self.is_game_over = False self.is_clear = False self.level = DEFAULT_LEVEL self.ranking_frame.hide() self.start_counter = StartCounter(self)
def jump(self, v=1500): self.v = v R.play_sound("jump") for item in self.items: item.on_jump(self)
def trigger(self, env, player): x = player.get_position().x x = x if player.direction == 0 else x + 60 y = player.get_position().y + 30 env.add_bullet(BBWaveBullet(env, (x, y), 90, speed=2000)) R.play_sound("wave_gun")
def update(self, delta): self.progress += delta number = 3 - int(self.progress) if self.number != number and number > 0: R.play_sound("count") self.number = number
def active(self, player, sound=True): if sound: R.play_sound("get_item") player.add_item(self) self.is_touchable = False self.is_visible = False self.environment.counter.inc_item_active(self.get_name())
def trigger(self, env, player): x = player.get_position().x x = x if player.direction == 0 else x + 60 y = player.get_position().y + 30 env.add_bullet(BBBullet(env, (x, y), 90)) env.add_bullet(BBBullet(env, (x, y), 70)) env.add_bullet(BBBullet(env, (x, y), 110)) R.play_sound("shotgun")
def __init__(self, stages, position=(0, 0), width=400): self.stages = stages self.position = position self.width = width self.cursor = 0 self.option_background = R.get_image("menu_option") self.lock_image = R.get_image("lock") self._init_cover()
def __init__(self, environment): super().__init__(environment) self.pattern_gen = Stage3.PatternGen(environment) self.background = R.get_image("stage3_bg") self.music = "stage3" self.id = 3
def __init__(self, environment, position): super().__init__(environment, position) self.image = pygame.transform.scale(R.get_image("platform1"), self.size.int()) self.direction = 1 self.progress = 0.0 self.speed = 100
def __init__(self, environment): super().__init__(environment) self.pattern_gen = Stage5.PatternGen(environment) self.background = R.get_image("stage5_bg") self.music = "stage5" self.id = 5 config.G = 999999
def __init__(self, environment, position): super().__init__(environment, position, 'Slime') self.is_damage = False self.damage_progress = 0.0 self.state_progress = 0.0 self.images = {} self._init_images(R.get_sprite_sheet("slime"))
def update(self, delta): if self.start_counter.is_finished(): R.play_music(self.stage.get_music()) if self.is_clear or self.is_game_over: self.ranking_frame.update(delta) return if self.is_pause or self.is_stop: return if not self.start_counter.is_finished(): self.start_counter.update(delta) return self.timer.update() self.stage.update(self.level) for p in self.stage.get_platforms(): p.update(delta) for item in self.stage.get_items(): item.update(delta) for m in self.stage.get_monsters(): m.update(delta) for b in self.bullets: b.update(delta) self.player.update(delta) current_level = int(self.player.pos().y / config.LEVEL_HEIGHT) if current_level > self.level: self.level = current_level self.camera.move((self.level - DEFAULT_LEVEL - 2) * config.LEVEL_HEIGHT) self.camera.update(delta) self.counter.update_level(self.level) self.counter.update_time(self.timer.get_time()) self._check_player(delta) self._check_mission()
def __init__(self, size, position): self.size = size self.position = position self.is_new_record = False self.surface = pygame.Surface(self.size) self.background = pygame.transform.scale(R.get_image("black_board"), self.size) self.reset()
def on_key_down(self, key): if key == pygame.K_DOWN: R.play_sound("select") self.selector.next() if key == pygame.K_UP: R.play_sound("select") self.selector.prev() if key == pygame.K_SPACE or key == pygame.K_RETURN: R.play_sound("confirm") self.select_stage(self.selector.get_selected_stage()) if key == pygame.K_BACKSPACE: R.play_sound("go_back") self.start_and_reset_scene("home")
def __init__(self, size): self.size = size self.direction = RIGHT self.is_jumping = False self.is_attacking = False self.is_unbeatable = False self.jumping_progress = 0 self.falling_progress = 0 self.attacking_progress = 0 self.images = {} self._init_images(R.get_sprite_sheet("ninja"))
def __init__(self, scene, position=(0, 0)): self.scene = scene self.size = (600, 900) self.position = position self.is_hidden = True self.surface = pygame.Surface(self.size) self.ranking_list = RankingList((550, 600), (25, 150)) self.option_selector = OptionSelector((self.size[0], 50), (0, 750)) self.db = Database() self.background = R.get_image("ranking_bg") self.reset()
def die(self): self.is_touchable = False self.is_damage = True self.damage_progress = 0.0 R.play_sound("slime_death")
def setup(self): self.background = Background(R.get_image("home_bg"), self.get_bound()) self.information_ui = Information()
def __init__(self, environment, position): super().__init__(environment, position) self.image = pygame.transform.scale(R.get_image("platform1"), self.size.int()).convert_alpha() self.image.fill((255, 255, 255, 120), None, pygame.BLEND_RGBA_MULT)
def __init__(self, environment, position): super().__init__(environment, position, 'Gravity Reducer') self.timer = Timer() self.image = pygame.transform.scale(R.get_image("gravity_reducer"), self.size.int())
def on_steped(self, player): super().on_steped(player) R.play_sound("slime_step")
def __init__(self, environment, position): super().__init__(environment, position, 'BB Wavegun') self.image = pygame.transform.scale(R.get_image("bb_wavegun"), self.size.int())
def __init__(self): self.title = R.get_image("title") self.bliping_progress = 0.0
def _load_resources(self): R.load()
def reset(self, params): db = Database() stages = db.get_stages() self.selector = StageSelector(stages, (100, 100), 480) R.play_music("home")
def __init__(self, environment, position): super().__init__(environment, position, 'Sprint shoes') self.image = pygame.transform.scale(R.get_image("spring_shoes"), self.size.int())
def setup(self): self.background = R.get_image("menu_bg")
def reset(self, params={}): R.play_music("home")
def __init__(self, environment, position): super().__init__(environment, position) self.image = pygame.transform.scale(R.get_image("platform2"), self.size.int()).convert_alpha()
def on_key_down(self, key): if key == pygame.K_SPACE: R.play_sound("confirm") self.start_and_reset_scene("menu")