def f(*args): pos = makePos(*args) e = entity.Entity(pos=pos) e.add_component( comp.TiledGfx(tile_sheet='gfx/smb1.png', sheet_size=[16, 16], tile_data=[15, 5], width=1, height=1, size=vars.tile_size, repx=args[3], repy=1)) e.add_component( comp.Collider(flag=vars.flags.platform_passthrough, mask=vars.flags.player, tag=0, shape=sh.Line( a=[0, vars.tile_size, 0], b=[args[3] * vars.tile_size, vars.tile_size, 0]))) e.add_component( comp.PolygonalMover(origin=(pos[0], pos[1]), loop=args[6], pct=args[4], moves=[{ 'delta': [0, args[5] * vars.tile_size], 'speed': args[7], 'hold': 0 }])) e.add_component(comp.Platform()) return e
def match_setup(): """set up matches. For the first match, draw the platforms and have them walk out to the rings. For other matches, have them "beam" in """ platform1 = components.Platform(550, 450) platform2 = components.Platform(50, 450) platform1.scalebywidth(400) platform2.scalebywidth(400) ball = components.Ball(500, 150) ballstart = random.randint(1, 10) if ballstart < 5: ball.direction = 1 else: ball.direction = -1 scoreboard = components.Scoreboard() return scoreboard, platform1, platform2, ball
def init(self): scenebase.SceneBase.init(self) bg = create_entity(self.world, "HouseScene1BG.png", pygame.Rect(640, 360, 1280, 720)) self.world.add_component(bg, components.Background()) player = get_player(self.world) for i in [("WoodPlatform3.png", 520, 390, 720, 40), ("WoodPlatformHalf.png", 1000, 500, 120, 40), ("WoodPlatformThird.png", 920, 440, 80, 40), ("WoodPlatformThird.png", 1080, 560, 80, 40)]: platform = create_entity(self.world, i[0], pygame.Rect(i[1], i[2], i[3], i[4])) self.world.add_component(platform, components.Platform()) self.world.add_component(platform, components.Background()) for i in [(520, 330), (760, 330), (280, 560), (520, 560)]: bed = create_entity(self.world, "Bed.png", pygame.Rect(i[0], i[1], 160, 80)) self.world.add_component(bed, components.Velocity()) self.world.add_component(bed, components.Flammable()) self.world.add_component(bed, components.Audio("heavy")) guy = create_entity(self.world, "NPC2.png", pygame.Rect(1000, 460, 80, 80)) self.world.add_component(guy, components.Velocity()) self.world.add_component(guy, components.Flammable()) self.world.add_component(guy, components.Audio("grunt")) table = create_entity(self.world, "TableBig.png", pygame.Rect(280, 330, 160, 80)) self.world.add_component(table, components.Velocity()) self.world.add_component(table, components.Flammable()) self.world.add_component(table, components.Audio("heavy")) 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) mug = create_entity(self.world, "Mug.png", pygame.Rect(250, 160, 80, 80)) self.world.add_component(mug, components.Hang()) self.world.add_component(mug, components.Flammable()) self.world.add_component( mug, components.Touch(guy, True, touch=puzzle_complete)) self.world.add_component(mug, components.Audio("light")) lamp = create_entity(self.world, "Chandelier.png", pygame.Rect(520, 160, 80, 80)) self.world.add_component(lamp, components.Flammable(True)) self.world.add_component(lamp, components.Hang()) lamp2 = create_entity(self.world, "Chandelier.png", pygame.Rect(760, 160, 80, 80)) self.world.add_component(lamp2, components.Flammable(True)) self.world.add_component(lamp2, components.Hang()) fireplace = create_entity(self.world, "Fireplace.png", pygame.Rect(760, 520, 160, 160)) self.world.add_component(fireplace, components.Flammable(True)) self.world.add_component(fireplace, components.Velocity()) self.world.add_component(fireplace, components.Background()) # shelf create_entity(self.world, "shelf.png", pygame.Rect(250, 210, 80, 20)) bubble = create_entity(self.world, "speech.png", pygame.Rect(1000, 100, 307, 173)) self.world.add_component(bubble, components.Hang()) image = self.world.component_for_entity(bubble, components.Image).image util.drawText( image, "About time you got here, NaN. I need my coffee stat! It's probably been sitting there for hours!", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font) self.world.add_processor(processors.RenderProcessor()) self.world.add_processor(processors.InputProcessor(), priority=10) self.world.add_processor(processors.PhysicsProcessor(600), priority=5) self.world.add_processor(processors.AnimationProcessor(), priority=5) self.world.add_processor(processors.PlayerProcessor(player, 40), priority=25)
def init(self): scenebase.SceneBase.init(self) bg = create_entity(self.world, "HouseSceneBlacksmithBG.png", pygame.Rect(640, 360, 1280, 720)) self.world.add_component(bg, components.Background()) player = get_player(self.world) for i in [("WoodPlatform3.png", 760, 390, 720, 40), ("WoodPlatformHalf.png", 280, 500, 120, 40), ("WoodPlatformThird.png", 360, 440, 80, 40), ("WoodPlatformThird.png", 200, 560, 80, 40)]: platform = create_entity(self.world, i[0], pygame.Rect(i[1], i[2], i[3], i[4])) self.world.add_component(platform, components.Platform()) self.world.add_component(platform, components.Background()) anvil = create_entity(self.world, "Anvil.png", pygame.Rect(710, 560, 80, 80)) self.world.add_component(anvil, components.Velocity()) self.world.add_component(anvil, components.Audio("heavy")) bed = create_entity(self.world, "Bed.png", pygame.Rect(500, 330, 160, 80)) self.world.add_component(bed, components.Velocity()) self.world.add_component(bed, components.Flammable()) self.world.add_component(bed, components.Audio("heavy")) bookshelf = create_entity(self.world, "Bookshelf.png", pygame.Rect(640, 290, 80, 160)) self.world.add_component(bookshelf, components.Velocity()) self.world.add_component(bookshelf, components.Flammable()) self.world.add_component(bookshelf, components.Audio("heavy")) guy = create_entity(self.world, "NPC3.png", pygame.Rect(280, 560, 80, 80)) self.world.add_component(guy, components.Velocity()) self.world.add_component(guy, components.Flammable()) self.world.add_component(guy, components.Audio("grunt")) left_chair = create_entity(self.world, "Chair.png", pygame.Rect(480, 560, 80, 80)) self.world.add_component(left_chair, components.Velocity()) self.world.add_component(left_chair, components.Flammable()) self.world.add_component(left_chair, components.Audio("light")) top_chair = create_entity(self.world, "Chair.png", pygame.Rect(770, 330, 80, 80)) self.world.add_component(top_chair, components.Velocity()) self.world.add_component(top_chair, components.Flammable()) self.world.add_component(top_chair, components.Audio("light")) table = create_entity(self.world, "Table.png", pygame.Rect(570, 560, 80, 80)) self.world.add_component(table, components.Velocity()) self.world.add_component(table, components.Flammable()) self.world.add_component(table, components.Audio("heavy")) def puzzle_complete(): notify( self.world, self.small_font, "You got a crack in it. Thanks for nothing.", self, text.TextScene( "NaN was depressed. For the majority of his life he was the strongest, fastest, all around best adventurer in the whole realm. But it was his own effectiveness led to his now pitiful existence.", SceneSix())) def open_container(container, item_string): if container is not None: p = self.world.component_for_entity(container, components.Position) self.world.delete_entity(container) item = create_entity(self.world, item_string, pygame.Rect(p.x, p.y, 80, 80)) self.world.add_component(item, components.Audio("light")) self.world.add_component(item, components.Flammable()) if container is chest: self.world.add_component( item, components.Touch(guy, rect=pygame.Rect(0, 0, 0, 0), touch=puzzle_complete)) if self.world.component_for_entity( player, components.Player).holding == container: self.world.component_for_entity( player, components.Player).holding = item i = self.world.component_for_entity(item, components.Image) s = self.world.component_for_entity(item, components.Size) i.image = pygame.transform.rotate(i.image, 90) tmp = s.width s.width = s.height s.height = tmp else: v = self.world.component_for_entity( container, components.Velocity) self.world.add_component(item, components.Velocity(v.x, v.y)) self.world.component_for_entity(item, components.Audio).sound.play() chest = create_entity(self.world, "chest.png", pygame.Rect(1070, 330, 80, 80)) self.world.add_component(chest, components.Velocity()) self.world.add_component(chest, components.Flammable()) self.world.add_component( chest, components.Touch(anvil, False, pygame.Rect(0, 0, 0, 0), open_container, chest, "Vase.png")) self.world.add_component(chest, components.Audio("chest")) box = create_entity(self.world, "box1.png", pygame.Rect(860, 330, 80, 80)) self.world.add_component(box, components.Velocity()) self.world.add_component(box, components.Flammable()) self.world.add_component( box, components.Touch(anvil, False, pygame.Rect(0, 0, 0, 0), open_container, box, "Chair.png")) self.world.add_component(box, components.Audio("heavy")) box2 = create_entity(self.world, "box2.png", pygame.Rect(950, 330, 80, 80)) self.world.add_component(box2, components.Velocity()) self.world.add_component(box2, components.Flammable()) self.world.add_component( box2, components.Touch(anvil, False, pygame.Rect(0, 0, 0, 0), open_container, box2, "PileOfBooks.png")) self.world.add_component(box2, components.Audio("heavy")) lamp = create_entity(self.world, "Chandelier.png", pygame.Rect(520, 170, 80, 80)) self.world.add_component(lamp, components.Flammable(True)) self.world.add_component(lamp, components.Hang()) lamp2 = create_entity(self.world, "Chandelier.png", pygame.Rect(1000, 170, 80, 80)) self.world.add_component(lamp2, components.Flammable(True)) self.world.add_component(lamp2, components.Hang()) forge = create_entity(self.world, "Forge.png", pygame.Rect(1040, 520, 80, 160)) self.world.add_component(anvil, components.Velocity()) self.world.add_component(forge, components.Flammable(True)) self.world.add_component(anvil, components.Audio("heavy")) workbench = create_entity(self.world, "Workbench.png", pygame.Rect(870, 560, 160, 80)) self.world.add_component(workbench, components.Velocity()) self.world.add_component(workbench, components.Flammable()) self.world.add_component(workbench, components.Audio("heavy")) bubble = create_entity(self.world, "speech.png", pygame.Rect(200, 100, 307, 173)) self.world.add_component(bubble, components.Hang()) util.drawText( self.world.component_for_entity(bubble, components.Image).image, "Shoot, now where did that vase go? NaN, you touched it last. You need to find it for me!", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font) self.world.add_processor(processors.RenderProcessor()) self.world.add_processor(processors.InputProcessor(), priority=10) self.world.add_processor(processors.PhysicsProcessor(600), priority=5) self.world.add_processor(processors.AnimationProcessor(), priority=5) self.world.add_processor(processors.PlayerProcessor(player, 60), priority=25)
def init(self): scenebase.SceneBase.init(self) bg = create_entity(self.world, "HouseScene2BG.png", pygame.Rect(640, 360, 1280, 720)) self.world.add_component(bg, components.Background()) player = get_player(self.world) floor2 = create_entity(self.world, "WoodPlatform2.png", pygame.Rect(400, 390, 480, 40)) self.world.add_component(floor2, components.Platform()) self.world.add_component(floor2, components.Background()) stair = create_entity(self.world, "WoodPlatform1.png", pygame.Rect(760, 500, 240, 40)) self.world.add_component(stair, components.Platform()) self.world.add_component(stair, components.Background()) bed = create_entity(self.world, "Bed.png", pygame.Rect(260, 330, 160, 80)) self.world.add_component(bed, components.Velocity()) self.world.add_component(bed, components.Flammable()) self.world.add_component(bed, components.Audio("heavy")) bookshelf = create_entity(self.world, "Bookshelf.png", pygame.Rect(420, 290, 80, 160)) self.world.add_component(bookshelf, components.Velocity()) self.world.add_component(bookshelf, components.Flammable()) self.world.add_component(bookshelf, components.Audio("heavy")) chest = create_entity(self.world, "chest.png", pygame.Rect(540, 330, 80, 80)) self.world.add_component(chest, components.Velocity()) self.world.add_component(chest, components.Flammable()) self.world.add_component(chest, components.Audio("chest")) guy = create_entity(self.world, "NPC1.png", pygame.Rect(280, 560, 80, 80)) self.world.add_component(guy, components.Velocity()) self.world.add_component(guy, components.Flammable()) self.world.add_component(guy, components.Audio("grunt")) left_chair = create_entity(self.world, "Chair.png", pygame.Rect(430, 560, 80, 80)) self.world.add_component(left_chair, components.Velocity()) self.world.add_component(left_chair, components.Flammable()) self.world.add_component(left_chair, components.Audio("light")) right_chair = create_entity(self.world, "Chair.png", pygame.Rect(610, 560, 80, 80)) self.world.add_component(right_chair, components.Velocity()) self.world.add_component(right_chair, components.Flammable()) self.world.add_component(right_chair, components.Audio("light")) self.world.component_for_entity( right_chair, components.Image).image = pygame.transform.flip( self.world.component_for_entity(right_chair, components.Image).image, False, False) table = create_entity(self.world, "Table.png", pygame.Rect(520, 560, 80, 80)) self.world.add_component(table, components.Velocity()) self.world.add_component(table, components.Flammable()) self.world.add_component(table, components.Audio("heavy")) def puzzle_complete(): p = self.world.component_for_entity(player, components.Player) if p.holding is books: p.holding = None self.world.delete_entity(books) notify( self.world, self.small_font, "Wow, you got the books dirty. I can't use these anymore.", self, text.TextScene( "These thankless jobs took their toll on NaN. He put on a friendly face, but inside he was growing weary...", SceneFour())) books = create_entity(self.world, "PileOfBooks.png", pygame.Rect(1000, 560, 80, 80)) self.world.add_component(books, components.Velocity()) self.world.add_component(books, components.Flammable()) self.world.add_component( books, components.Touch(bookshelf, rect=pygame.Rect(5, 0, -10, 0), touch=puzzle_complete)) self.world.add_component(books, components.Audio("light")) lamp = create_entity(self.world, "Chandelier.png", pygame.Rect(760, 170, 80, 80)) self.world.add_component(lamp, components.Flammable(True)) self.world.add_component(lamp, components.Hang()) self.world.add_component(lamp, components.Audio("glass.ogg")) bubble = create_entity(self.world, "speech.png", pygame.Rect(1000, 100, 307, 173)) self.world.add_component(bubble, components.Hang()) image = self.world.component_for_entity(bubble, components.Image).image util.drawText( image, "Ah! NaN, just in time! I need your help putting my books away. They are very important!", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font) self.world.add_processor(processors.RenderProcessor()) self.world.add_processor(processors.InputProcessor(), priority=10) self.world.add_processor(processors.PhysicsProcessor(600), priority=5) self.world.add_processor(processors.AnimationProcessor(), priority=5) self.world.add_processor(processors.PlayerProcessor(player, 85), priority=25)
def init(self): scenebase.SceneBase.init(self) bg = create_entity(self.world, "HouseScene2BG.png", pygame.Rect(640, 360, 1280, 720)) self.world.add_component(bg, components.Background()) player = get_player(self.world) floor2 = create_entity(self.world, "WoodPlatform2.png", pygame.Rect(400, 390, 480, 40)) self.world.add_component(floor2, components.Platform()) self.world.add_component(floor2, components.Background()) stair = create_entity(self.world, "WoodPlatform1.png", pygame.Rect(760, 500, 240, 40)) self.world.add_component(stair, components.Platform()) self.world.add_component(stair, components.Background()) bed = create_entity(self.world, "Bed.png", pygame.Rect(260, 330, 160, 80)) self.world.add_component(bed, components.Velocity()) self.world.add_component(bed, components.Flammable()) self.world.add_component(bed, components.Audio("heavy")) bookshelf = create_entity(self.world, "Bookshelf.png", pygame.Rect(420, 290, 80, 160)) self.world.add_component(bookshelf, components.Velocity()) self.world.add_component(bookshelf, components.Flammable()) self.world.add_component(bookshelf, components.Audio("heavy")) chest = create_entity(self.world, "chest.png", pygame.Rect(540, 330, 80, 80)) self.world.add_component(chest, components.Velocity()) self.world.add_component(chest, components.Flammable()) self.world.add_component(chest, components.Audio("chest")) guy = create_entity(self.world, "NPC1.png", pygame.Rect(280, 560, 80, 80)) self.world.add_component(guy, components.Velocity()) self.world.add_component(guy, components.Flammable()) self.world.add_component(guy, components.Audio("grunt")) left_chair = create_entity(self.world, "Chair.png", pygame.Rect(430, 560, 80, 80)) self.world.add_component(left_chair, components.Velocity()) self.world.add_component(left_chair, components.Flammable()) self.world.add_component(left_chair, components.Audio("light")) right_chair = create_entity(self.world, "Chair.png", pygame.Rect(610, 560, 80, 80)) self.world.add_component(right_chair, components.Velocity()) self.world.add_component(right_chair, components.Flammable()) self.world.add_component(right_chair, components.Audio("light")) self.world.component_for_entity(right_chair, components.Image).image = pygame.transform.flip(self.world.component_for_entity(right_chair, components.Image).image, False, False) table = create_entity(self.world, "Table.png", pygame.Rect(520, 560, 80, 80)) self.world.add_component(table, components.Velocity()) self.world.add_component(table, components.Flammable()) self.world.add_component(table, components.Audio("heavy")) puzzledone = False def puzzle_complete(): puzzledone = True p = self.world.component_for_entity(player, components.Player) if p.holding is bed: p.holding = None self.world.delete_entity(books) notify(self.world, self.small_font, "OH MY GOD. MY HOUSE. GET THE HECK OUT OF HERE.", self, text.TextScene("These thankless jobs took their toll on NaN. He put on a friendly face, but inside he was growing weary...", SceneFour())) books = create_entity(self.world, "PileOfBooks.png", pygame.Rect(1000, 560, 80, 80)) self.world.add_component(books, components.Velocity()) self.world.add_component(books, components.Flammable()) self.world.add_component(books, components.Touch(bookshelf, rect=pygame.Rect(5, 0, -10, 0))) self.world.add_component(books, components.Audio("light")) lamp = create_entity(self.world, "Chandelier.png", pygame.Rect(760, 170, 80, 80)) self.world.add_component(lamp, components.Flammable(True)) self.world.add_component(lamp, components.Hang()) self.world.add_component(lamp, components.Audio("glass.ogg")) bubble = create_entity(self.world, "speech.png", pygame.Rect(1000, 100, 307, 173)) self.world.add_component(bubble, components.Hang()) image = self.world.component_for_entity(bubble, components.Image).image util.drawText(image, "Where the heck is NaN? My other books fell off! Note: you must scene select next scene", (255, 255, 255), pygame.Rect(30, 20, 246, 134), self.small_font) def move_up(entity): self.world.add_component(entity, components.ChangePosition((0, -40), 1, interpolation.Smooth(), True, move_down, entity)) def move_down(entity): self.world.add_component(entity, components.ChangePosition((0, 40), 1, interpolation.Smooth(), True, move_up, entity)) tutorial = self.world.create_entity() image = self.font.render("press f to launch a fireball", False, (32, 255, 128)) self.world.add_component(tutorial, components.Position(640, 680)) self.world.add_component(tutorial, components.Image(image=image)) self.world.add_component(tutorial, components.Size(image.get_width(), image.get_height())) move_up(tutorial) self.world.add_processor(processors.RenderProcessor()) self.world.add_processor(processors.InputProcessor(), priority=10) self.world.add_processor(processors.PhysicsProcessor(600), priority=5) self.world.add_processor(processors.AnimationProcessor(), priority=5) self.world.add_processor(processors.FireballPlayerProcessor(player, 85), priority=25)
def init(self): scenebase.SceneBase.init(self) def go_back(): self.switch_to_scene(TitleScene()) def open_scene(scene): self.switch_to_scene(scene) def highlight(entity): t = self.world.component_for_entity(entity, components.Text) image = t.font.render("> " + t.text + " <", False, (0, 128, 128)) self.world.component_for_entity(entity, components.Image).image = image size = self.world.component_for_entity(entity, components.Size) size.width = image.get_width() size.height = image.get_height() def lowlight(entity): t = self.world.component_for_entity(entity, components.Text) image = t.font.render(t.text, False, t.color) self.world.component_for_entity(entity, components.Image).image = image size = self.world.component_for_entity(entity, components.Size) size.width = image.get_width() back = self.world.create_entity() image = self.large_font.render("back", False, (0, 128, 0)) self.world.add_component(back, components.Position(640, 360)) self.world.add_component(back, components.Text("back", self.large_font)) self.world.add_component(back, components.Image(image=image)) self.world.add_component( back, components.Size(image.get_width(), image.get_height(), .75)) self.world.add_component(back, components.Reactive()) self.world.add_component(back, components.Click(go_back)) self.world.add_component(back, components.Over(highlight, lowlight)) self.world.add_component(back, components.Audio("click")) scene1 = self.world.create_entity() label1 = self.world.create_entity() image = self.large_font.render("1", False, (0, 128, 0)) self.world.add_component(label1, components.Position(300, 170)) self.world.add_component(label1, components.Text("1", self.large_font)) self.world.add_component(label1, components.Image(image=image)) self.world.add_component( label1, components.Size(image.get_width(), image.get_height())) self.world.add_component(label1, components.Reactive()) self.world.add_component(scene1, components.Position(300, 100)) self.world.add_component(scene1, components.Platform()) self.world.add_component(scene1, components.Image("IntroBG.png")) self.world.add_component(scene1, components.Size(320, 180)) self.world.add_component(scene1, components.Reactive()) self.world.add_component(scene1, components.Click(open_scene, game.SceneOne())) self.world.add_component(scene1, components.Over(highlight, lowlight, label1)) scene2 = self.world.create_entity() label2 = self.world.create_entity() image = self.large_font.render("2", False, (0, 128, 0)) self.world.add_component(label2, components.Position(980, 170)) self.world.add_component(label2, components.Text("2", self.large_font)) self.world.add_component(label2, components.Image(image=image)) self.world.add_component( label2, components.Size(image.get_width(), image.get_height())) self.world.add_component(label2, components.Reactive()) self.world.add_component(scene2, components.Position(980, 100)) self.world.add_component(scene2, components.Platform()) self.world.add_component(scene2, components.Image("OutsideSceneBG.png")) self.world.add_component(scene2, components.Size(320, 180)) self.world.add_component(scene2, components.Reactive()) self.world.add_component(scene2, components.Click(open_scene, game.SceneTwo())) self.world.add_component(scene2, components.Over(highlight, lowlight, label2)) scene3 = self.world.create_entity() label3 = self.world.create_entity() image = self.large_font.render("3", False, (0, 128, 0)) self.world.add_component(label3, components.Position(300, 420)) self.world.add_component(label3, components.Text("3", self.large_font)) self.world.add_component(label3, components.Image(image=image)) self.world.add_component( label3, components.Size(image.get_width(), image.get_height())) self.world.add_component(label3, components.Reactive()) self.world.add_component(scene3, components.Position(300, 350)) self.world.add_component(scene3, components.Platform()) self.world.add_component(scene3, components.Image("HouseScene2BG.png")) self.world.add_component(scene3, components.Size(320, 180)) self.world.add_component(scene3, components.Reactive()) self.world.add_component( scene3, components.Click(open_scene, game.SceneThree())) self.world.add_component(scene3, components.Over(highlight, lowlight, label3)) scene4 = self.world.create_entity() label4 = self.world.create_entity() image = self.large_font.render("4", False, (0, 128, 0)) self.world.add_component(label4, components.Position(980, 420)) self.world.add_component(label4, components.Text("4", self.large_font)) self.world.add_component(label4, components.Image(image=image)) self.world.add_component( label4, components.Size(image.get_width(), image.get_height())) self.world.add_component(label4, components.Reactive()) self.world.add_component(scene4, components.Position(980, 350)) self.world.add_component(scene4, components.Platform()) self.world.add_component(scene4, components.Image("HouseScene3BG.png")) self.world.add_component(scene4, components.Size(320, 180)) self.world.add_component(scene4, components.Reactive()) self.world.add_component( scene4, components.Click(open_scene, game.SceneFour())) self.world.add_component(scene4, components.Over(highlight, lowlight, label4)) scene5 = self.world.create_entity() label5 = self.world.create_entity() image = self.large_font.render("5", False, (0, 128, 0)) self.world.add_component(label5, components.Position(300, 670)) self.world.add_component(label5, components.Text("5", self.large_font)) self.world.add_component(label5, components.Image(image=image)) self.world.add_component( label5, components.Size(image.get_width(), image.get_height())) self.world.add_component(label5, components.Reactive()) self.world.add_component(scene5, components.Position(300, 600)) self.world.add_component(scene5, components.Platform()) self.world.add_component( scene5, components.Image("HouseSceneBlacksmithBG.png")) self.world.add_component(scene5, components.Size(320, 180)) self.world.add_component(scene5, components.Reactive()) self.world.add_component( scene5, components.Click(open_scene, game.SceneFive())) self.world.add_component(scene5, components.Over(highlight, lowlight, label5)) scene6 = self.world.create_entity() label6 = self.world.create_entity() image = self.large_font.render("6", False, (0, 128, 0)) self.world.add_component(label6, components.Position(980, 670)) self.world.add_component(label6, components.Text("6", self.large_font)) self.world.add_component(label6, components.Image(image=image)) self.world.add_component( label6, components.Size(image.get_width(), image.get_height())) self.world.add_component(label6, components.Reactive()) self.world.add_component(scene6, components.Position(980, 600)) self.world.add_component(scene6, components.Platform()) self.world.add_component(scene6, components.Image("HouseScene1BG.png")) self.world.add_component(scene6, components.Size(320, 180)) self.world.add_component(scene6, components.Reactive()) self.world.add_component(scene6, components.Click(open_scene, game.SceneSix())) self.world.add_component(scene6, components.Over(highlight, lowlight, label6)) for ent, (i, p, s, r) in self.world.get_components( components.Image, components.Position, components.Size, components.Reactive): if r.x == 0: r.x = p.x r.y = p.y mousex, mousey = pygame.mouse.get_pos() mousex *= 1280 / pygame.display.get_surface().get_width() mousey *= 720 / pygame.display.get_surface().get_height() p.x = r.x + (r.x - mousex) / 10 p.y = r.y + (r.y - mousey) / 10 s.scale = 100 / min( 400, max(100, math.sqrt((r.x - mousex)**2 + (r.y - mousey)**2))) self.world.add_processor(processors.RenderProcessor()) self.world.add_processor(processors.InputProcessor(), priority=10) self.world.add_processor(processors.PhysicsProcessor(), priority=5) self.world.add_processor(processors.AnimationProcessor(), priority=5)