Phil's pyGame Utilities Documentation

Overview

Scripts
tileedit | leveledit | tganew | levelfancy

Reference
algo | ani | engine | fonts | high | html | layout | text | timer | vid

Tutorials
1 | 2 | 3 | 4 | 5

GUI Ref.
theme | style | widget | surface | const

Containers
container | app | table | document | area

Forms
form | group

Widgets
basic | button | input | keysym | slider | select | misc

Other
menus | dialog

Tutorials
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10

tutorial on how to load tiles and levels

The following tutorial demonstrates how to use tileedit and leveledit via the command line. You can just as easily do all these things via the in-program "File/Open" and "File/New" menu items.

Here's an introduction to using tileedit and leveledit

$ -- linux, etc instructions
C:\> -- windows instructions

first you need to be in the examples dir for this tutorial to work

$ cd examples
C:\pgu> cd examples

$ tileedit tiles.tga 16 16
C:\pgu\examples> python ../scripts/tileedit tiles.tga 16 16

the next time you run tileedit, you will not need to provide the width and height of the tiles

$ tileedit codes.tga 16 16
C:\pgu\examples> python ../scripts/tileedit codes.tga 16 16

the next time you run tileedit, you will not need to provide the width and height of the codes

$ leveledit level.tga tiles.tga codes.tga 16 16
C:\pgu\examples> python ../scripts/leveledit level.tga tiles.tga codes.tga 16 16

the next time you run leveledit, you will not need to provide the tiles, codes, and width and height of the tiles

This is the initialization function I created for the game. I use the tga_ methods to load up the tiles and level I created.
  55:def init():
  56:    g = tilevid.Tilevid()
  57:
  58:    g.screen = pygame.display.set_mode((SW,SH),SWSURFACE)
  59:
  60:    g.tga_load_tiles('tiles.tga',(TW,TH))
  61:    g.tga_load_level('level.tga')
  62:
  63:    return g
This is the run function I created for the game. In this example, the level is displayed, but there is no interaction (other than allowing the user to quit via ESC or the QUIT signal.
  70:def run(g):
  71:    g.quit = 0
  72:
  73:    g.paint(g.screen)
  74:    pygame.display.flip()
  75:
  76:    while not g.quit:
  77:        for e in pygame.event.get():
  78:            if e.type is QUIT: g.quit = 1
  79:            if e.type is KEYDOWN and e.key == K_ESCAPE: g.quit = 1
  80:
  81:        g.loop()
  82:        updates = g.update(g.screen)
  83:        pygame.display.update(updates)

all content (c) 2006 Phil Hassey - Phil's pyGame Utilities