On Nov 21, 2007, at 11:19 AM, Miguel Sicart wrote:
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!).
Ask when you'd like to hear about it!
Casey Duncan wrote:
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()
With subsurfaces, eh? I was thinking more like:
<code>
w,h = SCREEN_SIZE ## eg. (800,600)
top_screen = pygame.surface.Surface((w,h/2))
bot_screen = pygame.surface.Surface((w,h/2))
def Draw():
DrawPlayerOneScreen(top_screen) ## Draw game stuff onto these surfaces
DrawPlayerTwoScreen(bot_screen)
screen.blit(top_screen,(0,0))
screen.blit(top_screen,(0,h/2))
pygame.display.update()
</code>
What's the purpose of using subsurfaces? I don't understand those.