Example #1
0
def scene_change(sceneOld, sceneNew):
    '''
    End of sceneOld, load sceneNew.
    Scene must be str: if scene = scene python object, name is scene.name
    '''
    scenes = gl.getSceneList()
    print("Scenes list in scene_change() =", scenes)
    # Check name
    scnName = []
    for scn in scenes:
        scnName.append(scn.name)
    if not sceneOld in scnName:
        print("  {} isn't in scenes list".format(sceneOld))
    else:
        gl.tempoDict["scene_change"].unlock()
        gl.tempoDict["scene_change"].reset()
        print("  Tempo scene_change reset and unlock")

        for scn in scenes:
            if scn.name == sceneOld:
                scn.end()
                print("  End of scene: {}".format(scn))
        try:
            gl.addScene(sceneNew)
            print("  Scene {0} added".format(sceneNew))
        except:
            print("  Scene {0} doesn't exist: Can't be set.".format(sceneNew))
Example #2
0
 def addOverlay(self):
     scene = self.getscene(self.getOverlaySceneId())
     self.setOverlaySceneId(self._id)
     if scene and scene != self._id:
         scene.replace(self._id)
     else:
         logic.addScene(self._id, 1)
Example #3
0
 def addBackground(self):
     scene = self.getscene(self.getBackgroundSceneId())
     self.setBackgroundSceneId(self._id)
     if scene and scene != self._id:
         scene.replace(self._id)
     else:
         logic.addScene(self._id, 0)
Example #4
0
def scene_change(sceneOld, sceneNew):
    '''
    End of sceneOld, load sceneNew.
    Scene must be str: if scene = scene python object, name is scene.name
    '''
    scenes = gl.getSceneList()
    print("Scenes list in scene_change() =", scenes)
    # Check name
    scnName = []
    for scn in scenes:
        scnName.append(scn.name)
    if not sceneOld in scnName:
        print("  {} isn't in scenes list".format(sceneOld))
    else:
        gl.tempoDict["scene_change"].unlock()
        gl.tempoDict["scene_change"].reset()
        print("  Tempo scene_change reset and unlock")

        for scn in scenes:
            if scn.name == sceneOld:
                scn.end()
                print("  End of scene: {}".format(scn))
        try:
            gl.addScene(sceneNew)
            print("  Scene {0} added".format(sceneNew))
        except:
            print("  Scene {0} doesn't exist: Can't be set.".format(sceneNew))
Example #5
0
def addScene(scenename, overlay=True):
    scene = getScene(scenename)
    
    if not scene:
        logic.addScene(scenename, overlay)
        return True
    return False
Example #6
0
def overlay_scene(scn, overlay=1):
    '''Note de la doc:
    This function is not effective immediately, the scene is queued and added
    on the next logic cycle where it will be available from getSceneList.
    Overlay = 1: overlay
    Overlay = 0: underlay
    '''

    gl.addScene(scn, overlay)
Example #7
0
	def Play(self):
		cont = logic.getCurrentController()
		scene = logic.getCurrentScene()
		mouse = cont.sensors['Mouse']
		mouseEvents = logic.mouse.events
		click = mouseEvents[events.LEFTMOUSE]		
		if click:
			logic.addScene('Level0')
			logic.addScene('Music')
Example #8
0
 def Play(self):
     cont = logic.getCurrentController()
     scene = logic.getCurrentScene()
     mouse = cont.sensors['Mouse']
     mouseEvents = logic.mouse.events
     click = mouseEvents[events.LEFTMOUSE]
     if click:
         logic.addScene('Level0')
         logic.addScene('Music')
Example #9
0
def overlay_scene_rank(scenes):
    '''Ajoute la sceène rank en overlay.'''

    scene_list = []
    for scn in scenes :
        scene_list.append(scn.name)

    if not "Rank" in scene_list:
        # Overlay la scène rank
        gl.addScene("Rank", 1)
Example #10
0
	def Update():
		if message1.positive:
			obj.playAction("CamMainAction",1.0,11.0,1,1,0.0,1,0.0,0,1.0)
		if obj.getActionFrame(1) > 10.5:
			obj.stopAction(1)
			obj.setActionFrame(0,1)
			
		if pause.positive and dict['paused'] == False:
			dict['paused'] = True
			logic.addScene('Pause')
			scene.suspend()
Example #11
0
    def Update():
        if message1.positive:
            obj.playAction("CamMainAction", 1.0, 11.0, 1, 1, 0.0, 1, 0.0, 0,
                           1.0)
        if obj.getActionFrame(1) > 10.5:
            obj.stopAction(1)
            obj.setActionFrame(0, 1)

        if pause.positive and dict['paused'] == False:
            dict['paused'] = True
            logic.addScene('Pause')
            scene.suspend()
Example #12
0
	def Init():
		if not 'init' in obj:
			obj['init'] = 1
			dict['level'] = 3
			if not 'Score' in scenes:
				logic.addScene('Score')
			if not 'score' in dict:
				dict['score'] = 0
			dict['levelScore'] = 0
			dict['levelClock']= 0
			dict['tank_kills'] = 0
			dict['rocket_kills'] = 0
			dict['breakable'] = False
Example #13
0
	def Init():
		if not 'init' in obj:
			obj['init'] = 1
			dict['level'] = 4
			if not 'Score' in scenes:
				logic.addScene('Score')
			if not 'score' in dict:
				dict['score'] = 0
			dict['levelScore'] = 0
			dict['levelClock']= 0
			dict['tank_kills'] = 0
			dict['rocket_kills'] = 0
			scene.objects['CamMain']['enemies'] = 1
Example #14
0
	def Update():
		#Camera shake animation. Used during explosions.
		if message1.positive:
			obj.playAction("CamMainAction",1.0,11.0,1,1,0.0,1,0.0,0,1.0) 
		if obj.getActionFrame(1) > 10.5:
			obj.stopAction(1)
			obj.setActionFrame(0,1)
		
		#Pause scene controller
		if pause.positive and dict['paused'] == False:
			dict['paused'] = True
			logic.addScene('Pause')
			scene.suspend()
Example #15
0
 def Init():
     if not 'init' in obj:
         obj['init'] = 1
         dict['level'] = 4
         if not 'Score' in scenes:
             logic.addScene('Score')
         if not 'score' in dict:
             dict['score'] = 0
         dict['levelScore'] = 0
         dict['levelClock'] = 0
         dict['tank_kills'] = 0
         dict['rocket_kills'] = 0
         scene.objects['CamMain']['enemies'] = 1
Example #16
0
 def Init():
     if not 'init' in obj:
         obj['init'] = 1
         dict['level'] = 3
         if not 'Score' in scenes:
             logic.addScene('Score')
         if not 'score' in dict:
             dict['score'] = 0
         dict['levelScore'] = 0
         dict['levelClock'] = 0
         dict['tank_kills'] = 0
         dict['rocket_kills'] = 0
         dict['breakable'] = False
Example #17
0
def groundDeathState(self):
	"""
	Documentation
	"""
	if ( not self.rig.isPlayingAction(5)):
		scene = logic.getCurrentScene()
		scene.suspend()
		# add game over scene
		logic.addScene("GameOver", 1)
	else:
		frame = self.rig.getActionFrame(5)
		audio = self.audio.getAudio(PlayerSoundConstant.BOUNCE)
		self.audio.playFrameSound(frame, [46], audio)
Example #18
0
def groundDeathState(self):
    """
	Documentation
	"""
    if (not self.rig.isPlayingAction(5)):
        scene = logic.getCurrentScene()
        scene.suspend()
        # add game over scene
        logic.addScene("GameOver", 1)
    else:
        frame = self.rig.getActionFrame(5)
        audio = self.audio.getAudio(PlayerSoundConstant.BOUNCE)
        self.audio.playFrameSound(frame, [46], audio)
Example #19
0
 def Init():
     if not 'init' in obj:
         obj['init'] = 1
         dict['level'] = 1
         dict['score'] = 0
         for i in scenes:
             if 'Controls' in i.name:
                 i.end()
         if not 'Score' in scenes:
             logic.addScene('Score')
         dict['levelScore'] = 0
         dict['levelClock'] = 0
         dict['tank_kills'] = 0
         dict['rocket_kills'] = 0
         dict['breakable'] = False
Example #20
0
 def Next():
     if obj['enemies'] < 1:
         for i in scenes:
             if 'Score' in i.name:
                 i.suspend()
         if obj['time'] > 45:  #delay between when the last tank is killed and the 'next' menu appears
             if dict['level'] == 0:
                 dict['score'] = 0
             else:
                 timeBonus = 50 - (int(dict['levelClock']))
                 if timeBonus >= 1:
                     dict['levelScore'] += timeBonus
             scene.suspend()
             logic.addScene('Next')
         obj['time'] += 1
Example #21
0
	def Next(): #Handles beating a level, adding score, and moving on to the next level.
		if obj['enemies'] < 1:
			for i in scenes:
					if 'Score' in i.name:
						i.suspend()
			if obj['time'] > 45: #delay between when the last tank is killed and the 'next' menu appears. Looks weird if its instant.
				if dict['level'] == 0:
					dict['score'] = 0 #No points awarded on instruction level (level 0).
				else:
					timeBonus = 50 - (int(dict['levelClock']))
					if timeBonus >= 1: #Added this in to avoid adding negative bonuses if player take longer than 50 seconds to beat a level.
						dict['levelScore'] += timeBonus
				scene.suspend()
				logic.addScene('Next') #The next scene is added as an overlay to show current score and show the "next level" button.
			obj['time'] += 1
Example #22
0
	def Init():
		if not 'init' in obj:
			obj['init'] = 1
			dict['level'] = 1
			dict['score'] = 0
			for i in scenes:
				if 'Controls' in i.name:
					i.end()
			if not 'Score' in scenes:
				logic.addScene('Score')
			dict['levelScore'] = 0
			dict['levelClock']= 0
			dict['tank_kills'] = 0
			dict['rocket_kills'] = 0
			dict['breakable'] = False
Example #23
0
	def Next():
		if obj['enemies'] < 1:
			for i in scenes:
					if 'Score' in i.name:
						i.suspend()
			if obj['time'] > 45: #delay between when the last tank is killed and the 'next' menu appears
				if dict['level'] == 0:
					dict['score'] = 0
				else:
					timeBonus = 50 - (int(dict['levelClock']))
					if timeBonus >= 1:
						dict['levelScore'] += timeBonus
				scene.suspend()
				logic.addScene('Next')
			obj['time'] += 1
Example #24
0
def setScene(name):
    """
	Deletes the game scene (if any) and loads a new one.

	.. note::
		The new scene will be initialized on the next logic frame.

	:param string name: Name of the scene to load. If none no scene will be loaded, but the current scene will be removed.
	"""
    global _change_scene_name

    if module.change_scene_frame == False:
        module._started = False
        if module.scene_game == None:
            logic.addScene(name, 0)
        else:
            if module.scene_behavior:
                module.scene_behavior.onExit()
                del module.scene_behavior
                module.scene_behavior = None
            module.scene_game.replace(name)
        if name:
            module.change_scene_frame = True
            _change_scene_name = name
        return

    #From here the scene is already replaced, now is time to initializate.
    if name:
        debug("Multiple calls to utils.setScene(), this call will be ignored.")
        return

    name = _change_scene_name
    scene = getSceneByName(name)
    if not scene: return

    module.change_scene_frame = False
    module.scene_game = scene

    if name in module.scene_behavior_dict:
        module.scene_behavior = (module.scene_behavior_dict[name])()
        b = module.scene_behavior
        b.scene = scene
        for ob in scene.objects:
            b.objects[ob.name] = ob
        b.init()
        b.baseInit()
        for bh in b.behaviors:
            bh.init()
