Beispiel #1
0
    def __init__(self, id: str, width, height, worldWidth: int,
                 worldHeight: int, startPos):
        super().__init__(id, width, height)

        # adding pause button
        self.keyl.addKey(key=32, func=func.togglePause)
        self.keyl.addKey(key=299, func=func.restart)

        main = Entity(tag='main')
        main.camera = OrthoCamera(worldwidth=worldWidth * vars.tileSize,
                                  worldheight=worldHeight * vars.tileSize,
                                  camwidth=width,
                                  camheight=height,
                                  viewport=[0, 0, width, height],
                                  tag='maincam')
        self.main = main
        self.add(main)

        # create the collision engine (maybe to put into the ctor of the room subclass)
        ce = CollisionEngine(80, 80)
        #         ce.addResponse(vars.tags.player, vars.tags.brick_sensor, CollisionResponse(onenter=func.brickResponse))
        #         ce.addResponse(vars.tags.player, vars.tags.bonus_brick_sensor, CollisionResponse(onenter=func.bonusBrickResponse))
        #         ce.addResponse(vars.tags.player, vars.tags.mushroom, CollisionResponse(onenter=func.mushroomResponse))
        #         ce.addResponse(vars.tags.player, vars.tags.warp, CollisionResponse(onenter = func.onWarpEnter, onleave= func.onWarpExit))
        #         ce.addResponse(vars.tags.player, vars.tags.hotspot, CollisionResponse(onenter = func.hotspotEnter))
        #         ce.addResponse(vars.tags.player, vars.tags.coin, CollisionResponse(onenter = func.coinResponse))
        #         ce.addResponse(vars.tags.player, vars.tags.goomba, CollisionResponse(onenter = func.goombaResponse))
        #         ce.addResponse(vars.tags.player, vars.tags.koopa, CollisionResponse(onenter = func.koopaResponse))
        #         ce.addResponse (vars.tags.player, vars.tags.spawn, CollisionResponse (onenter = func.onSpawn))
        #         ce.addResponse (vars.tags.player, vars.tags.key, CollisionResponse (onenter = func.onCollectItem))
        #         ce.addResponse(vars.tags.goomba, vars.tags.player_fire, CollisionResponse (onenter = func.fireHitsFoe))
        self.addRunner(ce)
        self.addRunner(Scheduler())

        self.dw = DynamicWorld(256, 256, 'maincam')
        self.addRunner(self.dw)

        #         diag = Entity (tag = 'diag')
        #         diag.camera = OrthoCamera(worldwidth = width, worldheight = height,
        #             camwidth=width, camheight=height, viewport=[0, 0, width, height], tag='diagcam')
        #         diag.add(Text ('main', 8, engine.getString('mario'), [255, 255, 255, 255], TextAlignment.topleft, pos=[24, 248, 2]))
        #         diag.add(Text ('main', 8, '{:06d}'.format(vars.score), [255, 255, 255, 255], TextAlignment.topleft, tag='score_label', pos=[24, 240, 2]))
        #         diag.add(Text ('main', 8, engine.getString('world'), [255, 255, 255, 255], TextAlignment.topleft, pos=[144, 248, 2]))
        #         diag.add(Text ('main', 8, id, [255, 255, 255, 255], TextAlignment.top, pos=[164, 240, 2]))
        #         diag.add(Text ('main', 8, engine.getString('time'), [255, 255, 255, 255], TextAlignment.topright, pos=[232, 248, 2]))
        #         diag.add(Text ('main', 8, str(vars.time), [255, 255, 255, 255], TextAlignment.topright, tag='score_label', pos=[232, 240, 2]))
        #         diag.add(Sprite (model = 'coin_counter', pos=[96, 232, 2]))
        #         diag.add(Text ('main', 8, 'x', [255,255,255,255], pos=[108,240,2]))
        #         diag.add(Text ('main', 8, '{:02d}'.format(vars.coins), [255, 255, 255, 255], TextAlignment.topleft, tag='coin_label', pos=[116, 240, 2]))

        #         fpsCount = Text ('main', 8, '0', [255,255,255,255], align = TextAlignment.topleft, tag='fps', pos = [0, 256, 2])
        #         fpsCount.addComponent (FPSCounter())
        #         diag.add (fpsCount)

        #         self.add(diag)

        # add player
        wboy = build.makePlayer('wonderboy', startPos[0], startPos[1])
        main.add(wboy)
