After I posted a comment in the last split-screen article about being able to use Global Values to simplify and speed up the process, I've had quite a few

people message me asking for an example on how to do this. So here it is: a split-screen tutorial by ShadowCaster.



First things first, you can download the example file from DC at this url: http://www.create-games.com/shadowcaster/examples/splitscreen.zip It's an MMF 1.5

file, sorry to everyone who doesnt have this, but I havent got any other packages installed at the moment. You can still follow through the tutorial to get

it working in the other Clickteam software that support sub-applications. Just a quick note: player 1 is controlled using WASD and player 2 is controlled

using the arrow keys, however you can change this at any time by pressing CTRL+Y.



To start, I'll explain the basics of what we're going to do, then I'll take you into the specifics. Basically to create a split-screen game you need to

create 3 frames: one, which we will call the "parent" frame, and it's child frames called "Player 1" and "Player 2". What we will be doing is adding the two

children frames to the parent frame, which will be used to communicate between the two.



If you dont understand, what we are doing is displaying the frame containing the player 1 information, and player 2 information at the same time. These will

be displayed on top of a third frame (called the "Parent") which stores information about each of it's children so that they can talk to each other.



In my example I created these frames as shown below.



Image



As you can see I've gone ahead and resized frames 3 and 4 to 2000x230 -- this will allow horizontal scrolling plus a 20px gap when the two frames are

displayed at 640x480 (this will allow you to add a menu or score table between the frames; it's a good idea to seperate them in some way otherwise it may get

confusing for the player).



Once you've created both frames exactly the same with all the elements you need, set player 1's object to whatever movement and player 2's movement to static

in the frame labelled "Player 1" and do the opposite for the "Player 2" frame. Make sure that in the "Player 2" frame, however, you select the second player

controlled object to get it's events from the player 2 controls. This can be done by clicking the "Player" tab in the movement setup and selecting "Assign

Movement to Player 2" as shown below.



Image



Now let's go back to the Parent frame. In the frame editor click Insert -> New Object Into Frame and select "Sub-Application" from the list.



Image



Click to place the object at the top-left corner of the screen. A dialog box will appear with many options available. Enter the frame you want the Sub-

Application object to display (in this case, the frame labelled "Player 1"). Because we want the sub-applications to communicate using global values, click

the Global Values option under "Share With Parent Application". As both the sub-applications we will be adding will be sharing their global values with the

parent, this is the same as simply having the sub-applications share the values with each other directly.



Image



Do the same as above, adding another sub-application and select to share global values, but this time set it to display the frame labelled "Player 2".





As this article isnt about scrolling I'm not going to go indepth on this part, but for the Player 1 frame, set the screen to follow the Player 1 controlled

object. Likewise for the Player 2 frame, set the screen to follow the Player 2 object. For more information on how to do this, you can see the above example

.



OK, now we're onto the trickey bit. Enter the event editor in the Player 1 frame and create a new "Always" event. Under "Special" click "Change a Global

Value -> Set" and select value A. In the expression editor select "Retrieve data from an object" and under the Player 1 object select "Position -> X

Coordinate". Do the same for the Y coordinate, but save it to Global Value B, and again set Global Value C to "Movement -> Current Direction Value" so that

the other frame knows which way your character is, not just positioned, but also which way it is facing. Do the same thing for the Player 2 frame, but

obviously save the X, Y and Direction values of the Player 2 object under global values D, E and F.



Image



We're almost done, now



Go back into the event editor for the Player 1 frame. Under the same Always event you created earlier, set the X position of the Player 2 object to global

value D, the Y position to value E and it's direction to value F. Do the same under the Player 2 frame for player 1, but use the Global Values A, B and C.





Image



Your done! Run your application to see everything working. You can see how it would be possible to adapt this method into a larger application with guns, and

so on.



Image



If you had any problems understanding this tutorial, or would like a working example, download the forementioned file (created with MMF 1.5).



Hope you found this tutorial informative, if you have any questions, feel free to DC Mail me.



Mike