X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=research%2Ftransmission_spectroscopy%2Fsimulator%2Fpgu-0.18%2Fexamples%2Ftilevid1.py;fp=research%2Ftransmission_spectroscopy%2Fsimulator%2Fpgu-0.18%2Fexamples%2Ftilevid1.py;h=4cf9b8d2192e0c5e99f11ea32f2ce30ddc54d311;hb=70a96cca12cb006506461d26cd112bab179fe74c;hp=0000000000000000000000000000000000000000;hpb=8caf60af39689a3546074f0c68d14c3a2e28191e;p=matches%2Fhonours.git diff --git a/research/transmission_spectroscopy/simulator/pgu-0.18/examples/tilevid1.py b/research/transmission_spectroscopy/simulator/pgu-0.18/examples/tilevid1.py new file mode 100644 index 00000000..4cf9b8d2 --- /dev/null +++ b/research/transmission_spectroscopy/simulator/pgu-0.18/examples/tilevid1.py @@ -0,0 +1,87 @@ +"""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 + +""" + + + + +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 tilevid + +SW,SH = 320,240 +TW,TH = 16,16 + +##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 = tilevid.Tilevid() + + g.screen = pygame.display.set_mode((SW,SH),SWSURFACE) + + g.tga_load_tiles('tiles.tga',(TW,TH)) + g.tga_load_level('level.tga') + + 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())