Beispiel #2
0
    def __init__(self, id: str, width, height, worldWidth: int,
                 worldHeight: int):
        super().__init__(id, width, height)
        # adding pause button
        #self.keyl.addKey(key=32, func = f)
        #self.keyl.addKey(key=264, func = checkWarp)

        main = Entity(tag='main')
        main.camera = OrthoCamera(worldwidth=worldWidth,
                                  worldheight=worldHeight,
                                  camwidth=width,
                                  camheight=height,
                                  viewport=[0, 0, width, height],
                                  tag='maincam')
        self.add(main)

        # create the collision engine (maybe to put into the ctor of the room subclass)
        ce = CollisionEngine(80, 80)
        ce.addResponse(var.Tags.player, var.Tags.wall,
                       CollisionResponse(onenter=f, onleave=g))
        self.addRunner(ce)
        self.addRunner(Scheduler())
Beispiel #3
0
    def __init__(self, id:str, width, height, worldWidth: int, worldHeight : int, startPos):
        super().__init__(id, width, height)
        # adding pause button
        self.keyl.addKey(key=32, func = func.togglePause)
        #self.keyl.addKey(key=264, func = checkWarp)
        # restart on F10
        self.keyl.addKey(key=299, func = func.restart)

        main = Entity (tag='main')
        main.camera = OrthoCamera(worldwidth = worldWidth * vars.tileSize, worldheight = worldHeight * vars.tileSize, 
        camwidth=width, camheight=height, viewport=[0, 0, width, height], tag='maincam')
        self.main = main
        self.add(main)

        # create the collision engine (maybe to put into the ctor of the room subclass)
        ce = CollisionEngine(80, 80)
        ce.addResponse(vars.tags.player, vars.tags.brick_sensor, CollisionResponse(onenter=func.brickResponse))
        ce.addResponse(vars.tags.player, vars.tags.bonus_brick_sensor, CollisionResponse(onenter=func.bonusBrickResponse))
        ce.addResponse(vars.tags.player, vars.tags.mushroom, CollisionResponse(onenter=func.mushroomResponse))
        ce.addResponse(vars.tags.player, vars.tags.warp, CollisionResponse(onenter = func.onWarpEnter, onleave= func.onWarpExit))
        ce.addResponse(vars.tags.player, vars.tags.hotspot, CollisionResponse(onenter = func.hotspotEnter))
        ce.addResponse(vars.tags.player, vars.tags.coin, CollisionResponse(onenter = func.coinResponse))
        ce.addResponse(vars.tags.player, vars.tags.goomba, CollisionResponse(onenter = func.goombaResponse))
        ce.addResponse(vars.tags.player, vars.tags.koopa, CollisionResponse(onenter = func.koopaResponse))		
        ce.addResponse (vars.tags.player, vars.tags.spawn, CollisionResponse (onenter = func.onSpawn))
        ce.addResponse (vars.tags.player, vars.tags.key, CollisionResponse (onenter = func.onCollectItem))
        ce.addResponse(vars.tags.goomba, vars.tags.player_fire, CollisionResponse (onenter = func.fireHitsFoe))
        self.addRunner(ce)
        self.addRunner(Scheduler())


        self.dw = DynamicWorld(256, 256, 'maincam')
        self.addRunner(self.dw)

        diag = Entity (tag = 'diag')
        diag.camera = OrthoCamera(worldwidth = width, worldheight = height, 
            camwidth=width, camheight=height, viewport=[0, 0, width, height], tag='diagcam')
        diag.add(Text ('main', 8, engine.getString('mario'), [255, 255, 255, 255], TextAlignment.topleft, pos=[24, 248, 2]))
        diag.add(Text ('main', 8, '{:06d}'.format(vars.score), [255, 255, 255, 255], TextAlignment.topleft, tag='score_label', pos=[24, 240, 2]))
        diag.add(Text ('main', 8, engine.getString('world'), [255, 255, 255, 255], TextAlignment.topleft, pos=[144, 248, 2]))
        diag.add(Text ('main', 8, id, [255, 255, 255, 255], TextAlignment.top, pos=[164, 240, 2]))
        diag.add(Text ('main', 8, engine.getString('time'), [255, 255, 255, 255], TextAlignment.topright, pos=[232, 248, 2]))
        diag.add(Text ('main', 8, str(vars.time), [255, 255, 255, 255], TextAlignment.topright, tag='score_label', pos=[232, 240, 2]))
        diag.add(Sprite (model = 'coin_counter', pos=[96, 232, 2]))
        diag.add(Text ('main', 8, 'x', [255,255,255,255], pos=[108,240,2]))
        diag.add(Text ('main', 8, '{:02d}'.format(vars.coins), [255, 255, 255, 255], TextAlignment.topleft, tag='coin_label', pos=[116, 240, 2]))

        fpsCount = Text ('main', 8, '0', [255,255,255,255], align = TextAlignment.topleft, tag='fps', pos = [0, 256, 2])
        fpsCount.addComponent (FPSCounter())
        diag.add (fpsCount)

        self.add(diag)

	    # scene = {

		# 	[2] = {
		# 		tag = "diag",
		# 		camera = {
		# 			tag = "diagcam",
		# 			type ="ortho",
		# 			pos = {0,0,5},
		# 			size = {args.screen_size[1]*16, args.screen_size[2]*16},
		# 			bounds = {0,0,args.screen_size[1]*16, args.screen_size[2]*16},
		# 			viewport = {0, 0, args.screen_size[1]*16, args.screen_size[2]*16}
		# 		},
		# 		children = {
		# 	 		{
		# 				pos = {24,248,0},
		# 				components = {
		# 					{ type = "text", id="MARIO", font="main", size=8, }
		# 				}
		# 			},
		# 			{
		# 				tag = "score_label",
		# 				pos = {24, 240, 0},
		# 				components = {
		# 					{ type = "text", id=string.format("%06d", variables.score), font="main", size=8, }	
		# 				}
		# 			},
		# 	 		{
		# 				pos = {144,248,0},
		# 				components = {
		# 					{ type = "text", id="WORLD", font="main", size=8, }
		# 				}
		# 			},	
		# 	 		{
		# 				pos = {164,236,0},
		# 				components = {
		# 					{ type = "text", id=variables.world_name, font="main", size=8, align="center" }
		# 				}
		# 			},						
		# 			{
		# 				pos = {232,248,0},
		# 				components = {
		# 					{ type = "text", id="TIME", font="main", size=8, align="topright" }
		# 				}
		# 			},	
		# 			{
		# 				tag = "time_label",
		# 				pos = {232,240,0},
		# 				components = {
		# 					{ type = "text", id=tostring(variables.time), font="main", size=8, align="topright" }
		# 				}
		# 			},				
		# 			{
		# 				pos = {96, 232, 0},
		# 				type="sprite",
		# 				model="coin_counter"
		# 			},
		# 			{
		# 				pos = {108,240,0},
		# 				components = {
		# 					{ type = "text", id="x", font="main", size=8 }
		# 				}
		# 			},	
		# 			{
		# 				tag = "coin_label",
		# 				pos = {116, 240, 0},
		# 				components = {
		# 					{ type = "text", id=string.format("%02d", variables.coins), font="main", size=8, }	
		# 				}
		# 			},
		# 		}
		# 	}
		# },

        # add player
        mario = build.makePlayer(vars.stateInfo[vars.state], startPos[0], startPos[1])
        main.add(mario)
