• Advertisement
Sign in to follow this  

Game Maker (GML) Split Screen Script - Split Down Center

This topic is 661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've written a script to split the screen which I'll include below, the problem with the script is it does not split the screen according to how many players are present. The screen is meant to always split down the middle but instead splits the screen with the center point somewhere around the upper left hand corner of the screen, I have tried setting the variables according to the display dimensions and the window dimensions (application runs full screen.) Does anybody have any ideas of what might be wrong with the below script?

Sorry for the rushed post, headed out at the moment, will probably edit and upload screenshots later.

Any help would be much appreciated, Thanks!

Script:
 

//dwidth = floor(display_get_width()); //Display Height
//dheight = floor(display_get_height()); //Display Width
dwidth = floor(window_get_width()); //Display Height
dheight = floor(window_get_height()); //Display Width

view_object[0] = obj_player;
view_object[1] = obj_player2;
view_object[2] = obj_player;
view_object[3] = obj_player;

xp1 = 0; yp1 = 0; wp1 = dwidth; hp1 = dheight;

switch(numplayers){ //Currently set it this objects on create event.
case 1: //1 Player
xp1 = 0; yp1 = 0; wp1 = dwidth; hp1 = dheight;
view_xport[0] = xp1; view_yport[0] = yp1; view_wview[0] = wp1; view_hview[0] = hp1;
view_visible[0] = true; view_visible[1] = false; view_visible[2] = false; view_visible[3] = false;
break;
case 2: //2 Players
xp1 = 0; yp1 = 0; wp1 = dwidth/2; hp1 = dheight;
xp2 = dwidth/2; yp2 = 0; wp2 = dwidth/2; hp2 = dheight;
view_xport[0] = xp1; view_yport[0] = yp1; view_wview[0] = wp1; view_hview[0] = hp1;
view_xport[1] = xp2; view_yport[1] = yp2; view_wview[1] = wp2; view_hview[1] = hp2;
view_visible[0] = true; view_visible[1] = true; view_visible[2] = false; view_visible[3] = false;
break;
case 3: //3 Players
xp1 = 0; yp1 = 0; wp1 = dwidth; hp1 = dheight/2;
xp2 = 0; yp2 = dheight/2; wp2 = dwidth; hp2 = dheight/2;
xp3 = dwidth/2; yp3 = dheight/2; wp3 = dwidth; hp3 = dheight/2;
view_xport[0] = xp1; view_yport[0] = yp1; view_wview[0] = wp1; view_hview[0] = hp1;
view_xport[1] = xp2; view_yport[1] = yp2; view_wview[1] = wp2; view_hview[1] = hp2;
view_xport[2] = xp3; view_yport[2] = yp3; view_wview[2] = wp3; view_hview[2] = hp3;
view_visible[0] = true; view_visible[1] = true; view_visible[2] = true; view_visible[3] = false;
break;
case 4: //4 Players
xp1 = 0; yp1 = 0; wp1 = dwidth/2; hp1 = dheight/2;
xp2 = dwidth/2; yp2 = 0; wp2 = dwidth/2; hp2 = dheight/2;
xp3 = 0; yp3 = dheight/2; wp3 = dwidth; hp3 = dheight/2;
xp4 = dwidth/2; yp4 = dheight/2; wp4 = dwidth; hp4 = dheight/2;
view_xport[0] = xp1; view_yport[0] = yp1; view_wview[0] = wp1; view_hview[0] = hp1;
view_xport[1] = xp2; view_yport[1] = yp2; view_wview[1] = wp2; view_hview[1] = hp2;
view_xport[2] = xp3; view_yport[2] = yp3; view_wview[2] = wp3; view_hview[2] = hp3;
view_xport[3] = xp4; view_yport[3] = yp4; view_wview[3] = wp4; view_hview[3] = hp4;
view_visible[0] = true; view_visible[1] = true; view_visible[2] = true; view_visible[3] = true;
break;
default: // Single player visible with all other variables set to various default values.
xp1 = 0; yp1 = 0; wp1 = dwidth; hp1 = dheight;
xp2 = 0; yp2 = 0; wp2 = dwidth; hp2 = dheight;
xp3 = 0; yp3 = 0; wp3 = dwidth; hp3 = dheight;
xp4 = 0; yp4 = 0; wp4 = dwidth; hp4 = dheight;
view_xport[0] = xp1; view_yport[0] = yp1; view_wview[0] = wp1; view_hview[0] = hp1;
view_xport[1] = xp2; view_yport[1] = yp2; view_wview[1] = wp2; view_hview[1] = hp2;
view_xport[2] = xp3; view_yport[2] = yp3; view_wview[2] = wp3; view_hview[2] = hp3;
view_xport[3] = xp4; view_yport[3] = yp4; view_wview[3] = wp4; view_hview[3] = hp4;
view_visible[0] = true; view_visible[1] = false; view_visible[2] = false; view_visible[3] = false;
break;
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement