Skip to content

khafatech/pygame-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pygame:

Moving a square:

For starters, create a program in which we can move a box around the screen with the arrow keys.

  • Two ways to get events:
    • polling the device
    • using sdl events

Functions:

  • init: pygame.init() or pygame.*.init()

  • screen = pygame.display.set_mode(size)

  • screen functions:

    • blit(screen, rect)
    • fill(color)
  • loading & converting images: (surfaces) image = pygame.image.load('player.bmp').convert()

  • Keyboard input:

event.KEYDOWN and KEYUP when key pressed. event.key indicates which key http://www.pygame.org/docs/ref/key.html

for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN: print event.key

Template for a working pygame program:

Pygame on gp2x:

  • Get it from the gp2x wiki.
  • extract.
  • use the example to set up the environment before launching python programs.

special to gp2x:

pygame.display.set_mode((320, 240), 0, 16)

  • how to get input?

About

small programs to test pygame

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages