def onMouse(): Rasterizer.showMouse(True) cont = GameLogic.getCurrentController() mouse = cont.sensors["Mouse"] over = cont.sensors["Over"] if mouse.positive: hit = over.hitObject if hit is None: return print(hit.name) print(hit.children) if hit.name in buildings: deselectAll() hit.children["Base01.Selected"].setVisible(True) infoPanelShow(hit) addUnit() else: if hit.name in units: deselectAll() hit.children["Unit0.Selected"].setVisible(True) cont.owner["selected"] = hit["id"] infoPanelShow(hit) else: for target in scene.objects: if "Target" in target.name and target["id"] == cont.owner["selected"]: target.localPosition = over.hitPosition
def enable(c): """ Enable the mouse pointer and at the same time sets the mouse to the our center of the screen. Does not require any properties. """ print("client.mouse.enable") # Set the mouse to the default position try: Rasterizer.setMousePosition(Rasterizer.getWindowWidth() / 2, Rasterizer.getWindowHeight() / 2) except: pass # Enable the mouse Rasterizer.showMouse(True)
def screamHopelesslyUntilGodComesBack(): Rasterizer.showMouse(1) controller = bge.logic.getCurrentController(); owner = controller.owner; scene = bge.logic.getCurrentScene(); objects = scene.objects; bge.logic.LibLoad('//bluestar.blend','Scene',async=True).onFinish = loadBlend; bge.logic.LibLoad('//blackstar.blend','Scene',async=True).onFinish = loadBlend; scene.objects["Camera"].position = [0,0,9]; import GameLogic as g; g.objectSelected = None;
def setPlayers(): import Rasterizer # menu leaves mouse on if ID == 0: Rasterizer.showMouse(False) playcount = conf['PLAYER_COUNT'] if playcount != 1 and playcount != 2: cont.activate('set_camera') return True if ID != 0 and ID != 1: print("Unsupported number of players, running anyway") cont.activate('set_camera') return True # Single player game. no tricks if playcount == 1: if ID == 0: pass else: return False elif playcount == 2: # Split screen own_camera.useViewport = True w = Rasterizer.getWindowWidth() h = Rasterizer.getWindowHeight() if ID == 0: # Vert #own_camera.setViewport(0, h/2, w, h) # Hoz own_camera.setViewport(0, 0, int(w / 2), h) if ID == 1: # Vert #own_camera.setViewport(0, 0, w, h/2) # Hoz own_camera.setViewport(int(w / 2), 0, w, h) if not WITHOUT_CAMERA: cont.activate('set_camera') return True
def setPlayers(): import Rasterizer # menu leaves mouse on if ID==0: Rasterizer.showMouse(False) playcount = conf['PLAYER_COUNT'] if playcount != 1 and playcount != 2: cont.activate('set_camera') return True if ID != 0 and ID != 1: print("Unsupported number of players, running anyway") cont.activate('set_camera') return True # Single player game. no tricks if playcount == 1: if ID == 0: pass else: return False elif playcount == 2: # Split screen own_camera.useViewport = True w = Rasterizer.getWindowWidth() h = Rasterizer.getWindowHeight() if ID == 0: # Vert #own_camera.setViewport(0, h/2, w, h) # Hoz own_camera.setViewport(0, 0, int(w/2), h) if ID == 1: # Vert #own_camera.setViewport(0, 0, w, h/2) # Hoz own_camera.setViewport(int(w/2), 0, w, h) if not WITHOUT_CAMERA: cont.activate('set_camera') return True
def main(): try: conf = GameLogic.globalDict['CONFIG'] except: conf = GameLogic.globalDict['CONFIG'] = {} def confdef(opt, value): if opt not in conf: conf[opt] = value confdef('PLAYER_COUNT', 1) confdef('GRAPHICS_DETAIL', 2) # 2 == high confdef('GRAPHICS_GLSL', 1) # toggle # Keys # P1 confdef('KEY_UP_P1', GameKeys.UPARROWKEY) confdef('KEY_DOWN_P1', GameKeys.DOWNARROWKEY) confdef('KEY_LEFT_P1', GameKeys.LEFTARROWKEY) confdef('KEY_RIGHT_P1', GameKeys.RIGHTARROWKEY) # P2 confdef('KEY_UP_P2', GameKeys.WKEY) confdef('KEY_DOWN_P2', GameKeys.SKEY) confdef('KEY_LEFT_P2', GameKeys.AKEY) confdef('KEY_RIGHT_P2', GameKeys.DKEY) # P1 confdef('KEY_JUMP_P1', GameKeys.MKEY) confdef('KEY_THROW_P1', GameKeys.SPACEKEY) confdef('KEY_ACTION_P1', GameKeys.NKEY) # P2 confdef('KEY_JUMP_P2', GameKeys.GKEY) confdef('KEY_THROW_P2', GameKeys.JKEY) confdef('KEY_ACTION_P2', GameKeys.HKEY) # import Rasterizer Rasterizer.showMouse(True)
def showMouse(): Rasterizer.showMouse(1)
import Rasterizer as r r.showMouse(True)
def main(): Rasterizer.showMouse(1)
import Rasterizer as R from bge import logic, events cont = logic.getCurrentController() scn = logic.getCurrentScene() own = cont.owner R.showMouse(True) scene = logic.getCurrentScene() MouseOver = cont.sensors["MouseOver"] keyboard = logic.keyboard JUST_ACTIVATED = logic.KX_INPUT_JUST_ACTIVATED JUST_RELEASED = logic.KX_INPUT_JUST_RELEASED if __name__ == "__main__": if own['Draging'] and MouseOver.positive and own[ 'Selected'] in scene.objects: if not own['Selected']['Aktief']: own['Selected']["Aktief"] = True # Vind de nieuwe positie van de muiscursor # in 3D coordinaten op het grondvlak HitObject = MouseOver.hitObject HitPosition = MouseOver.hitPosition #print(HitObject,HitPosition) Xhit = HitPosition[0] Yhit = HitPosition[1] Zhit = HitPosition[2] own['Xhit'] = Xhit own['Yhit'] = Yhit own['Zhit'] = Zhit
def disable(c): """ Disable the mouse pointer by hiding the pointer. Does not require any of the properties. """ print("client.mouse.disable") Rasterizer.showMouse(False)
def initGUI(): R.showMouse(1) G.UIScene = G.getCurrentScene()
import Rasterizer as r r.showMouse(1)
def main(): Rasterizer.showMouse(1)
import Rasterizer Rasterizer.showMouse(0)
import Rasterizer Rasterizer.showMouse(1)
def initGUI(): R.showMouse(1) G.UIScene = G.getCurrentScene()
import GameLogic import Rasterizer #init stuff, show mouse if not hasattr(GameLogic,'init'): GameLogic.init = 1 Rasterizer.showMouse(1) # load controller, set sensors py = GameLogic.getCurrentController() always,move,click = py.sensors # load target "Cube" obj = GameLogic.getCurrentScene().getObjectList()["Rouge"] # find mouse if move.positive: pos = move.getHitPosition() # set "Cube" at mouse position on click if click.positive: obj.setPosition(pos)
def hideMouse(): Rasterizer.showMouse(0)
import bge import Rasterizer Rasterizer.showMouse(False) def main(): cont = bge.logic.getCurrentController() # The KX_GameObject that owns this controller. own = cont.owner # for scripts that deal with spacial logic own_pos = own.worldPosition # Some example functions, remove to write your own script. # check for a positive sensor, will run on any object without errors. print("Logic info for KX_GameObject", own.name) input = False for sens in cont.sensors: # The sensor can be on another object, we may want to use it own_sens = sens.owner print(" sensor:", sens.name, end=" ") if sens.positive: print("(true)") input = True else: print("(false)") for actu in cont.actuators: # The actuator can be on another object, we may want to use it
import bge import Rasterizer Rasterizer.showMouse(False) def main(): cont = bge.logic.getCurrentController() # The KX_GameObject that owns this controller. own = cont.owner # for scripts that deal with spacial logic own_pos = own.worldPosition # Some example functions, remove to write your own script. # check for a positive sensor, will run on any object without errors. print("Logic info for KX_GameObject", own.name) input = False for sens in cont.sensors: # The sensor can be on another object, we may want to use it own_sens = sens.owner print(" sensor:", sens.name, end=" ") if sens.positive: print("(true)") input = True else: print("(false)") for actu in cont.actuators:
def start(controller): Rasterizer.showMouse(True)
def disable(c): """ Disable the mouse pointer """ print('client.mouse.disable') Rasterizer.showMouse(False)
# Import Rasterizer import Rasterizer # Show mouse Rasterizer.showMouse(True)
import Rasterizer cont = GameLogic.getCurrentController() player = cont.getOwner() mousemove = cont.getSensor('mousemove') Rasterizer.showMouse(0) player.mouseX = mousemove.getXPosition() player.mouseY = mousemove.getYPosition() player.moveX = 0.0 player.moveY = 0.0 shoulderipo = cont.getActuator('shoulderipo') playerrot = cont.getActuator('playerrot') shoulder = shoulderipo.getOwner() player.deltaMouseX = player.mouseX - (Rasterizer.getWindowWidth() / 2) player.deltaMouseY = player.mouseY - (Rasterizer.getWindowHeight() / 2) player.moveX= (player.deltaMouseX - player.moveX) * player.mousefilter player.moveY= (player.deltaMouseY - player.moveY) * player.mousefilter player.rot -= (player.moveX * player.sensitivity) shoulder.pitch -= (player.moveY * player.sensitivity) GameLogic.addActiveActuator(playerrot, 1) GameLogic.addActiveActuator(shoulderipo, 1) Rasterizer.setMousePosition(Rasterizer.getWindowWidth() / 2, Rasterizer.getWindowHeight() / 2)
import bge, Rasterizer # Frequently used variables curScene = bge.logic.getCurrentScene() curCont = bge.logic.getCurrentController() scenes = bge.logic.getSceneList() text = bge.logic.globalDict["Text"] # Get the objects inventoryView = curScene.objects["InventoryView"] inventoryBackground = curScene.objects["InventoryBackground"] inventoryItem = curScene.objects["InventoryItem"] # Add the mouse pointer if needed Rasterizer.showMouse(True) inventoryItem.resolution = 4 inventoryItem["Text"] = scenes[0].objects["Player"]["Inventory"]
def enable(c): """ Enable the mouse pointer """ print('client.mouse.enable') Rasterizer.showMouse(True)