[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Split screen question (newbie)
On Nov 21, 2007, at 11:19 AM, Miguel Sicart wrote:
Hi all,
Thanks a lot for the help!
Ok, so what I am interested in doing is sort of artsy-fartsy little
videogames (think Rob Humble's The Marriage), and this is one of
them: top of the screen, player one will be doing one thing
(collecting items, destroying items); bottom of the screen, player
two will be doing other things (putting items together). And that
is it, more or less :)
Now, the problem is that I am to game programming what military
music is to music, so I don't want to go into tiling or scrolling
backgrounds (but hey, I'd love to learn more about tiling at some
moment!).
My intuition was very much towards Casey and Ian's comments - two
subsurfaces where I can draw. Question is, I have no idea how to
practically do that.
I do the screen the classic way, I think
screen = pygame.display.set_mode()
and then a background:
background = pygame.Surface(screen.get_size())
Then do something like:
top_rect = screen.get_rect()
top_rect.height = top_rect.height / 2
top_screen = screen.subsurface(top_rect)
bot_rect = top_rect.move(0, top_rect.height)
bot_screen = screen.subsurface(bot_rect)
Now use top_screen to draw into the top and bot_screen to draw into
the bottom. You flip the main screen surface as usual to see the
result since drawing to top_screen and bot_screen actual just draws
into different positions of screen.
for example, try:
top_screen.fill((255,0,0))
bot_screen.fill((0,0,255))
pygame.display.flip()
-Casey