Split-Screen (Using Python)

Hello, I am using a splitscreen script made by Goran from Nilunder.
It does work, to an extent. It works if there are no or small background objects.
This is hard to describe so I will use pictures:



In Picture 1 there is no big background object so it works perfectly.
In Picture 2 there is a large background object so the screen is split very oddly, as shown.
Sorry for the poor explanation, I do not know Python although I am learning. So I ask, can anyone please correct my problem? Goran made this for 2.60a so maybe that’s the problem, I don’t know.

The Blend: SplitScreenProblem.blend
The Script:

# Simple split screen script [Blender 2.60a] by:
#
# Goran Milovanovic (www.nilunder.com)
#
# Always (true level off) ________ Python (Module)


from bge import logic, render

def main():
    
    scene = logic.getCurrentScene()
    
    w_w = render.getWindowWidth()
    w_h = render.getWindowHeight()
    
    vcoords = ((0, w_w//2), (w_h//2, w_w))
    
    cams = [scene.objects[name] for name in ("Cam_0", "Cam_1")]
    
    for c, v in zip(cams, vcoords):
        c.useViewport = True
        c.setViewport(v[0], 0, v[1], w_h)

Thank you in advance.

Attachments


As the thread journeys into the third page, I say bump.
Sorry.

The script you posted is not an exact copy.

If you look at the script I posted in the original nilunder thread, you’ll notice that it does this:

vcoords = ((0, w_w//2), (w_w//2, w_w))

Your script is doing this:

vcoords = ((0, w_w//2), (w_h//2, w_w))

So, you’re using w_h where w_w should be.

PS:

You could have posted on nilunder - it’s my script, so I can answer quickly. :wink:

Thanks Goran, silly me.
I was going to post on Nilunder but it had been inactive (I know you were sick and had computer problems - usb…lol) so I decided against it. (Although you did make a video the hours later, lol).

Thanks again.

EDIT: I have also being using your tutorials to try and learn Python (the ray sensor one). I am making a SplitScreen FPS for fun and your tutorials are very handy, so I thank you, yet again. :wink: I will show you it’s finished state eventually and credit you where it’s due. :slight_smile: