Beispiel #1
0
def load_scene(name):
    """
    Load data from cache/disk, parse it and create a new scene deactivated
    empty scene and reference it . Then parse all the gameobjects using
    GameObjectLoader (see the gameobjects docs), add them. Finally activate
    the scene and spawn the GameObjects.

    The name of the scene is the filename of the scene data file without
    the extension.
    """
    destroy_current()
    gvars.current_scene = Scene(name)
    gos = _load_gameobjects(load_raw_data(name))
    _spawn_gameobjects(gos)
    gvars.current_scene.activate()
Beispiel #2
0
    def initGame(self,
                 mainFile,
                 externalComponents=None,
                 buttonCallbacks=None):
        self._buttonCallbacks = buttonCallbacks
        self._externalComponents = externalComponents

        data = engine.file.getJsonData(mainFile)

        if "game" in data:
            if "title" in data["game"]:
                pygame.display.set_caption(data["game"]["title"])
            if "icon" in data["game"]:
                img = self.getRenderer().getImage(data["game"]["icon"])
                pygame.display.set_icon(img)

        if "mainScene" in data:
            scene = Scene(data["mainScene"])
            self.setActiveScene(scene)
Beispiel #3
0
 def __init__(self):
     Scene.__init__(self)
Beispiel #4
0
 def exit(self, screen):
     Scene.exit(self, screen)
Beispiel #5
0
 def loop(self, screen):
     Scene.loop(self, screen)
Beispiel #6
0
 def init(self):
     Scene.init(self)
Beispiel #7
0
 def add_scene(self, scn: Scene) -> Scene:
     scn.setup()
     self.scenes.append(scn)
     if self.iscene == -1:
         self.iscene = len(self.scenes) - 1
     return scn
Beispiel #8
0
 def new_scene(self) -> Scene:
     scn = Scene()
     return self.add_scene(scn)