Example #25
0
def setScene(name):
	"""
	Deletes the game scene (if any) and loads a new one.

	.. note::
		The new scene will be initialized on the next logic frame.

	:param string name: Name of the scene to load. If none no scene will be loaded, but the current scene will be removed.
	"""
	global _change_scene_name

	if module.change_scene_frame == False:
		module._started = False
		if module.scene_game == None:
			logic.addScene(name, 0)
		else:
			if module.scene_behavior:
				module.scene_behavior.onExit()
				del module.scene_behavior
				module.scene_behavior = None
			module.scene_game.replace(name)
		if name:
			module.change_scene_frame = True
			_change_scene_name = name
		return

	#From here the scene is already replaced, now is time to initializate.
	if name:
		debug("Multiple calls to utils.setScene(), this call will be ignored.")
		return

	name = _change_scene_name
	scene = getSceneByName(name)
	if not scene: return

	module.change_scene_frame = False
	module.scene_game = scene

	if name in module.scene_behavior_dict:
		module.scene_behavior = (module.scene_behavior_dict[name])()
		b = module.scene_behavior
		b.scene = scene
		for ob in scene.objects: b.objects[ob.name] = ob
		b.init()
		b.baseInit()
		for bh in b.behaviors: bh.init()
Example #26
0
    def __init__(self, world, name):
        try:
            scene = next(s for s in logic.getSceneList() if s.name == name)

        except StopIteration:
            scene = logic.addScene(name)

        self.bge_scene = scene
        self.physics_manager = PhysicsManager()

        super().__init__(world, name)
Example #27
0
    def __init__(self, world, name):
        try:
            scene = next(s for s in logic.getSceneList() if s.name == name)

        except StopIteration:
            scene = logic.addScene(name)

        self.bge_scene = scene
        self.physics_manager = PhysicsManager()

        super().__init__(world, name)
Example #28
0
 def toggle_menu(self, to_state=None):
     if to_state is not None:
         self.is_open = not to_state
     scenes = {_.name: _ for _ in G.getSceneList()}
     if self.is_open:
         #scenes['HUD'].suspend()
         if 'City' in scenes:
             scenes['City'].resume()
         self.menu.setVisible(False, True)
         if self.camera:
             self.camera['focalDepth'] = 1.0
         self.is_open = False
     else:
         if 'City' in scenes:
             scenes['City'].suspend()
         G.addScene('HUD', 1)
         if self.camera:
             self.camera['focalDepth'] = 0.1
         self.menu.setVisible(True, True)
         scenes['HUD'].resume()
         self.is_open = True
     self.update_screen_size()
Example #29
0
def select(own):
	field = FIELDS[ own['fieldNum'] ]

	if field == 'start':
		# Set all globalDicts based on fields
		logic.globalDict['stage'] = own['stages'][0]
		logic.globalDict['party1'] = own['party1'][0]
		logic.globalDict['party2'] = own['party2'][0]
		# 'players' must be handled a little differently

		# Start battlefield
		path = logic.expandPath('battlefield.blend')
		logic.startGame(path)

	elif field == 'party1' or field == 'party2':
		# TODO(kgeffen) Implement character/party creation
		return

		# Set name of party being dealt with
		logic.globalDict['party'] = own[field][0]

		logic.addScene('partyCreate')
		logic.getCurrentScene().suspend()
Example #30
0
def initPlayer(cont):
	#logic.globalDict['SunPos'] = scene.objects['Sun'].worldPosition
	#
	logic.globalDict['Player'] = {}

	own = cont.sensors['player'].owner
	rig = cont.sensors['arm_sensors'].owner
	backCam = cont.sensors['backCam_sensors'].owner
	orientController = scene.objects['orientController']

	groundSens = cont.sensors['groundSens']

	track_orient = cont.actuators['track_orient']

	# instance physic
	physic = PlayerPhysic(groundSens)

	# instance rig
	rig = PlayerRig(rig)

	# instance axis orient
	orientController = AxisOrientation(orientController)

	# instance player
	own = Player(own, rig, physic, track_orient, backCam)

	# load data
	own.loadData()

	# Add hud scene
	logic.addScene("HUD")

	# start with fall state
	own.switchState(PlayerState.FALL_STATE)

	logic.player = own
	logic.globalDict['player'] = own
