def fade_up(world, entity, from_scene, to_scene): world.add_component( entity, components.ChangePosition((0, -100), 4, interpolation.Smooth(), True, fade_out, world)) world.add_component(entity, components.ChangeAlpha(0, 4, interpolation.Smooth())) world.add_component(entity, components.Delay(5, next_scene, from_scene, to_scene))
def puzzle_complete(): if self.world.component_for_entity(mug, components.Flammable).lit: p = self.world.component_for_entity(player, components.Player) if p.holding is mug: p.holding = None self.world.delete_entity(mug) #self.switch_to_scene(text.TextScene("NaN was unsure how much longer he could go on like this. He still wanted to help people, but was filled with thoughts of inadequacy and self doubt.", SceneSeven())) notify(self.world, self.small_font, "Way to take your time.", self, text.TextScene("Eventually he'd had enough. He decided he would get revenge on his town for treating him this way.", SceneSeven())) else: complaint = create_entity(self.world, "speech.png", pygame.Rect(640, 500, 307, 173)) self.world.add_component(complaint, components.ChangeAlpha(0, 4, interpolation.Smooth())) util.drawText(self.world.component_for_entity(complaint, components.Image).image, "It's cold! Heat it up for me.", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font)
def start_game(): for ent, c in self.world.get_component(components.CircleAnimation): c.loop = False c.chain = move_to_bottom for ent in [start, quitbutton, title]: pos = self.world.component_for_entity(ent, components.Position) self.world.add_component( ent, components.ChangePosition((pos.x, pos.y + 100), 1)) self.world.add_component(ent, components.ChangeAlpha(1, 0, 1)) def change_scene(): print("TODO: game screen") next_scene = self.world.create_entity() self.world.add_component(next_scene, components.Delay(2, change_scene))
def fade_scene(): for ent in [text, continue_text]: if self.world.has_component(ent, components.ChangeAlpha): self.world.remove_component(ent, components.ChangeAlpha) self.world.add_component(ent, components.ChangeAlpha(0, .5)) self.world.add_component( ent, components.ChangePosition( (640, self.world.component_for_entity( ent, components.Position).y + 50), .5)) self.world.add_component(text, components.Delay(1, next_scene)) pygame.mixer.Sound( os.path.join(components.get_base_path(), 'audio', 'click')).play()
def start_game(): for ent, (p, i) in self.world.get_components(components.Position, components.Image): self.world.add_component( ent, components.ChangePosition((p.x, p.y + 100), .25)) self.world.add_component(ent, components.ChangeAlpha(0, .25)) def change_scene(): self.switch_to_scene( text.TextScene( "This is the story of an adventurer named NaN, known across the land for his unwavering enthusiasm for helping anyone with anything. His abilities were known far and wide, and indeed our story even begins with him defeating a dragon with ease...", game.SceneOne())) next_scene = self.world.create_entity() self.world.add_component(next_scene, components.Delay(.5, change_scene))
def puzzle_complete(): if self.world.component_for_entity(mug, components.Flammable).lit: p = self.world.component_for_entity(player, components.Player) if p.holding is mug: p.holding = None self.world.delete_entity(mug) #self.switch_to_scene(text.TextScene("NaN was unsure how much longer he could go on like this. He still wanted to help people, but was filled with thoughts of inadequacy and self doubt.", SceneSeven())) notify( self.world, self.small_font, "Way to take your time.", self, text.TextScene( "Eventually he'd had enough. There was no way he could go back to adventuring, but he similarly could not stop here. He began a new journey, leaving his town without a single goodbye. Thanks for playing.", title.TitleScene())) else: complaint = create_entity(self.world, "speech.png", pygame.Rect(640, 500, 307, 173)) self.world.add_component( complaint, components.ChangeAlpha(0, 4, interpolation.Smooth())) util.drawText( self.world.component_for_entity(complaint, components.Image).image, "It's cold! Heat it up for me.", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font)
def fade_out(world): for ent, i in world.get_component(components.Image): world.add_component(ent, components.ChangeAlpha(0, 1)) for ent, a in world.get_component(components.Animation): world.add_component(ent, components.ChangeAlpha(0, 1))
def fade_in(entity): self.world.add_component( entity, components.ChangeAlpha(1, 1, interpolation.Circle(), fade_out, entity))
def init(self): scenebase.SceneBase.init(self) text = self.world.create_entity() image = pygame.Surface([1280, 720], pygame.SRCALPHA, 32).convert_alpha() util.drawText(image, self.text, (255, 255, 255), pygame.Rect(100, 100, 1080, 520), self.font) self.world.add_component(text, components.Position(640, 240)) self.world.add_component(text, components.Image(image=image, alpha=0)) self.world.add_component( text, components.Size(image.get_width(), image.get_height())) self.world.add_component(text, components.ChangePosition((640, 340), .5)) self.world.add_component(text, components.ChangeAlpha(1, 1)) #self.world.add_component(text, components.Reactive()) def fade_out(entity): self.world.add_component( entity, components.ChangeAlpha(.5, 1, interpolation.Circle(), fade_in, entity)) def fade_in(entity): self.world.add_component( entity, components.ChangeAlpha(1, 1, interpolation.Circle(), fade_out, entity)) continue_text = self.world.create_entity() image = self.font.render("press any button to continue", False, (32, 128, 255)) self.world.add_component(continue_text, components.Position(640, 640)) self.world.add_component(continue_text, components.Image(image=image)) self.world.add_component( continue_text, components.Size(image.get_width(), image.get_height())) #self.world.add_component(continue_text, components.Reactive()) fade_in(continue_text) def fade_scene(): for ent in [text, continue_text]: if self.world.has_component(ent, components.ChangeAlpha): self.world.remove_component(ent, components.ChangeAlpha) self.world.add_component(ent, components.ChangeAlpha(0, .5)) self.world.add_component( ent, components.ChangePosition( (640, self.world.component_for_entity( ent, components.Position).y + 50), .5)) self.world.add_component(text, components.Delay(1, next_scene)) pygame.mixer.Sound( os.path.join(components.get_base_path(), 'audio', 'click')).play() def next_scene(): self.switch_to_scene(self.scene) self.world.add_processor(processors.RenderProcessor()) self.world.add_processor(processors.AnimationProcessor(), priority=5) self.world.add_processor(processors.TextProcessor(fade_scene), priority=10) self.world.add_processor(processors.InputProcessor())