def display_text(self): temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Nova!').image help_bubble = infobubble.InfoBubble(temp_image, self.object_collided_with, 1.5 * FRAMES_PER_SECOND) help_bubble.offset = vector.Vector2d(0.0, -100.0) self.text_group.add(help_bubble)
def die(self): if self.dying == 0: death_type = int(random.random() * 3) if death_type == 0: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Blast!').image utility.play_sound(self.death_sound[0], OW_CHANNEL) elif death_type == 1: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Oh No!').image utility.play_sound(self.death_sound[1], OW_CHANNEL) elif death_type == 2: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Bother!').image utility.play_sound(self.death_sound[2], OW_CHANNEL) self.animation_list.play('Die') self.bounds = -1000, -1000, SCREEN_WIDTH + 1000, SCREEN_HEIGHT + 32 self.bound_style = BOUND_STYLE_CUSTOM help_bubble = infobubble.InfoBubble(temp_image, self, 5 * FRAMES_PER_SECOND) help_bubble.offset = vector.Vector2d(0.0, -100.0) self.bullet_group.add(help_bubble) self.dying += 1 if settings_list[PARTICLES] and not self.dying % 2: puffs_to_create = 4 while puffs_to_create: puffs_to_create -= 1 temp_puff = particle.SmokeParticle(self.position, (1, 0)) temp_puff.velocity.set_angle(359 * random.random()) self.effects_group.add(temp_puff)
def increment_score_no_text(self, value): self.score += value self.score_board.set_text(self.score) if self.score > self.next_bonus: utility.play_sound(self.extraLifeSound, OW_CHANNEL) temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Extra Life!').image help_bubble = infobubble.InfoBubble(temp_image, self, 1.5 * FRAMES_PER_SECOND) help_bubble.offset = vector.Vector2d(0.0, -100.0) self.effects_group.add(help_bubble) self.lives += 1 self.life_board.set_text('x' + str(self.lives)) self.next_bonus += 50000
def load_level(self): if self.done: return utility.fade_music() utility.play_music(self.music, True) self.stage = 0 self.pause_spawning = 3 * FRAMES_PER_SECOND self.player.bullet_bonus = 0 self.player.reflect_bonus = 0 self.powerup_group.empty() self.enemy_group.empty() self.effects_group.empty() # Display Level text display_name = text.Text(FONT_PATH, 64, FONT_COLOR, self.world_name, 90) display_name.set_alignment(CENTER_MIDDLE) display_name.position = vector.Vector2d( (SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)) self.group_list[TEXT_GROUP].add(display_name) display_level = text.Text(FONT_PATH, 32, FONT_COLOR, 'Level ' + str(self.level + 1), 90) display_level.position = vector.Vector2d( (SCREEN_WIDTH / 2, SCREEN_HEIGHT * (2.0 / 3.0))) display_level.set_alignment(CENTER_MIDDLE) self.group_list[TEXT_GROUP].add(display_level) # Reset all information for the new level self.enemy_list = [] self.load_stage() utility.play_sound(self.get_ready_sound, OW_CHANNEL) temp_image = text.TextSurface(FONT_PATH, 36, FONT_COLOR, 'Get Ready...').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.offset = vector.Vector2d(0.0, -100.0) self.effects_group.add(help_bubble)
def increment_score(self, value, textPosition, text_group): if self.combo_bonus and value <= 250: self.combo_bonus += int(.2 * FRAMES_PER_SECOND) self.combo_kills += 1 temp_image = text.Text(FONT_PATH, 30, FONT_COLOR, 'x' + str(self.combo_kills) + '!').image help_bubble = infobubble.InfoBubble(temp_image, self, 0.5 * FRAMES_PER_SECOND) help_bubble.offset = vector.Vector2d(0.0, -100.0) self.bullet_group.add(help_bubble) if self.point_bonus: value *= 2 temp_text = text.Text(FONT_PATH, 36, FONT_COLOR, str(value), 15) temp_text.set_alignment(CENTER_MIDDLE) temp_text.position = vector.Vector2d(textPosition) text_group.add(temp_text) self.score += value self.score_board.set_text(self.score) if self.score >= self.next_bonus: utility.play_sound(self.extraLifeSound, OW_CHANNEL) temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Extra Life!').image help_bubble = infobubble.InfoBubble(temp_image, self, 1.5 * FRAMES_PER_SECOND) help_bubble.offset = vector.Vector2d(0.0, -100.0) text_group.add(help_bubble) self.lives += 1 self.life_board.set_text('x' + str(self.lives)) self.next_bonus += 50000
def actor_update(self): if self.lives <= 0: self.active = False self.velocity -= vector.Vector2d(0.0, -0.3) self.die() return if not self.damage_bonus: self.bullet_damage = 1 if not self.reflect_bonus: self.bullet_bound_style = BOUND_STYLE_KILL self.bullet_collide_style = COLLIDE_STYLE_HURT if not self.fast_shot: self.reset_fire_timer = self.default_fire_timer if self.point_bonus: self.point_bonus -= 1 if self.damage_bonus: self.damage_bonus -= 1 if self.reflect_bonus: self.reflect_bonus -= 1 if self.dual_shot: self.dual_shot -= 1 if self.stun_timer: self.stun_timer -= 1 if self.fast_shot: self.fast_shot -= 1 if self.combo_bonus: self.combo_bonus -= 1 if not self.combo_bonus: combo_counter = 0 bonus_points = 0 while combo_counter <= self.combo_kills: combo_counter += 1 bonus_points += combo_counter * 25 self.increment_score_no_text(bonus_points) temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Combo Points:' + str(bonus_points) + '!').image help_bubble = infobubble.InfoBubble(temp_image, self, 1.5 * FRAMES_PER_SECOND) help_bubble.offset = vector.Vector2d(0.0, -100.0) self.bullet_group.add(help_bubble) self.combo_kills = 0 self.fire_timer -= 1 self.velocity *= .95 if not self.active: self.active = True if not self.fire_timer: self.animation_list.stop('Idle', self.animation_list.current_frame) if self.stun_timer: self.animation_list.play('HurtIdle', self.animation_list.current_frame)
def update(self): if self.boss_dead: self.time_after_boss += 1 if self.default_spawn_rate: if not self.moono_spawn_rate: self.moono_spawn_rate = self.default_spawn_rate self.spawn_moono() self.moono_spawn_rate -= 1 if self.new_moono.health <= 0: self.moono_dead = True if self.current_step == 0: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Welcome to the tutorial!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.current_step += 1 self.timer = 0 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 1: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Use your mouse to move.').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 5 * FRAMES_PER_SECOND and self.current_step == 2: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Notice the stars that you shoot?').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 3: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'When moving you shoot stars.').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 4: self.spawn_moono('balloon') temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Oh no! Its a Moono!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 5: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Attack with your stars!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 6: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Moonos hurt you when they touch you.').image self.timer -= 1 self.moono_dead = False help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 7: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Did you get the Balloon?').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 8: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Collect balloons for bonus points!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 9: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Balloons always help you get more points.').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 10: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Points are important!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 11: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Every 50,000 points you get an extra life!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 12: self.spawn_baake() temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Oh bother! It's Baake.").image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 13: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Baakes don't hurt you...").image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 14: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, '...but they do love to get in the way!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 15: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Its usually best to stay away from Baake.').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 16: self.spawn_moono('reflect') temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Blast, another Moono!').image self.moono_dead = False self.timer -= 1 help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 17: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Did you pickup that powerup gem?').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 18: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Gems change how you attack.').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 19: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, "These effects don't last long...").image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 20: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, '...but they do stack!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 21: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'So pick up as many as you can!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 22: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'It is important to make use of gems').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 23: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'They can really help you out!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 24: self.default_spawn_rate = 2.5 * FRAMES_PER_SECOND self.mass_attack = True self.timer = 0 self.current_step += 1 if self.current_step == 25: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "They're attacking en masse!").image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 26: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Try moving slowly towards them.').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 27: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'You can better control your shots.').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 28: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'This can really increase your chances!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 3 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 4 * FRAMES_PER_SECOND and self.current_step == 29: self.spawn_boss() self.boss_fight = True temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Oh no! Its a boss!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 30: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Kill the moonos that spawn.').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer >= 3 * FRAMES_PER_SECOND and self.current_step == 31: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Some of them will drop a nova.').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer == 3 * FRAMES_PER_SECOND and self.current_step == 32: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, 'Use the nova when the boss is near').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.timer == 3 * FRAMES_PER_SECOND and self.current_step == 33: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Only novas can hurt bosses!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) self.timer = 0 self.current_step += 1 if self.time_after_boss == 1 * FRAMES_PER_SECOND: temp_image = text.TextSurface(FONT_PATH, 30, FONT_COLOR, 'Congratulations!').image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) if self.time_after_boss == 3 * FRAMES_PER_SECOND: temp_image = text.TextSurface( FONT_PATH, 30, FONT_COLOR, "Looks like you're ready for a real challenge!").image help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND) help_bubble.set_offset(vector.Vector2d(0.0, -100.0)) self.text_group.add(help_bubble) if self.moono_dead or self.mass_attack: self.timer += 1 if self.time_after_boss == 5 * FRAMES_PER_SECOND: utility.fade_music() return True