1 """<title>tutorial on how to scroll and use a Timer object</title>"""
4 from pygame.locals import *
6 # the following line is not needed if pgu is installed
7 import sys; sys.path.insert(0, "..")
9 from pgu import tilevid, timer
19 g.screen = pygame.display.set_mode((SW,SH),SWSURFACE)
21 g.tga_load_tiles('tiles.tga',(TW,TH))
23 ##In init(), I add bg=1 to tga_load_level so that the background layer is
26 g.tga_load_level('level.tga',1)
29 ##In init(), I also set the bounds of the level. The view will never go
30 ##outside the bounds of the level.
32 g.bounds = pygame.Rect(TW,TH,(len(g.tlayer[0])-2)*TW,(len(g.tlayer)-2)*TH)
40 ##In run(), I add a Timer so that I can keep a constant framerate of FPS fps.
49 for e in pygame.event.get():
50 if e.type is QUIT: g.quit = 1
51 if e.type is KEYDOWN and e.key == K_ESCAPE: g.quit = 1
53 ##In run(), each frame I move the view to the right by SPEED pixels.
59 updates = g.update(g.screen)
60 pygame.display.update(updates)
62 ##In run(), at the end of each frame, I give the timer a tick. The timer will delay the