Ticket #9260 (closed defect: fixed)
pippy examples can adapt to screen dimensions
|Reported by:||skierpage||Owned by:||Quozl|
|Action Needed:||add to build||Verified:||no|
|Deployments affected:||Blocked By:||#10395|
All the pippy graphics examples I looked at hardcode
# XO screen is 1200x900 size = width, height = 1200, 900
but that makes the activity resolution-dependent. Bad for emulation, and on the XO if you rotate the screen, Bounce's word goes off the side, etc.
I read http://www.pygame.org/docs/ref/display.html and it seems pygame defaults to full-screen and can determine display size.
I've never written a line of Python before but this fixes the Bounce example to work rotated:
# Don't need to set a screen resolution (SDL 1.2.10 and above), # we can determine it dynamically (pygame 1.8.0 and above). if pygame.get_sdl_version() < (1, 2, 10) or pygame.version.vernum < (1, 8, 0) : exit('Warning, version of Pygame too old,exiting!') screen = pygame.display.set_mode() # Ask for display's width and height. display = pygame.display.Info() size = width, height = display.current_w, display.current_h
or maybe better request the screen's size and width instead of the display's, so last two lines become (untested):
size = width, height = screen.get_size()