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.
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.
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.
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.
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.
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.
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.
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.
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.
Very very very nice, ShadowCaster. I'm saving this page on my computer in case I need it in future! Nice a simple, despite the complex things you need to do.
The "ShadowCaster" logo? It was made in Maya using just two lights One facing directly at the camera with a lens flare effect, and one facing up from below the camera with a fog effect. I was just playing around with lights one day and managed to make that without really trying
great article, thanks shadow. the problem is, of course, that with this method you need twice the amount of graphics as you have two levels for every one proper level... if you see what i mean. good nontheless... i was thinking of putting splitscreen into my next game and this'll help a lot.
In MMF you can just select the level and click copy then paste in the storyboard, then all you have to do is change the movement from the player 1 object to the player 2 object.
I've been trying to think of a way so you can just have 1 level and link each sub-app link to the same level, but as far as I can see there is no easy way to differentiate between which sub-app is which.
Actually, a thought would be to use global values... set GV A to 1 when you load level 1, then set an internal counter to the value of GV A, then once the first sub app is loaded, set GV A to 2, then load level 2 and set an internal counter so to GV A again... Though this would require a bit of fiddling, but would be possible. Probably best to give it a go if your level is extremely large (in terms of memory, not physically).
Karl: If your in Kindergarden to college/uni/tafe, then you can get an academic version for VERY cheap. It's exactly the same as the full version except about $300 cheaper
Hey, this is going to help me a lot, ShadowCaster! But could you use arrays instead?
And just to give some advice: For split-screen games with lots of collisions, weapons, etc., download and use the 1000 global value object.
Bart: You can use inis, though this would write to the hard drive (which literally around 1 billion times slower than storing something in memory).
Jon: Sorry, I didnt see your article. I did this because people requested it. I didnt rip you off, I'm good at working out these kinds of things for myself