[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Split screen question (newbie)



On Wed, 21 Nov 2007 16:33:39 +0100, Mundial 82 <mundial82@xxxxxxxxx> wrote:
> Hi all,
> 
> ok, so I am a bit of a newbie and I am trying to make a split screen
> game. The idea is very simple: screen divided in halves, top and
> bottom spaces are wrapped, and not connected at all (think two
> different spaces). It would be great if the two sides could have
> different backgrounds.
> I have no clue how to due this,  so any help is very welcome. I guess
> my level is pretty low: I can make asteroids and spacewar kind of games.

Hi there!

There isn't really a split-screen mode built into Pygame; you can draw
whatever you want, wherever you want. The question is what you're drawing.

Say that you've got a scrolling tile engine, where two characters are
moving around independently, and you want each half of the screen to follow
one of them. In the drawing part of your game's main loop you might say
something like:
<code>
top, bottom, left, right = FigureOutRangeOfTilesToDraw(P1.location) ##
Based on what part of the game world P1 is in
DrawTiles((top,bottom,left,right),(0,0)) ## Draw stuff to the top half of
the screen
top, bottom, left, right = FigureOutRangeOfTilesToDraw(P2.location) ##
Based on what part of the game world P2 is in
DrawTiles((top,bottom,left,right),(0,half_of_screen_height)) ## Draw stuff
to the bottom half of the screen
</code>

The point is that you just draw the game world twice per frame, with the
area depicted being centered around each character and the area you draw
_to_ being restricted to half of the screen. There's no special command for
it.

It might be helpful if you'd sketch and post what you want the split to
look like. Would this be for a game with characters in a scrolling world,
or what? It wouldn't make sense to do a split screen for the sort of
static-screen games some people make.

Kris