Opened 8 years ago

Closed 6 years ago

Last modified 20 months ago

#9260 closed defect (fixed)

pippy examples can adapt to screen dimensions

Reported by: skierpage Owned by: Quozl
Priority: normal Milestone:
Component: pippy-activity Version:
Keywords: Cc:
Blocked By: #10395 Blocking:
Deployments affected: Action Needed: add to build
Verified: no


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 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 (9)

comment:1 Changed 8 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()

comment:2 Changed 7 years ago by Quozl

  • Action Needed changed from never set to review
  • Owner changed from cjb to Quozl
  • Status changed from new to assigned

A patch proposed.

comment:3 Changed 7 years ago by Quozl

Patch accepted upstream.

comment:4 Changed 6 years ago by Quozl

  • Action Needed changed from review to add to build

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

comment:5 Changed 6 years ago by Quozl

  • Blocked By 10395 added

comment:6 Changed 6 years ago by Quozl

  • Milestone changed from Not Triaged to 10.1.3

comment:7 Changed 6 years ago by Quozl

  • Milestone changed from 10.1.3 to 10.1.4

comment:8 Changed 6 years ago by dsd

  • Resolution set to fixed
  • Status changed from assigned to closed

Pippy-38 is present in 11.2.0 build 4

comment:9 Changed 20 months ago by Quozl

  • Milestone 11.2.0-final deleted

Milestone 11.2.0-final deleted

Note: See TracTickets for help on using tickets.