Beispiel #4
0
    def __init__(self, id: str, width, height, worldWidth: int,
                 worldHeight: int, playerModel: str, startPos):
        super().__init__(id, width, height)
        # adding pause button
        self.keyl.addKey(key=32, func=f)

        main = Entity(tag='main')
        main.camera = OrthoCamera(worldwidth=worldWidth * vars.tileSize,
                                  worldheight=worldHeight * vars.tileSize,
                                  camwidth=width,
                                  camheight=height,
                                  viewport=[0, 0, width, height],
                                  tag='maincam')
        self.add(main)

        # create the collision engine (maybe to put into the ctor of the room subclass)
        ce = CollisionEngine(80, 80, coll25=True)
        ce.addResponse(vars.tags.player_attack, vars.tags.foe,
                       CollisionResponse(onenter=func.foeIsHit))
        ce.addResponse(vars.tags.player, vars.tags.foe_attack,
                       CollisionResponse(onenter=build.playerIsHit))
        # ce.addResponse(vars.tags.player, vars.tags.bonus_brick_sensor, CollisionResponse(onenter=func.bonusBrickResponse))
        # ce.addResponse(vars.tags.player, vars.tags.mushroom, CollisionResponse(onenter=func.mushroomResponse))
        # ce.addResponse(vars.tags.player, vars.tags.warp, CollisionResponse(onenter = func.warpEnter, onleave= func.warpExit))
        # ce.addResponse(vars.tags.player, vars.tags.hotspot, CollisionResponse(onenter = func.hotspotEnter))
        # ce.addResponse(vars.tags.player, vars.tags.coin, CollisionResponse(onenter = func.coinResponse))
        # ce.addResponse(vars.tags.player, vars.tags.goomba, CollisionResponse(onenter = func.goombaResponse))
        # ce.addResponse(vars.tags.player, vars.tags.koopa, CollisionResponse(onenter = func.koopaResponse))

        self.addRunner(ce)
        self.addRunner(Scheduler())

        self.dw = DynamicWorld(256, 256, 'maincam')
        self.addRunner(self.dw)

        # add player
        mario = build.makePlayer(playerModel, startPos[0], startPos[1])
        main.add(mario)
        self.main = main

        # add score/lives stuff
        ui = Entity(tag='ui')
        ui.camera = OrthoCamera(worldwidth=256,
                                worldheight=256,
                                camwidth=256,
                                camheight=256,
                                viewport=[0, 0, 256, 256],
                                tag='uicam')
        ui.add(
            Text(tag='lives_label',
                 font='main',
                 text='LIVES ' + str(vars.lives),
                 color=[255, 255, 255, 255],
                 align=TextAlignment.topleft,
                 pos=[8, 248]))
        ui.add(
            Text(tag='energy_label',
                 font='main',
                 text='ENERGY ' + str(vars.energy),
                 color=[255, 255, 255, 255],
                 align=TextAlignment.topright,
                 pos=[248, 248]))
        self.add(ui)
