change screen resolution at runtime

Ok i got it.
Ninja Style!

1.-Create some objects (cubes, spheres,…) that will work as buttons.

2.-On one of them create 2 mouse sensors.
First one set to “Mouse over any”
second one set to “Left Button”

3.-Connect both to a python controller script

4.- The script:


#Mackraken script
#Use it as u want

import Rasterizer as R
import GameLogic as G
import os 

#when rollover any object mouse will be visible
R.showMouse(1)

cont = G.getCurrentController()
obj = cont.getOwner()

#2 sensors, one to detect roll over an object and another to detect left mouse button #pressed

mclic = cont.getSensor("m2")
mover = cont.getSensor("m1")

#if mouse is over an object and you press LMB

if mover.isPositive() and mclic.isPositive():
#get the object
    obhit = mover.getHitObject()
#change the resolution
    if obhit.name=="OBr800":
        obj.debug = "800"
        prog = "C:/runtime/screen.exe"
        args = [" -p 0 0 800 600 C:/runtime/screen.exe"]
        
        print os.execvp(prog, (prog,) + tuple(args))
        
    elif obhit.name=="OBr1024":
        obj.debug = "1024"
        prog = "C:/runtime/screen.exe"
        args = [" -p 0 0 1024 768 C:/runtime/screen.exe"]
        
        print os.execvp(prog, (prog,) + tuple(args))