Example #31
0
def onGameStart(cont):
    lyprint("LOADING FILES")

    try:
        verts = gamepath + "\\dsm\\cache\\landmass\\verts.npy"
        print("%s" % (verts))
        core.grid["verts"] = np.load(verts)

    except:
        core.grid["verts"] = np.ndarray((41, 41), dtype=object)
        core.genVerts = True

    LibLoad(gamepath + "\\data\\nature\\trees.blend",
            "Scene",
            load_actions=True)
    LibLoad(gamepath + "\\data\\chars\\dummy.blend",
            "Scene",
            load_actions=True)
    LibLoad(gamepath + "\\data\\runes.blend", "Scene", load_actions=True)
    LibLoad(gamepath + "\\data\\building\\fireShrine\\fireShrine_a0.blend",
            "Scene",
            load_actions=True)
    LibLoad(gamepath + "\\data\\building\\houses\\houses.blend",
            "Scene",
            load_actions=True)

    LibLoad(gamepath + "\\data\\mapping\\moonGate\\moonGate_a0.blend", "Scene")

    addScene("UI", 1)
    addScene("FX", 1)
    addScene("Skydome", 0)

    own = cont.owner
    core.cont = own
    own["core"] = core
    own["lookAngle"] = [0, 0]

    new_scene = _Scene.new(own.scene)
    core.joyIndex = gamekeys.joystick_init(own)

    core.joyPlugged = joysticks[core.joyIndex] != None

    own["time"] = ""
    own["date"] = ""
    own.addDebugProperty("time")
    own.addDebugProperty("date")

    own["underwater"] = False
    own["ingame"] = False

    new_scene.active_camera.fov = camFOV_fp if core.firstPerson else camFOV
def initPlayer(cont):
    print("Player initialization")
    loadConfFile()
    # Init game
    logic.camObstaclePosition = None

    initGame()

    # logic.globalDict['SunPos'] = scene.objects['Sun'].worldPosition
    #
    if not "Player" in logic.globalDict:
        logic.globalDict["Player"] = {}

    own = cont.sensors["player"].owner
    rig = cont.sensors["arm_sensors"].owner
    backCam = cont.sensors["backCam_sensors"].owner
    orientController = scene.objects["orientController"]

    track_orient = cont.actuators["track_orient"]

    # Active camera
    if logic.globalDict["CONFIGURATION"]["active_auto_cam"] == 1:
        print("OK")
        scene.active_camera = backCam

        # instance physic
    physic = PlayerPhysic()

    # instance rig
    rig = PlayerRig(rig)

    # instance axis orient
    orientController = AxisOrientation(orientController)

    # Instance player
    own = Player(own, rig, physic, track_orient, backCam)

    # Load data
    own.loadData()

    # Init equipement visibility
    own.fightManager.initEquipement()

    # Start pos from level
    if "level" in logic.globalDict:
        if "startPos" in logic.globalDict["level"]:
            own.worldPosition = logic.globalDict["level"]["startPos"]
            a = logic.globalDict["level"]["targetVec"]
            vec = [a[0], a[1], a[2]]
            own.alignAxisToVect(vec, 0, 1)
    else:
        logic.globalDict["level"] = {}
        vec = [1, 0, 0]
        own.alignAxisToVect(vec, 0, 1)

        # Add hud scene
    logic.addScene("HUD")

    # start with fall state
    own.switchState(PlayerState.FALL_STATE)

    logic.player = own
    logic.globalDict["player"] = own
Example #33
0
                self.obj.applyTorque([0.0, 0.0, - bank / 15], 1)
                self.obj.applyTorque([0.0, -bank / 12, 0.0], 1)
            if pitch > 0.001 and pitch < 90:
                self.obj.applyTorque([- pitch / 12, 0.0, 0.0], 1)
            if pitch < 0.001 and pitch > -90:
                self.obj.applyTorque([- pitch / 12, 0.0, 0.0], 1)


def change_focus(cont):
    mevents = G.mouse.events
    #if mousewheel moves down, bring focus closer
    if mevents[E.WHEELDOWNMOUSE] in (ACTIVE, ACTIVATED):
        camera['focalDepth'] -= 0.005
    #if mousewheel moves up, make focus further
    if mevents[E.WHEELUPMOUSE] in (ACTIVE, ACTIVATED):
        camera['focalDepth'] += 0.005
    camera['focalDepth'] = camera['focalDepth'] < 0.1 and 0.1 or camera['focalDepth']
    camera['focalDepth'] = camera['focalDepth'] > 1.0 and 1.0 or camera['focalDepth']