Beispiel #5
0
    def __init__(self,
                 id: str,
                 width,
                 height,
                 collide=False,
                 addui: bool = True,
                 verbSetId: int = 0):
        super().__init__(id, width, height)
        self.collide = collide
        scumm.State.collision_enabled = collide
        uisize = scumm.Config.ui_height
        camWidth = engine.device_size[0]
        camHeight = engine.device_size[1] - uisize

        # get the verbset used in this room
        verbset: scumm.VerbSet = scumm.Config.verbSets[verbSetId]
        defv: scumm.Verb = scumm.Config.getVerb(verbset.defaultVerb)
        scumm.Config.verb = verbset.defaultVerb
        #verbs = settings.monkey.config['verbs']
        default_verb = scumm.Config.getVerb

        # add the main node
        main = Entity(tag='main')
        main.camera = OrthoCamera(width,
                                  height,
                                  camWidth,
                                  camHeight, [0, uisize, camWidth, camHeight],
                                  tag='maincam')

        # add the ui node
        if addui:
            main.addComponent(compo.HotSpotManager(lmbclick=func.walkto))

            ui = entity.Entity(tag='ui')
            ui.camera = cam.OrthoCamera(camWidth,
                                        uisize,
                                        camWidth,
                                        uisize, [0, 0, camWidth, uisize],
                                        tag='uicam')
            ui.add(
                entity.Text(font='ui',
                            text=defv.text,
                            color=scumm.Config.Colors.current_action,
                            align=entity.TextAlignment.bottom,
                            tag='current_verb',
                            pos=[camWidth / 2, 48, 0]))
            ui.addComponent(compo.HotSpotManager())
            inventory_node = entity.TextView(factory=makeInventoryButton,
                                             pos=(160, 0),
                                             size=(140, 48),
                                             fontSize=8,
                                             lines=6,
                                             deltax=26,
                                             tag='inventory')
            inventory_node.addComponent(compo.HotSpotManager())

            row = 2
            count = 0
            for a in verbset.verbs:
                col = 1 + count // 4
                x = 2 + (col - 1) * 46
                verb: scumm.Verb = scumm.Config.getVerb(a)
                print('here ' + a + ' ' + verb.text)
                ui.add(
                    se.VerbButton(
                        font='ui',
                        verbId=a,
                        colorInactive=scumm.Config.Colors.verb_unselected,
                        colorActive=scumm.Config.Colors.verb_selected,
                        align=entity.TextAlignment.bottomleft,
                        pos=[x, uisize - row * 8, 0]))
                count += 1
                row += 1
                if (row > 5):
                    row = 2
            self.scene.append(ui)
            self.scene.append(inventory_node)

            scumm.Config.resetVerb()

        # add the dialogue node
        dialogue_node = entity.TextView(factory=makeDialogueButton,
                                        size=[320, 56],
                                        fontSize=8,
                                        lines=6,
                                        deltax=26,
                                        tag='dialogue')
        dialogue_node.addComponent(compo.HotSpotManager())

        #ui.add (VerbButton (font='ui', text='Open', colorInactive = ScummConfig.Colors.verb_unselected, colorActive = ScummConfig.Colors.verb_selected, align = e.TextAlignment.bottomleft, pos = [0,0,0]))
        # ui.add (e.Text(font='ui', text=verbs[verbset[1]].text, color = [255, 255, 255, 255], align = e.TextAlignment.topleft, pos = [0, 56, 0]))
        # ui.add (e.Text(font='ui', text=verbs[verbset[1]].text, color = [255, 255, 255, 255], align = e.TextAlignment.bottomleft, pos = [0, 0, 0]))
        # ui.add (e.Text(font='ui', text=verbs[verbset[1]].text, color = [255, 255, 255, 255], align = e.TextAlignment.topright, pos = [320, 56, 0]))
        # ui.add (e.Text(font='ui', text=verbs[verbset[1]].text, color = [255, 255, 255, 255], align = e.TextAlignment.bottomright, pos = [320, 0, 0]))

        self.ref['main'] = main.children

        self.scene.append(main)
        self.scene.append(dialogue_node)

        # create a hotspot manager
        #self.engines.append(runner.HotSpotManager(lmbclick=func.walkto))
        self.engines.append(runner.Scheduler())
        if collide:
            #self.engines.append (runner.CollisionEngine(128, 128))
            ce = runner.CollisionEngine(128, 128)
            ce.addResponse(0, 1, runner.CollisionResponse(onenter=ciao))
            self.engines.append(ce)
        self.init.append(startupRoomUI(id))