Commits

Anonymous committed cf731de

chimp update

Comments (0)

Files changed (3)

docs/tut/ChimpLineByLine.html

 promises of riches and reward. The example itself is very simple, and
 a bit thin on errorchecking code. This sample program demonstrates
 many abilities like creating a graphics window, loading images and
-sound files, rendering TTF text, streaming music, and basic input and
-mouse handling.
-
+sound files, rendering TTF text, and basic event and mouse handling.
+<br>&nbsp;<br>
 This tutorial will go through the code block by block. Explaining how
 the code works. There will also be mention of how the code could be
-improved and what errorchecking could help out. 
-
+improved and what errorchecking could help out.
+<br>&nbsp;<br>
 This is an exellent tutorial for people getting their first look at the
 <i>pygame</i> code. Once <i>pygame</i> is fully installed, you can find and run the
-chimp demo for yourself in the examples directory.
-<br>
+chimp demo for yourself in the examples directory. 
+
+<p align=center><table border=1 bgcolor=#ddcc88 cellpadding=8><tr><td align=center>
+<img src=chimpshot.gif alt="Chimp Screenshot" width=474 height=85><br>
+<a href=chimp.py.html>Full Source</a>
+</td></tr></table></p>
+
 
 <br>
 <h2>Import Modules</h2>
 graphics or doublebuffered displays, it does not matter, <i>pygame</i> will
 give us the best possible match.<br>
 <br>
-Last we set the window title and turn of the mouse cursor for our
+Last we set the window title and turn off the mouse cursor for our
 window. Very basic to do, and now we have a small black window ready
 to do our bidding.<br>
 <br>

docs/tut/chimp.py.html

+<HTML><HEAD><TITLE>..\..\examples\chimp.py</TITLE></HEAD>
+		  <BODY BGCOLOR=#FFFFFF>
+		  <!--header-->
+		  <!--script--><PRE><FONT COLOR=#1111CC>#/usr/bin/env python</FONT>
+
+<FONT COLOR=#115511>"""This simple example is used for the line-by-line tutorial
+that comes with pygame. It is based on a 'popular' web banner.
+Note there are comments here, but for the full explanation, 
+follow along in the tutorial. This code contains little error
+checking to make it a little clearer. The full tutorial explains
+where and how better error checking will help."""</FONT>
+
+
+<FONT COLOR=#1111CC>#Import Modoules</FONT>
+<FONT COLOR=#3333CC><B>import</B></FONT> os
+<FONT COLOR=#3333CC><B>import</B></FONT> pygame, pygame.font, pygame.image, pygame.mixer
+<FONT COLOR=#3333CC><B>from</B></FONT> pygame.locals <FONT COLOR=#3333CC><B>import</B></FONT> *
+
+
+<FONT COLOR=#1111CC>#Resource Filenames</FONT>
+chimpfile = os.path.join(<FONT COLOR=#115511>'data'</FONT>, <FONT COLOR=#115511>'chimp.gif'</FONT>)
+fistfile = os.path.join(<FONT COLOR=#115511>'data'</FONT>, <FONT COLOR=#115511>'fist.gif'</FONT>)
+hitfile = os.path.join(<FONT COLOR=#115511>'data'</FONT>, <FONT COLOR=#115511>'punch.wav'</FONT>)
+missfile = os.path.join(<FONT COLOR=#115511>'data'</FONT>, <FONT COLOR=#115511>'whiff.wav'</FONT>)
+
+
+<FONT COLOR=#3333CC><B>def</B></FONT><A NAME="main"><FONT COLOR=#CC0000><B> main</B></FONT></A>():
+<FONT COLOR=#1111CC>#Initialize Everything</FONT>
+    pygame.init()
+    screen = pygame.display.set_mode((468, 60), HWSURFACE|DOUBLEBUF)
+    pygame.display.set_caption(<FONT COLOR=#115511>'Monkey Fever'</FONT>)
+    pygame.mouse.set_visible(0)
+     
+<FONT COLOR=#1111CC>#Create The Backgound</FONT>
+    background = pygame.Surface(screen.get_size())
+    background.fill((250, 250, 250))
+    
+<FONT COLOR=#1111CC>#Put Text On The Background, Centered</FONT>
+    font = pygame.font.Font(None, 36)
+    text = font.render(<FONT COLOR=#115511>"Pummel The Chimp, And Win $$$"</FONT>, 1, (10, 10, 10))
+    textpos = text.get_rect()
+    textpos.centerx = background.get_rect().centerx
+    background.blit(text, textpos)
+
+<FONT COLOR=#1111CC>#Display The Background While Setup Finishes</FONT>
+    screen.blit(background, (0, 0))
+    pygame.display.flip()
+    
+<FONT COLOR=#1111CC>#Load Resources</FONT>
+    chimp = pygame.image.load(chimpfile).convert()
+    fist = pygame.image.load(fistfile).convert()
+    whiffsound = pygame.mixer.Sound(missfile)
+    hitsound = pygame.mixer.Sound(hitfile)
+    
+<FONT COLOR=#1111CC>#Prepare To Animate</FONT>
+    chimppos = chimp.get_rect()
+    chimppos.bottom = screen.get_height()
+    chimpmove = 2
+    reload = 0
+
+<FONT COLOR=#1111CC>#Main Loop</FONT>
+    <FONT COLOR=#3333CC><B>while</B></FONT> 1:
+    
+    <FONT COLOR=#1111CC>#Handle Input, Check For Quit</FONT>
+        event = pygame.event.poll()
+        <FONT COLOR=#3333CC><B>if</B></FONT> event.type == QUIT <FONT COLOR=#3333CC><B>or</B></FONT> (event.type == KEYDOWN <FONT COLOR=#3333CC><B>and</B></FONT> event.key == K_ESCAPE):
+            <FONT COLOR=#3333CC><B>break</B></FONT>
+    
+    <FONT COLOR=#1111CC>#Move The Monkey</FONT>
+        chimppos.left += chimpmove
+        <FONT COLOR=#3333CC><B>if</B></FONT> <FONT COLOR=#3333CC><B>not</B></FONT> screen.get_rect().contains(chimppos):
+            chimpmove = -chimpmove
+    
+    <FONT COLOR=#1111CC>#Move And Punch The Fist</FONT>
+        fistpos = pygame.mouse.get_pos()    
+        pressed = pygame.mouse.get_pressed()[0]
+        <FONT COLOR=#3333CC><B>if</B></FONT> <FONT COLOR=#3333CC><B>not</B></FONT> reload <FONT COLOR=#3333CC><B>and</B></FONT> pressed:
+            <FONT COLOR=#3333CC><B>if</B></FONT> chimppos.collidepoint(fistpos):
+                hitsound.play()
+            <FONT COLOR=#3333CC><B>else</B></FONT>:
+                whiffsound.play()
+        reload = pressed
+        <FONT COLOR=#3333CC><B>if</B></FONT> <FONT COLOR=#3333CC><B>not</B></FONT> reload:
+            fistpos = fistpos[0] - 20, fistpos[1] - 10
+
+    <FONT COLOR=#1111CC>#Draw The Entire Scene</FONT>
+        screen.blit(background, (0, 0))
+        screen.blit(chimp, chimppos)
+        screen.blit(fist, fistpos)
+        pygame.display.flip()
+
+<FONT COLOR=#1111CC>#Game Over</FONT>
+
+
+<FONT COLOR=#1111CC>#this is python code to kickstart the program if not imported</FONT>
+<FONT COLOR=#3333CC><B>if</B></FONT> __name__ == <FONT COLOR=#115511>'__main__'</FONT>: main()
+</PRE>
+		  <!--footer-->
+		  </BODY>
Added
New image
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.