weapon = ray_weapons[ray_choice - 1] raw_input("Ray attacks with {0}".format(weapon.name)) hit, damage = weapon.attack(enemy) if hit: enemy.take_damage(damage) raw_input("{0} takes {1} damage!".format(enemy.name, damage)) else: raw_input("Ray misses") if enemy.is_alive(): enemy_weapon = choice(enemy_weapons) raw_input("{0} attacks with {1}".format(enemy.name, enemy_weapon.name)) hit, damage = enemy_weapon.attack(enemy) if hit: ray.take_damage(damage) raw_input("Ray takes {0} damage!".format(damage)) else: raw_input("{0} misses".format(enemy.name)) else: raw_input("{0} is defeated".format(enemy.name)) enemy = None if ray.is_alive(): print("You have won!") game.load_music("ff7.wav") game.play_music(False) raw_input() else: print("Oh dear, you are dead!") game.stop_music()
def _on_pacman_level_cleared(self): global_obj.game_paused = True global_obj.game_state = GameState.LEVEL_COMPLETE game.start_timer(timer_id=self.level_cleared_timer_id) game.stop_music()
def _on_pacman_lose_life(self): global_obj.game_paused = True global_obj.game_state = GameState.PACMAN_LOSE_LIFE game.start_timer(timer_id=self.pacman_lose_life_start_timer_id) game.stop_music()
def _on_pacman_power_pellete_eaten(self): game.stop_music() game.play_music(music_id="power-pellete") game.start_timer(timer_id=self.ghost_frightened_timer_id)
def _on_ghost_frightened_timer_timeout(self): game.stop_music() if global_obj.game_state == GameState.PLAYING: game.play_music(music_id="siren1")
def __create__(self): # Vars self.speed = 100 # Play Music game.stop_music() game.pause_music() game.resume_music() game.play_music(music_id="dd-music") # Create Text Label Entity text_label_entity_id = "test_text" game.create_label_entity( entity_id=text_label_entity_id, text="Test", position=(100, 100), font_id="charriot", layer=2, fixed=False, wrap_length=800, color=(100, 100, 100), ) # Update Label Text game.update_label_entity_text(entity_id=text_label_entity_id, text="New Text!") # Create sprite entity helicopter_entity_id = "helicopter" game.create_sprite_entity( entity_id=helicopter_entity_id, texture_id="chopper", position=(400, 400), layer=3, width=32, height=32, clickable=False, fixed=False, collider_tag="", # Emtpy as default set to add collider ) # Setup signal for animation finished game.subscribe_to_signal( source_id=f"{helicopter_entity_id}_animation", signal_id="animation_finished", subscriber_entity_id=self.entity_id, function_name="_on_helicopter_animation_finished", ) # Setup signal for animation frame changed game.subscribe_to_signal( source_id=f"{helicopter_entity_id}_animation", signal_id="frame_changed", subscriber_entity_id=self.entity_id, function_name="_on_helicopter_frame_changed", ) # Delete sprite entity (after creation) delete_entity_id = "delete_entity" game.create_sprite_entity( entity_id=delete_entity_id, texture_id="chopper", position=(100, 100), layer=3, width=32, height=32, clickable=False, fixed=False, ) game.delete_entity(entity_id=delete_entity_id) # Create timer self.counted_seconds = 0 self.count_timer_id = "count_timer" game.create_timer( timer_id=self.count_timer_id, time=1.0, loops=True, start_on_creation=True ) # Stop Timer game.stop_timer(self.count_timer_id) # Start Timer game.start_timer(self.count_timer_id) # Connect signal game.subscribe_to_signal( source_id=self.count_timer_id, signal_id="timeout", subscriber_entity_id=self.entity_id, function_name="_on_test_timer_timeout", )