scene = G.getCurrentScene()
if scene.name == 'City':
    camera = get_object('Camera')
    scene.active_camera = camera
    cont = G.getCurrentController()
    ply = cont.owner
    movement_controls = MovementControl()
    G.addScene('HUD', 1)

    def update():
        movement_controls.update()
Example #34
0
 def add(self, key, overlay=True):
     logic.addScene(key, overlay)
Example #35
0
def primary():
	for scene in BACKGROUND_SCENES + OVERLAY_SCENES:
		logic.addScene(scene, 1)
Example #36
0
	def Gameover():	#Handles losing. 
		if obj['players'] < 1:
			if obj['time'] > 45:	#delay between when the last tank is killed and the 'gameover' menu appears
				scene.suspend()
				logic.addScene('Gameover')
			obj['time'] += 1
Example #37
0
 def Gameover():
     if obj['players'] < 1:
         if obj['time'] > 45:  #delay between when the last tank is killed and the 'gameover' menu appears
             scene.suspend()
             logic.addScene('Gameover')
         obj['time'] += 1
Example #38
0
 def Countdown():
     logic.addScene('Countdown', True)
     dict['newLevel'] += 1
Example #39
0
	def overlay(self, name):
		logic.addScene(name)
def initPlayer(cont):
    print("Player initialization")
    loadConfFile()
    # Init game
    logic.camObstaclePosition = None

    initGame()

    #logic.globalDict['SunPos'] = scene.objects['Sun'].worldPosition
    #
    if not 'Player' in logic.globalDict:
        logic.globalDict['Player'] = {}

    own = cont.sensors['player'].owner
    rig = cont.sensors['arm_sensors'].owner
    backCam = cont.sensors['backCam_sensors'].owner
    orientController = scene.objects['orientController']

    track_orient = cont.actuators['track_orient']

    # Active camera
    if logic.globalDict['CONFIGURATION']['active_auto_cam'] == 1:
        print("OK")
        scene.active_camera = backCam

    # instance physic
    physic = PlayerPhysic()

    # instance rig
    rig = PlayerRig(rig)

    # instance axis orient
    orientController = AxisOrientation(orientController)

    # Instance player
    own = Player(own, rig, physic, track_orient, backCam)

    # Load data
    own.loadData()

    # Init equipement visibility
    own.fightManager.initEquipement()

    # Start pos from level
    if ('level' in logic.globalDict):
        if ('startPos' in logic.globalDict['level']):
            own.worldPosition = logic.globalDict['level']['startPos']
            a = logic.globalDict['level']['targetVec']
            vec = [a[0], a[1], a[2]]
            own.alignAxisToVect(vec, 0, 1)
    else:
        logic.globalDict['level'] = {}
        vec = [1, 0, 0]
        own.alignAxisToVect(vec, 0, 1)

    # Add hud scene
    logic.addScene("HUD")

    # start with fall state
    own.switchState(PlayerState.FALL_STATE)

    logic.player = own
    logic.globalDict['player'] = own
Example #41
0
	def Countdown(): #Adds in the countdown scene you see at the start of every level. Then the CountdownAction function (below) takes over.
		logic.addScene('Countdown',True)
		dict['newLevel'] += 1
from bge import logic as g

c = g.getCurrentController()
o = c.owner

cena = g.getCurrentScene()

for i in c.sensors:
    exec(i.name+"=i")
    
#if ini.positive:
g.addScene("hud")
    
hud = g.getSceneList()[1].objects
barra = hud["barraDeVida"]

barra.localScale[0] = o['vida']/120

if sensorCollision.positive:
    o['vida']-= 1

if o ['vida'] < 1:
    o['vida'] = 0  
Example #43
0
	def Countdown():
		logic.addScene('Countdown',True)
		dict['newLevel'] += 1
