ARGH
[matches/honours.git] / research / transmission_spectroscopy / simulator / pgu-0.18 / examples / hexvid1.py
1 """<title>tutorial on how to load tiles and levels with hexvid</title>
2 <p>
3 you should go through the tilevid tutorials before you view these.  hexvid
4 is just another vid interface.
5
6 <pre>$ leveledit hexlevel.tga hextiles.tga hexcodes.tga 32 64 --hex
7 C:\pgu\examples> python ../scripts/leveledit hexlevel.tga hextiles.tga hexcodes.tga 32 64 --hex</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 hexvid
20
21 SW,SH = 320,240
22 TW,TH = 32,28
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 = hexvid.Hexvid()
31
32     g.screen = pygame.display.set_mode((SW,SH),SWSURFACE)
33     
34     g.tga_load_tiles('hextiles.tga',(TW,TH))
35     g.tga_load_level('hexlevel.tga')
36     
37     g.view.x = -320
38     g.view.y = 200
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