def score(self, value): self._score = value game.update_label_entity_text(entity_id="player_one_point_value_label", text=f"{self._score}") if self._score > self.high_score: self.high_score = self._score if self._score >= 10000 and not self.extra_life_earned: self.lives += 1 self.extra_life_earned = True game.play_sound(sound_id="pacman-extra-life")
def high_score(self, value): self._high_score = value game.update_label_entity_text(entity_id="high_score_point_value_label", text=f"{self._high_score}")
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", )