import bge keyboard = bge.logic.keyboard JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED #exit functions #======= def endpoint(funct, motion, dict, cont): print('endpoint', funct,motion) scene = bge.logic.getCurrentScene() scenes = bge.logic.getSceneList() main_scene = [scene for scene in scenes if scene.name=="main"][0] main_empty = main_scene.objects['Empty'] own = cont.owner import Settings load_timer = 100 shirt = scene.objects["Char4:Zshirtt1"] shoeR = scene.objects['Char4:Shoes02.R'] shoeL = scene.objects['Char4:Shoes02.L'] deck = scene.objects["deck"] throw_deck = scene.objectsInactive["throw_deck"] cam = scene.objects['Camera.003'] c_move = .025 #color move amount if funct == 'exit': print("exit function", motion) bge.logic.endGame() if funct == 'restart': print("restart function", motion) bge.logic.restartGame() if funct == 'shirt color r': s_color = shirt.color s_color_r = s_color[0] if motion == 'inc': if s_color_r < 1: s_color_r += c_move s_color_r = round(s_color_r, 2) else: s_color_r = 1 if motion == 'dec': if s_color_r > c_move: s_color_r -= c_move s_color_r = round(s_color_r, 2) else: s_color_r = 0 new_col = [s_color_r, s_color[1], s_color[2], s_color[3]] shirt.color = new_col dict['shirt_color_r'] = new_col[0] if funct == 'shirt color g': s_color = shirt.color s_color_g = s_color[1] if motion == 'inc': if s_color_g < 1: s_color_g += c_move s_color_g = round(s_color_g, 2) else: s_color_rg = 1 if motion == 'dec': if s_color_g > c_move: s_color_g -= c_move s_color_g = round(s_color_g, 2) else: s_color_g = 0 new_col = [s_color[0], s_color_g, s_color[2], s_color[3]] shirt.color = new_col dict['shirt_color_g'] = new_col[1] if funct == 'shirt color b': s_color = shirt.color s_color_b = s_color[2] if motion == 'inc': if s_color_b < 1: s_color_b += c_move s_color_b = round(s_color_b, 2) else: s_color_b = 1 if motion == 'dec': if s_color_b > c_move: s_color_b -= c_move s_color_b = round(s_color_b, 2) else: s_color_b = 0 new_col = [s_color[0], s_color[1], s_color_b, s_color[3]] shirt.color = new_col print(new_col) dict['shirt_color_b'] = new_col[2] if funct == 'shoe color r': s_color = shoeL.color s_color_r = s_color[0] if motion == 'inc': if s_color_r < 1: s_color_r += c_move s_color_r = round(s_color_r, 2) else: s_color_r = 1 if motion == 'dec': if s_color_r > c_move: s_color_r -= c_move s_color_r = round(s_color_r, 2) else: s_color_r = 0 new_col = [s_color_r, s_color[1], s_color[2], s_color[3]] shoeL.color = new_col shoeR.color = new_col dict['shoe_color_r'] = new_col[0] if funct == 'shoe color g': s_color = shoeL.color s_color_g = s_color[1] if motion == 'inc': if s_color_g < 1: s_color_g += c_move s_color_g = round(s_color_g, 2) else: s_color_rg = 1 if motion == 'dec': if s_color_g > c_move: s_color_g -= c_move s_color_g = round(s_color_g, 2) else: s_color_g = 0 new_col = [s_color[0], s_color_g, s_color[2], s_color[3]] shoeL.color = new_col shoeR.color = new_col dict['shoe_color_g'] = new_col[1] if funct == 'shoe color b': s_color = shoeL.color s_color_b = s_color[2] if motion == 'inc': if s_color_b < 1: s_color_b += c_move s_color_b = round(s_color_b, 2) else: s_color_b = 1 if motion == 'dec': if s_color_b > c_move: s_color_b -= c_move s_color_b = round(s_color_b, 2) else: s_color_b = 0 new_col = [s_color[0], s_color[1], s_color_b, s_color[3]] shoeL.color = new_col shoeR.color = new_col print(new_col) dict['shoe_color_b'] = new_col[2] if funct == 'deck color r': s_color = deck.color s_color_r = s_color[0] if motion == 'inc': if s_color_r < 1: s_color_r += c_move s_color_r = round(s_color_r, 2) else: s_color_r = 1 if motion == 'dec': if s_color_r > c_move: s_color_r -= c_move s_color_r = round(s_color_r, 2) else: s_color_r = 0 new_col = [s_color_r, s_color[1], s_color[2], s_color[3]] deck.color = new_col throw_deck.color = new_col dict['deck_color_r'] = new_col[0] if funct == 'deck color g': s_color = deck.color s_color_g = s_color[1] if motion == 'inc': if s_color_g < 1: s_color_g += c_move s_color_g = round(s_color_g, 2) else: s_color_rg = 1 if motion == 'dec': if s_color_g > c_move: s_color_g -= c_move s_color_g = round(s_color_g, 2) else: s_color_g = 0 new_col = [s_color[0], s_color_g, s_color[2], s_color[3]] deck.color = new_col throw_deck.color = new_col dict['deck_color_g'] = new_col[1] if funct == 'deck color b': s_color = deck.color s_color_b = s_color[2] if motion == 'inc': if s_color_b < 1: s_color_b += c_move s_color_b = round(s_color_b, 2) else: s_color_b = 1 if motion == 'dec': if s_color_b > c_move: s_color_b -= c_move s_color_b = round(s_color_b, 2) else: s_color_b = 0 new_col = [s_color[0], s_color[1], s_color_b, s_color[3]] deck.color = new_col throw_deck.color = new_col print(new_col) dict['deck_color_b'] = new_col[2] if funct == 'shirt logo': logo = dict['shirt_logo'] logo1 = shirt.meshes[0].materials[0].textures[6] logo2 = shirt.meshes[0].materials[0].textures[7] logo3 = shirt.meshes[0].materials[0].textures[5] if motion == 'inc': if logo == 0: logo = 1 elif logo == 1: logo = 2 elif logo == 2: logo = 3 elif logo == 3: logo = 0 if motion == 'dec': if logo == 0: logo = 3 elif logo == 1: logo = 0 elif logo == 2: logo = 1 elif logo == 3: logo = 2 if logo == 1: logo1.diffuseIntensity = 1 logo2.diffuseIntensity = 0 logo1.diffuseFactor = 1 logo2.diffuseFactor = 0 logo3.diffuseIntensity = 0 logo3.diffuseFactor = 0 if logo == 2: logo1.diffuseIntensity = 0 logo1.diffuseFactor = 0 logo2.diffuseIntensity = 1 logo2.diffuseFactor = 1 logo3.diffuseIntensity = 0 logo3.diffuseFactor = 0 if logo == 3: logo1.diffuseIntensity = 0 logo1.diffuseFactor = 0 logo2.diffuseIntensity = 0 logo2.diffuseFactor = 0 logo3.diffuseIntensity = 1 logo3.diffuseFactor = 1 if logo == 0: logo1.diffuseIntensity = 0 logo2.diffuseIntensity = 0 logo1.diffuseFactor = 0 logo2.diffuseFactor = 0 logo3.diffuseIntensity = 0 logo3.diffuseFactor = 0 dict['shirt_logo'] = logo if funct == 'brightness / contrast on': if motion == 'inc': cont.activate(cam.actuators["bc"]) cam['bc'] = 1 dict['bc'] = 1 else: cont.activate(cam.actuators["bc_off"]) cam['bc'] = 0 dict['bc'] = 0 if funct == 'brightness value': b = cam['BC_BRIGHTNESS'] if motion == 'inc': b += .05 else: b -= .05 cam['BC_BRIGHTNESS'] = round(b,2) dict['BC_BRIGHTNESS'] = round(b,2) if funct == 'contrast value': b = cam['BC_CONTRAST'] if motion == 'inc': b += .05 else: b -= .05 cam['BC_CONTRAST'] = round(b,2) dict['BC_CONTRAST'] = round(b,2) if funct == 'hdr on': if motion == 'inc': cont.activate(cam.actuators["hdr"]) cam['hdr'] = 1 dict['hdr'] = 1 else: cont.activate(cam.actuators["hdr_off"]) cam['hdr'] = 0 dict['hdr'] = 0 if funct == 'avgL': b = cam['avgL'] if motion == 'inc': b += .05 else: b -= .05 cam['avgL'] = round(b,2) dict['avgL'] = round(b,2) if funct == 'hdr strength': b = cam['HDRamount'] if motion == 'inc': b += .05 else: b -= .05 cam['HDRamount'] = round(b,2) dict['HDRamount'] = round(b,2) if funct == 'ao on': if motion == 'inc': cont.activate(cam.actuators["ao"]) cam['ao'] = 1 dict['ao'] = 1 else: cont.activate(cam.actuators["ao_off"]) cam['ao'] = 0 dict['ao'] = 0 if funct == 'ao width': b = cam['aowidth'] if motion == 'inc': b += 1 else: b -= 1 cam['aowidth'] = round(b,2) dict['aowidth'] = round(b,2) if funct == 'ao radius': b = cam['aoradius'] if motion == 'inc': b += 1 else: b -= 1 cam['aoradius'] = round(b,2) dict['aoradius'] = round(b,2) if funct == 'ao only': b = cam['onlyAO'] if motion == 'inc': b = 1 else: b = 0 cam['onlyAO'] = b dict['onlyAO'] = b if funct == 'dof on': if motion == 'inc': cont.activate(cam.actuators["DOF"]) cam['dof_on'] = 1 dict['dof_on'] = 1 else: cont.activate(cam.actuators["DOF_off"]) cam['dof_on'] = 0 dict['dof_on'] = 0 if funct == 'sun strength': b = cam['sun_strength'] if motion == 'inc': b += .05 else: b -= .05 cam['sun_strength'] = round(b,2) dict['sun_strength'] = round(b,2) if 'sun33' in scene.objects: sun = scene.objects['sun33'] sun.energy = b if funct == 'ambient strength': b = cam['ambient_strength'] if motion == 'inc': b += .05 else: b -= .05 cam['ambient_strength'] = round(b,2) dict['ambient_strength'] = round(b,2) if 'sun33' in scene.objects: scene.world.envLightEnergy = b if funct == 'sun rot x': #b = cam['sun_rot_x'] b=0 if motion == 'inc': b += .05 else: b -= .05 if 'camposEmpty' in scene.objects: em = scene.objects['camposEmpty'] rot = [ b, 0.0, 0] em.applyRotation(rot,True) cam['sun_rot_x'] = round(b,2) dict['sun_rot_x'] = round(b,2) if funct == 'sun rot y': #b = cam['sun_rot_y'] b=0 if motion == 'inc': b += .05 else: b -= .05 if 'camposEmpty' in scene.objects: em = scene.objects['camposEmpty'] rot = [ 0, b, 0] em.applyRotation(rot,True) cam['sun_rot_y'] = round(b,2) dict['sun_rot_y'] = round(b,2) #levels if funct == 'Demo Scene': if motion == 'inc': level = "pats" main_empty["level"] = "pats" own["level"] = level Settings.writeSettings() Settings.readSettings() #cont.activate(own.actuators['restart']) #Settings.loadlevel() dict['load_timer'] = load_timer dict['reload_timer'] = 250 dict['overlay_fadein'] = 1 if funct == 'Park A': if motion == 'inc': level = "j_scene" main_empty["level"] = "j_scene" own["level"] = level Settings.writeSettings() Settings.readSettings() #cont.activate(own.actuators['restart']) #Settings.loadlevel() dict['load_timer'] = load_timer dict['reload_timer'] = 250 dict['overlay_fadein'] = 1 if funct == 'Empty Lot': if motion == 'inc': level = "lot" main_empty["level"] = "lot" own["level"] = level Settings.writeSettings() Settings.readSettings() #cont.activate(own.actuators['restart']) #Settings.loadlevel() dict['load_timer'] = load_timer dict['reload_timer'] = 250 dict['overlay_fadein'] = 1 if funct == 'Training': if motion == 'inc': level = "train" main_empty["level"] = "train" own["level"] = level Settings.writeSettings() Settings.readSettings() #cont.activate(own.actuators['restart']) #Settings.loadlevel() dict['load_timer'] = load_timer dict['reload_timer'] = 250 dict['overlay_fadein'] = 1 if funct == 'Spine': if motion == 'inc': level = "spine" main_empty["level"] = "spine" own["level"] = level Settings.writeSettings() Settings.readSettings() #cont.activate(own.actuators['restart']) #Settings.loadlevel() dict['load_timer'] = load_timer dict['reload_timer'] = 250 dict['overlay_fadein'] = 1 if funct == 'Warehouse': if motion == 'inc': level = "warehouse" main_empty["level"] = "warehouse" own["level"] = level Settings.writeSettings() Settings.readSettings() #cont.activate(own.actuators['restart']) #Settings.loadlevel() dict['load_timer'] = load_timer dict['reload_timer'] = 250 dict['overlay_fadein'] = 1 #======= #end exit functions def get_c_list(dict): #main menu if dict['mlevel'] == 0: dict['current_list'] = ['settings', 'level', 'replay', 'restart', 'exit'] #opt = dict['current_list'][dict['current_index']] if dict['mlevel'] == 1: if dict['lv0_opt'] == 'settings': #if opt == 'settings': dict['current_list'] = ['graphics', 'player', 'level', 'camera', 'physics'] if dict['lv0_opt'] == 'replay': dict['current_list'] = ['enter replay', 'recorder on', 'record length'] if dict['lv0_opt'] == 'level': dict['current_list'] = ['Demo Scene', 'Empty Lot', 'Park A', 'Training', 'Spine', 'Warehouse'] if dict['mlevel'] == 2: if dict['lv1_opt'] == 'graphics': #if opt == 'settings': dict['current_list'] = ['brightness / contrast', 'ao', 'hdr', 'dof'] if dict['mlevel'] == 2: if dict['lv1_opt'] == 'player': #if opt == 'settings': dict['current_list'] = ['shirt color r', 'shirt color g', 'shirt color b', 'shoe color r', 'shoe color g', 'shoe color b','deck color r', 'deck color g', 'deck color b', 'shirt logo'] if dict['mlevel'] == 2: if dict['lv1_opt'] == 'level': #if opt == 'settings': dict['current_list'] = ['sun strength', 'ambient strength', 'sun rot x', 'sun rot y', 'shadow on'] if dict['mlevel'] == 3: if dict['lv2_opt'] == 'ao': dict['current_list'] = ['ao on', 'ao radius', 'ao width', 'ao only'] if dict['lv2_opt'] == 'brightness / contrast': dict['current_list'] = ['brightness / contrast on', 'brightness value', 'contrast value'] if dict['lv2_opt'] == 'hdr': dict['current_list'] = ['hdr on', 'avgL', 'hdr strength'] if dict['lv2_opt'] == 'dof': dict['current_list'] = ['dof on'] def get_inputs(dict, cont): #opt = dict['current_list'][dict['current_index']] #b if keyboard.events[bge.events.LEFTARROWKEY] == JUST_ACTIVATED or (dict['bBut'] == False and dict['last_bBut'] == True): if dict['current_index'] not in dict['menu_end_points']: #print('lkey') if dict['mlevel'] == 2: dict['mlevel'] = 1 dict['current_index'] = dict['lv1_index'] elif dict['mlevel'] == 1: dict['mlevel'] = 0 dict['current_index'] = dict['lv0_index'] elif dict['mlevel'] == 3: dict['mlevel'] = 2 dict['current_index'] = dict['lv2_index'] else: pass # funct = dict['current_index'] # motion = 'dec' # endpoint(funct, motion, dict) #a if (keyboard.events[bge.events.RIGHTARROWKEY] == JUST_ACTIVATED) or (dict['aBut'] == False and dict['last_aBut'] == True): if dict['current_opt'] not in dict['menu_end_points']: if dict['mlevel'] == 0: dict['lv0_opt'] = dict['current_list'][dict['current_index']] dict['lv0_index'] = dict['current_index'] dict['mlevel'] = 1 dict['lv1_index'] = 0 dict['current_index'] = 0 elif dict['mlevel'] == 1: dict['lv1_opt'] = dict['current_list'][dict['current_index']] dict['lv1_index'] = dict['current_index'] dict['mlevel'] = 2 dict['lv2_index'] = 0 dict['current_index'] = 0 elif dict['mlevel'] == 2: dict['lv2_opt'] = dict['current_list'][dict['current_index']] dict['lv2_index'] = dict['current_index'] dict['mlevel'] = 3 dict['lv3_index'] = 0 dict['current_index'] = 0 elif dict['mlevel'] == 3: dict['lv3_opt'] = dict['current_list'][dict['current_index']] dict['lv3_index'] = dict['current_index'] #dict['mlevel'] = 3 #dict['lv3_index'] = 0 dict['current_index'] = 0 else: pass funct = dict['current_opt'] motion = 'inc' endpoint(funct, motion, dict, cont) #down if keyboard.events[bge.events.DOWNARROWKEY] == JUST_ACTIVATED or (dict['ddPad'] == False and dict['last_ddPad'] == True): if dict['current_index'] < (len(dict['current_list']) - 1): dict['current_index'] += 1 if dict['mlevel'] == 0: dict['lv0_index'] = dict['current_index'] if dict['mlevel'] == 1: dict['lv1_index'] = dict['current_index'] if dict['mlevel'] == 2: dict['lv2_index'] = dict['current_index'] if dict['mlevel'] == 3: dict['lv3_index'] = dict['current_index'] #up if keyboard.events[bge.events.UPARROWKEY] == JUST_ACTIVATED or (dict['udPad'] == False and dict['last_udPad'] == True): if dict['current_index'] > 0: dict['current_index'] -= 1 if dict['mlevel'] == 0: dict['lv0_index'] = dict['current_index'] if dict['mlevel'] == 1: dict['lv1_index'] = dict['current_index'] if dict['mlevel'] == 2: dict['lv2_index'] = dict['current_index'] if dict['mlevel'] == 3: dict['lv3_index'] = dict['current_index'] #left if dict['ldPad'] == False and dict['last_ldPad'] == True: if dict['current_opt'] in dict['menu_end_points']: funct = dict['current_opt'] motion = 'dec' endpoint(funct, motion, dict, cont) #right if dict['rdPad'] == False and dict['last_rdPad'] == True: if dict['current_opt'] in dict['menu_end_points']: funct = dict['current_opt'] motion = 'inc' endpoint(funct, motion, dict, cont) def init(own, dict): print('initing') own['inited'] = True dict['lv0_opt'] = 0 dict['lv0_index'] = 0 dict['lv1_opt'] = 0 dict['lv1_index'] = 0 dict['lv2_opt'] = 0 dict['lv2_index'] = 0 dict['lv3_opt'] = 0 dict['lv3_index'] = 0 dict['current_list'] = [''] dict['current_index'] = 0 dict['mlevel'] = 0 dict['current_opt'] = '' dict['pause_menu_text'] = '' dict['menu_end_points'] = ['exit', 'restart', 'shirt color r', 'shirt color g', 'shirt color b', 'shoe color r', 'shoe color g', 'shoe color b','deck color r', 'deck color g', 'deck color b', 'shirt logo', 'brightness / contrast on', 'brightness value', 'contrast value', 'hdr on', 'avgL', 'hdr strength', 'ao on', 'ao radius', 'ao width', 'ao only', 'dof on', 'sun strength', 'sun rot x', 'sun rot y', 'shadow on', 'ambient strength', 'Demo Scene', 'Empty Lot', 'Park A', 'Training', 'Spine', 'Warehouse'] def output(dict): try: opt = dict['current_list'][dict['current_index']] except: print('broken!!', dict['current_list'], dict['current_index']) dict['current_opt'] = opt #print(dict['lv1_index'], 'level: ', dict['mlevel'], dict['lv0_opt'], dict['current_index'], dict['current_list'], dict['current_opt']) outp = 'menu > ' if dict['mlevel'] == 0: outp = outp + dict['current_opt'] if dict['mlevel'] == 1: outp = outp + dict['lv0_opt'] +' > ' + dict['current_opt'] if dict['mlevel'] == 2: outp = outp + dict['lv0_opt'] +' > ' + dict['lv1_opt'] + ' > ' + dict['current_opt'] if dict['mlevel'] == 3: outp = outp + dict['lv0_opt'] +' > ' + dict['lv1_opt'] + ' > ' + dict['lv2_opt'] + ' > ' + dict['current_opt'] #print(outp) #print(dict['current_opt']) if dict['current_opt'] in dict['menu_end_points']: #print('adding end point value') if dict['current_opt'] == 'shirt color r': outp = outp + ': ' + str(dict['shirt_color_r']) print(outp + ': ' + str(dict['shirt_color_r'])) if dict['current_opt'] == 'shirt color g': outp = outp + ': ' + str(dict['shirt_color_g']) if dict['current_opt'] == 'shirt color b': outp = outp + ': ' + str(dict['shirt_color_b']) if dict['current_opt'] == 'shoe color r': outp = outp + ': ' + str(dict['shoe_color_r']) print(outp + ': ' + str(dict['shoe_color_r'])) if dict['current_opt'] == 'shoe color g': outp = outp + ': ' + str(dict['shoe_color_g']) if dict['current_opt'] == 'shoe color b': outp = outp + ': ' + str(dict['shoe_color_b']) if dict['current_opt'] == 'deck color r': outp = outp + ': ' + str(dict['deck_color_r']) print(outp + ': ' + str(dict['deck_color_r'])) if dict['current_opt'] == 'deck color g': outp = outp + ': ' + str(dict['deck_color_g']) if dict['current_opt'] == 'deck color b': outp = outp + ': ' + str(dict['deck_color_b']) if dict['current_opt'] == 'shirt logo': outp = outp + ': ' + str(dict['shirt_logo']) if dict['current_opt'] == 'brightness / contrast on': outp = outp + ': ' + str(dict['bc']) if dict['current_opt'] == 'brightness value': outp = outp + ': ' + str(dict['BC_BRIGHTNESS']) if dict['current_opt'] == 'contrast value': outp = outp + ': ' + str(dict['BC_CONTRAST']) if dict['current_opt'] == 'hdr on': outp = outp + ': ' + str(dict['hdr']) if dict['current_opt'] == 'avgL': outp = outp + ': ' + str(dict['avgL']) if dict['current_opt'] == 'hdr strength': outp = outp + ': ' + str(dict['HDRamount']) if dict['current_opt'] == 'ao on': outp = outp + ': ' + str(dict['ao']) if dict['current_opt'] == 'ao width': outp = outp + ': ' + str(dict['aowidth']) if dict['current_opt'] == 'ao radius': outp = outp + ': ' + str(dict['aoradius']) if dict['current_opt'] == 'ao only': outp = outp + ': ' + str(dict['onlyAO']) if dict['current_opt'] == 'dof on': outp = outp + ': ' + str(dict['dof_on']) if dict['current_opt'] == 'sun strength': outp = outp + ': ' + str(dict['sun_strength']) if dict['current_opt'] == 'sun rot x': outp = outp + ': ' + str(dict['sun_rot_x']) if dict['current_opt'] == 'sun rot y': outp = outp + ': ' + str(dict['sun_rot_y']) if dict['current_opt'] == 'shadow on': outp = outp + ': ' + str(dict['shadow_on']) if dict['current_opt'] == 'ambient strength': outp = outp + ': ' + str(dict['ambient_strength']) dict['pause_menu_text'] = outp def main(cont): own = cont.owner dict = bge.logic.globalDict if 'inited' not in own: init(own, dict) get_c_list(dict) get_inputs(dict, cont) get_c_list(dict) output(dict)