Example #44
0
def GAME(cont):
	global CURRENT, PROFILE, DATA, WORLD, LEVEL, ACTIVE_LIBLOAD, GAME_STATE

	global SC_SCN, SC_RUN
	SC_SCN = cont.owner.scene
	SC_RUN = cont.owner

	scene = SC_SCN
	owner = SC_RUN

	spawn = owner.get("SPAWN", True)
	timer = owner.get("TIMER", None)
	black = owner.get("GFXBG", None)

	if spawn == False:
		#MAIN(cont)
		#GAME_STATE = "DONE"
		return "DONE"

	## SET SCENE ##
	if WORLD.get("NEWSCENE", None) != None and config.EMBEDDED_FIX == False:
		if WORLD["NEWSCENE"] != scene.name:
			if scene.replace(WORLD["NEWSCENE"]) == True:
				CURRENT["Level"] = None
				print(scene.name, WORLD["NEWSCENE"])
				GAME_STATE = "SCENE"
				return "SCENE"
			else:
				print("NOTICE: Scene '"+CURRENT["Scene"]+"' Not Found...")

	if GAME_STATE == "SCENE":
		settings.applyGraphics()

	CURRENT["Scene"] = scene.name

	## LEVEL DATA ##
	if WORLD.get("NEWLEVEL", None) != None:
		CURRENT["Level"] = WORLD["NEWLEVEL"]

	if CURRENT["Level"] == None and owner.get("MAP", None) != None:
		CURRENT["Level"] = owner["MAP"]+".blend"

	newmap = str(CURRENT["Level"])+scene.name

	WORLD["NEWLEVEL"] = CURRENT["Level"]
	WORLD["NEWSCENE"] = CURRENT["Scene"]

	if newmap not in PROFILE["LVLData"]:
		print("Initializing Level Data...", newmap)
		PROFILE["LVLData"][newmap] = settings.GenerateLevelData()

	LEVEL = PROFILE["LVLData"][newmap]

	## EARLY BAIL ##
	if config.EMBEDDED_FIX == True:
		owner["SPAWN"] = False
		GAME_STATE = "EMBEDDED"
		return "EMBEDDED"

	if black == None:
		owner["GFXBG"] = True
		GAME_STATE = "BLACK"
		return "BLACK"

	## LIBLOAD ##
	if owner.get("LIBLIST", None) == None:
		owner["LIBLIST"] = [COREBLENDS["ASSETS"]]
		for libblend in config.LIBRARIES:
			libblend = DATA["GAMEPATH"]+config.LIBRARY_PATH+"\\"+libblend+".blend"
			owner["LIBLIST"].append(libblend)
		GAME_STATE = "LIBLOAD"
		return "LIBLOAD"

	if ACTIVE_LIBLOAD != None:
		print(ACTIVE_LIBLOAD.libraryName, ACTIVE_LIBLOAD.progress)
		GAME_STATE = "LIBLOAD"
		return "LIBLOAD"

	if len(owner["LIBLIST"]) > 0:
		libblend = owner["LIBLIST"].pop(0)
		#if config.LIBLOAD_TYPE != "ASYNC":
		logic.LibLoad(libblend, "Scene", load_actions=True, verbose=False, load_scripts=True)
		print(libblend)
		#elif config.LIBLOAD_TYPE == "ASYNC":
		#	ACTIVE_LIBLOAD = logic.LibLoad(libblend, "Scene", load_actions=True, verbose=False, load_scripts=True, async=True)
		#	ACTIVE_LIBLOAD.onFinish = LIBCB

		GAME_STATE = "LIBLOAD"
		return "LIBLOAD"

	## HUD SCENE ##
	if timer == None:
		owner["TIMER"] = (config.UPBGE_FIX == False)*100

		owner.worldScale = [1,1,1]
		logic.addScene("HUD", 1)
		GAME_STATE = "HUD"
		return "HUD"

	elif timer <= 30:
		owner["TIMER"] += 1
		GAME_STATE = "TIMER"
		return "TIMER"

	## SPAWN ##
	if "CLIP" in owner:
		LEVEL["CLIP"] = owner["CLIP"]

	if spawn == True:
		LOAD(owner)
		SC_SCN.addObject("__gameloop__", owner, 0)
		owner["SPAWN"] = None
		GAME_STATE = "SPAWN"
		return "SPAWN"

	elif spawn == None:
		owner["SPAWN"] = False
		GAME_STATE = "DONE"
		return "DONE"

	GAME_STATE = "WAIT"
	return "WAIT"
Example #45
0
 def add(self, key, overlay=True):
     logic.addScene(key, overlay)