SDL SplitScreen?

Pages: 12
closed account (N36fSL3A)
I want to know how I would incorporate a split screen function in a small RPG my brother wants to make. (He's 4 years younger than me and he wants to know how to program.) Can you please help? Some pseudo code or an example would be nice. Thanks in advance.
I don't remember the exact functions, but you should clip the first drawings to the first half of the screen, and the seconds to the second half of the screen.

Clipping is all I can tell you right now, try to look for SDL_ClipSurface, or maybe while drawing there should be a SDL_Rect clipping input.
closed account (N36fSL3A)
I don't understand what you mean...
For your drawing functions, make it so that you have to specify a target surface. After that, have 2 SDL_Surface objects, 1 for each side of the screen. Use your Draw function twice and specify the separate surfaces. Draw each surface on its respective side of the screen.

Not the whole thing, but that's the gist.
closed account (N36fSL3A)
What about drawing my tile map to each side?
It's what we are telling you to do.
1
2
3
4
5
6
7
8
9
10
11
12
13
SDL_Surface *player1Screen, *player2Screen, *screen;
player1Screen = SDL_Create_Surface(width/2,height);
player2Screen = SDL_Create_Surface(width/2,height);
screen = SDL_Create_Surface(width,height);

drawWorld(player1Screen);
drawWorld(player2Screen);

drawCharacters(player1Screen);
drawCharacters(player2Screen);

SDL_Draw_Surface(screen, player1Screen, 0, 0); //(dest, src, x, y)
SDL_Draw_Surface(screen, player2Screen, width/2, 0);
closed account (N36fSL3A)
In this case, would the other player show up onscreen when it's location is passed?
You need to separate two client areas to draw on as surfaces.

In such a case you want exactly half of the width of the window per client area.

This is seen in a large portion of multiplayer games, like Mario Kart, Need For Speed, etc.

Once you've set up two distinct client areas of the screen, draw to them as if they were on their own full window, just within half the portion of the screen.

The splicing of the screen in to two client areas is the least complicated part to solve in a game development, or any game in general, since simple math and division of the screen's surface in to two or more portions is simple in nature compared to a game and all of its assets.

closed account (N36fSL3A)
Pickout, I know this now, can someone answer my question though?
closed account (3qX21hU5)
I believe they did... just create to client area's.

In this case, would the other player show up onscreen when it's location is passed?


Not sure what you mean exactly by this...
The players won't move out of bounds in their clipped sections because each side of the clipped regions will behave as if they were on their own screen. That is what you should focus on implementing, treating two clipped client areas of a window as if they were distinct screens.
Look at ModShop's post, that's exactly how I would do it. If you code it right you could have an arbitrary number of screens for any number of players, rather than hardcoding two screens.
closed account (N36fSL3A)
That isn't what I mean. I get the clipping part. I'm going to have a map bigger than the screen boundries. I'm wondering if you pass where the other player is, will you be able to see their graphic. Example:

Lets say the map is 1000 by 1000 pixels. What if player1 is at 500 by 500, and player two is at 600 by 500. Would player2 be able to see Player one at his/her location through his/her's screen? Same thing with player1.
closed account (3qX21hU5)
I don't know its your game you tell us... What I mean by that is that has nothing to do with the clipping that has to do with the game development in general. If you want to program it so both players can see the other players characters on their own screen you can, and involves 2 (or how many players) view ports and camera's.

Here is something that might interest you and give you some ideas. Though it involves XNA http://msdn.microsoft.com/en-us/library/bb313965(v=xnagamestudio.10).aspx
closed account (N36fSL3A)
Oh, okay, thanks. That's really the main reason I made this topic, it was to see how to do that.
You would be drawing the exact same scene, just from different positions, so if both players were in roughly the same place they would see all the same stuff, including each other's player models (and their own in a third-person game).
closed account (N36fSL3A)
This is solved, but Chris, this isn't with OpenGL. I can't use glviewport or whatever it is.
closed account (3qX21hU5)
Every single graphics library has some sort of veiwport so just use your libraries similar feature.
In fact, there isn't even the need of, you can simply compute the viewports offsets by yourself.
Pages: 12