Ticket #9260 (closed defect: fixed)

Opened 6 years ago

Last modified 4 years ago

pippy examples can adapt to screen dimensions

Reported by: skierpage Owned by: Quozl
Priority: normal Milestone: 11.2.0-final
Component: pippy-activity Version:
Keywords: Cc:
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()

Change History

Changed 6 years ago by skierpage

This seems to work rotated also, and is simpler/cleaner:

# Display defaults to screen resolution (SDL 1.2.10 and above),
if pygame.get_sdl_version() < (1, 2, 10) :
  exit('Warning, version of SDL too old,exiting!')
screen = pygame.display.set_mode()
size = width, height = screen.get_width(), screen.get_height()

Changed 4 years ago by Quozl

  • owner changed from cjb to Quozl
  • status changed from new to assigned
  • next_action changed from never set to review

A patch proposed.

Changed 4 years ago by Quozl

Patch accepted upstream.

Changed 4 years ago by Quozl

  • next_action changed from review to add to build

Pippy-37 tested on 10.1.2 on XO-1, it contains the fix.

Changed 4 years ago by Quozl

  • blockedby 10395 added

Changed 4 years ago by Quozl

  • milestone changed from Not Triaged to 10.1.3

Changed 4 years ago by Quozl

  • milestone changed from 10.1.3 to 10.1.4

Changed 4 years ago by dsd

  • status changed from assigned to closed
  • resolution set to fixed

Pippy-38 is present in 11.2.0 build 4

Note: See TracTickets for help on using tickets.