Opened 6 years ago

Closed 4 years ago

#9260 closed defect (fixed)

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:
Blocked By: #10395 Blocking:
Deployments affected: Action Needed: add to build
Verified: no

Description

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

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

comment:2 Changed 4 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 4 years ago by Quozl

Patch accepted upstream.

comment:4 Changed 4 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 4 years ago by Quozl

  • Blocked By 10395 added

comment:6 Changed 4 years ago by Quozl

  • Milestone changed from Not Triaged to 10.1.3

comment:7 Changed 4 years ago by Quozl

  • Milestone changed from 10.1.3 to 10.1.4

comment:8 Changed 4 years ago by dsd

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

Pippy-38 is present in 11.2.0 build 4

Note: See TracTickets for help on using tickets.