f88b854dba4b74ea3f3d17eaf701edfbb1ed771e
[matches/honours.git] / research / transmission_spectroscopy / simulator / pgu-0.18 / examples / isovid1.py
1 """<title>tutorial on how to load tiles and levels with isovid.</title>
2
3 <p>you should go through the tilevid tutorials before you view these.  isovid
4 is just another vid interface.
5
6 <pre>$ leveledit isolevel.tga isotiles.tga isocodes.tga 32 64 --iso
7 C:\pgu\examples> python ../scripts/leveledit isolevel.tga isotiles.tga isocodes.tga 32 64 --iso</pre>
8
9 <p>the next time you run leveledit, you will not need to provide
10 the tiles, codes, and width and height of the tiles
11 """
12
13 import pygame
14 from pygame.locals import *
15
16 # the following line is not needed if pgu is installed
17 import sys; sys.path.insert(0, "..")
18
19 from pgu import isovid
20
21 SW,SH = 640,480
22 TW,TH = 32,64
23
24 ##This is the initialization function I created for
25 ##the game.
26 ##
27 ##I use the tga_ methods to load up the tiles and level I created.
28 ##::
29 def init():
30     g = isovid.Isovid()
31
32     g.screen = pygame.display.set_mode((SW,SH),SWSURFACE)
33     
34     g.tga_load_tiles('isotiles.tga',(TW,TH))
35     g.tga_load_level('isolevel.tga',1)
36     
37     g.view.x = -320
38     g.view.y = -32
39
40     return g
41 ##
42     
43 ##This is the run function I created for the game.  In this example,
44 ##the level is displayed, but there is no interaction (other than allowing the
45 ##user to quit via ESC or the QUIT signal.
46 ##::
47 def run(g): 
48     g.quit = 0
49     
50     g.paint(g.screen)
51     pygame.display.flip()
52     
53     while not g.quit:
54         for e in pygame.event.get():
55             if e.type is QUIT: g.quit = 1
56             if e.type is KEYDOWN and e.key == K_ESCAPE: g.quit = 1
57         
58         g.loop()
59         updates = g.update(g.screen)
60         pygame.display.update(updates)
61 ##    
62     
63 run(init())

UCC git Repository :: git.ucc.asn.au