--- /dev/null
+<html>
+<head>
+<title>tutorial on how to load, display, and use Sprites</title>
+<style type='text/css'><!--
+.sections {
+ border: 1px solid black;
+ background: #fef790;
+ margin-left: 8px;
+ }
+
+.sections th {
+ background: #fde42d;
+ }
+
+.sections .h1 {
+ padding: 2px;
+ padding-left: 0px;
+ }
+.sections .h2 {
+ padding: 2px;
+ padding-left: 16px;
+ }
+.sections .h3 {
+ padding: 2px;
+ padding-left: 32px;
+ }
+.sections .h4 {
+ padding: 2px;
+ padding-left: 48px;
+ }
+
+.sections .h5 {
+ padding: 2px;
+ padding-left: 64px;
+ }
+.sections .h6 {
+ padding: 2px;
+ padding-left: 72px;
+ }
+
+.wiki h1, .wiki h2, .wiki h3, .wiki h4, .wiki h5, .wiki h6 {
+ border: 0px;
+ padding: 0px;
+ background: none;
+ border-bottom: 1px solid #bbbbbb;
+
+ }
+
+.wiki div.h1 {
+ }
+.wiki div.h2 {
+ }
+
+.wiki dt {
+ font-style: italic;
+ }
+
+.wiki dd,dd,p.dd {
+ font-style: normal;
+ margin-left: 48px;
+ margin-top: 0px;
+ margin-bottom: 8px;
+ display: block;
+ }
+
+.wiki h3 {
+ margin-left: 48px;
+ }
+.wiki div.h3 {
+ margin-left: 48px;
+ }
+
+.wiki code, .wiki pre {
+ background: #eeeeee;
+ padding: 4px;
+ border: 1px dashed #888888;
+ }
+
+
+.wiki table {
+ border-top: 1px solid #888888;
+ border-left: 1px solid #888888;
+ border-spacing: 0px; border-collapse: collapse;
+ }
+.wiki td {
+ border-bottom: 1px solid #888888;
+ border-right: 1px solid #888888;
+ padding: 3px;
+ }
+.wiki th {
+ background: #eeeeee;
+ border-bottom: 1px solid #888888;
+ border-right: 1px solid #888888;
+ padding: 3px;
+ }
+
+-->
+</style>
+
+</head>
+<body>
+<div align='center'>
+
+<table cellpadding=8><tr><td>
+<a href='http://www.imitationpickles.org/pgu/'><img src='skin/logo.gif' alt="Phil's pyGame Utilities" border=0></a>
+<td style='font-size:48px'>Documentation
+</table>
+
+</div>
+
+<hr width=500 align=center>
+
+<table width='100%'><tr><td valign=top width=120 style='padding-right:6px;border-right: 1px solid black;'>
+<a href='index.html'>Overview</a><br><br>
+<strong>Scripts</strong><br>
+<a href="tileedit.html">tileedit</a>
+ | <a href="leveledit.html">leveledit</a>
+ | <a href="tganew.html">tganew</a>
+ | <a href="levelfancy.html">levelfancy</a>
+<br><br>
+<strong>Reference</strong><br>
+<a href="algo.html">algo</a>
+ | <a href="ani.html">ani</a>
+ | <a href="engine.html">engine</a>
+ | <a href="fonts.html">fonts</a>
+ | <a href="high.html">high</a>
+ | <a href="html.html">html</a>
+ | <a href="layout.html">layout</a>
+ | <a href="text.html">text</a>
+ | <a href="timer.html">timer</a>
+ | <a href="vid.html">vid</a>
+<br><br>
+<strong>Tutorials</strong><br>
+<a href="tilevid1.html">1</a>
+ | <a href="tilevid2.html">2</a>
+ | <a href="tilevid3.html">3</a>
+ | <a href="tilevid4.html">4</a>
+ | <a href="tilevid5.html">5</a>
+<br><br>
+<strong>GUI Ref.</strong><br>
+<a href="gui.theme.html">theme</a>
+ | <a href="gui.style.html">style</a>
+ | <a href="gui.widget.html">widget</a>
+ | <a href="gui.surface.html">surface</a>
+ | <a href="gui.const.html">const</a>
+<br><br>
+<strong>Containers</strong><br>
+<a href="gui.container.html">container</a>
+ | <a href="gui.app.html">app</a>
+ | <a href="gui.table.html">table</a>
+ | <a href="gui.document.html">document</a>
+ | <a href="gui.area.html">area</a>
+<br><br>
+<strong>Forms</strong><br>
+<a href="gui.form.html">form</a>
+ | <a href="gui.group.html">group</a>
+<br><br>
+<strong>Widgets</strong><br>
+<a href="gui.basic.html">basic</a>
+ | <a href="gui.button.html">button</a>
+ | <a href="gui.input.html">input</a>
+ | <a href="gui.keysym.html">keysym</a>
+ | <a href="gui.slider.html">slider</a>
+ | <a href="gui.select.html">select</a>
+ | <a href="gui.misc.html">misc</a>
+<br><br>
+<strong>Other</strong><br>
+<a href="gui.menus.html">menus</a>
+ | <a href="gui.dialog.html">dialog</a>
+<br><br>
+<strong>Tutorials</strong><br>
+<a href="gui1.html">1</a>
+ | <a href="gui2.html">2</a>
+ | <a href="gui3.html">3</a>
+ | <a href="gui4.html">4</a>
+ | <a href="gui5.html">5</a>
+ | <a href="gui6.html">6</a>
+ | <a href="gui7.html">7</a>
+ | <a href="gui8.html">8</a>
+ | <a href="gui9.html">9</a>
+ | <a href="gui10.html">10</a>
+<br><br>
+
+<td valign=top style='padding-left:6px;'>
+
+<h1>tutorial on how to load, display, and use Sprites</h1>
+
+<div class='wiki'>
+<a name="">
+<div class="h1">
+
+</div>
+Here are the various functions I used for the player and enemy logic.
+- After creating a Sprite, I set the clayer to 0 so that more than one player / enemy is created.
+- the Sprite must be added to the sprites list
+- instead of using class methods, I prefer to use set functions for
+the various methods -- loop and hit.
+- Enemies are removed when they go off screen.
+<pre>
+ 23:def player_new(g,t,value):
+ 24: g.clayer[t.ty][t.tx] = 0
+ 25: s = tilevid.Sprite(g.images['player'],t.rect)
+ 26: g.sprites.append(s)
+ 27: s.loop = player_loop
+ 28:
+ 29:def player_loop(g,s):
+ 30: s.rect.x += SPEED
+ 31:
+ 32: keys = pygame.key.get_pressed()
+ 33: dx,dy = 0,0
+ 34: if keys[K_UP]: dy-=1
+ 35: if keys[K_DOWN]: dy+=1
+ 36: if keys[K_LEFT]: dx-=1
+ 37: if keys[K_RIGHT]: dx+=1
+ 38: s.rect.x += dx*5
+ 39: s.rect.y += dy*5
+ 40: s.rect.clamp_ip(g.view)
+ 41:
+ 42:def enemy_new(g,t,value):
+ 43: g.clayer[t.ty][t.tx] = 0
+ 44: s = tilevid.Sprite(g.images['enemy'],t.rect)
+ 45: g.sprites.append(s)
+ 46: s.loop = enemy_loop
+ 47:
+ 48:def enemy_loop(g,s):
+ 49: if s.rect.right < g.view.left:
+ 50: g.sprites.remove(s)
+</pre>
+Here I initialize the image data. The columns are (name,file_name,shape)
+<pre>
+ 54:idata = [
+ 55: ('player','player.tga',(4,4,24,24)),
+ 56: ('enemy','enemy.tga',(4,4,24,24)),
+ 57: ('shot','shot.tga',(1,2,6,4)),
+ 58: ]
+</pre>
+Here I initialize the code data. The columns are (function, config).
+<pre>
+ 62:cdata = {
+ 63: 1:(player_new,None),
+ 64: 2:(enemy_new,None),
+ 65: 3:(enemy_new,None),
+ 66: 4:(enemy_new,None),
+ 67: }
+</pre>
+In init(), loading in the sprite images.
+<pre>
+ 81: g.load_images(idata)
+</pre>
+In init(), running the codes for the initial screen.
+<pre>
+ 86: g.run_codes(cdata,(0,0,25,17))
+</pre>
+In run(), each frame I make sure to run the codes that are on the far
+right of the screen.
+<pre>
+ 109: g.run_codes(cdata,(g.view.right/TW,0,1,17))
+</pre>
+
+</div>
+
+</table>
+
+<hr width=500 align=center>
+<div align='center'>all content (c) 2006 Phil Hassey - <a href='http://www.imitationpickles.org/pgu/'>Phil's pyGame Utilities</a></div>
+</body>
+</html>
\ No newline at end of file