X-Git-Url: https://git.ucc.asn.au/?p=matches%2Fhonours.git;a=blobdiff_plain;f=research%2Ftransmission_spectroscopy%2Fsimulator%2Fpgu-0.18%2Fexamples%2Fisovid1.py;fp=research%2Ftransmission_spectroscopy%2Fsimulator%2Fpgu-0.18%2Fexamples%2Fisovid1.py;h=f88b854dba4b74ea3f3d17eaf701edfbb1ed771e;hp=0000000000000000000000000000000000000000;hb=70a96cca12cb006506461d26cd112bab179fe74c;hpb=8caf60af39689a3546074f0c68d14c3a2e28191e diff --git a/research/transmission_spectroscopy/simulator/pgu-0.18/examples/isovid1.py b/research/transmission_spectroscopy/simulator/pgu-0.18/examples/isovid1.py new file mode 100644 index 00000000..f88b854d --- /dev/null +++ b/research/transmission_spectroscopy/simulator/pgu-0.18/examples/isovid1.py @@ -0,0 +1,63 @@ +"""tutorial on how to load tiles and levels with isovid. + +

you should go through the tilevid tutorials before you view these. isovid +is just another vid interface. + +

$ leveledit isolevel.tga isotiles.tga isocodes.tga 32 64 --iso
+C:\pgu\examples> python ../scripts/leveledit isolevel.tga isotiles.tga isocodes.tga 32 64 --iso
+ +

the next time you run leveledit, you will not need to provide +the tiles, codes, and width and height of the tiles +""" + +import pygame +from pygame.locals import * + +# the following line is not needed if pgu is installed +import sys; sys.path.insert(0, "..") + +from pgu import isovid + +SW,SH = 640,480 +TW,TH = 32,64 + +##This is the initialization function I created for +##the game. +## +##I use the tga_ methods to load up the tiles and level I created. +##:: +def init(): + g = isovid.Isovid() + + g.screen = pygame.display.set_mode((SW,SH),SWSURFACE) + + g.tga_load_tiles('isotiles.tga',(TW,TH)) + g.tga_load_level('isolevel.tga',1) + + g.view.x = -320 + g.view.y = -32 + + 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. +##:: +def run(g): + g.quit = 0 + + g.paint(g.screen) + pygame.display.flip() + + while not g.quit: + for e in pygame.event.get(): + if e.type is QUIT: g.quit = 1 + if e.type is KEYDOWN and e.key == K_ESCAPE: g.quit = 1 + + g.loop() + updates = g.update(g.screen) + pygame.display.update(updates) +## + +run(init())