Commits

Anonymous committed 7a9d787

image module redone

  • Participants
  • Parent commits bc10c4b

Comments (0)

Files changed (26)

 #everything you can, but you can ignore ones you don't have
 #dependencies for, just comment them out
 
+imageext src/imageext.c $(SDL) $(IMAGE)
 font src/font.c $(SDL) $(FONT)
-image src/image.c $(SDL) $(IMAGE)
 mixer src/mixer.c $(SDL) $(MIXER)
 mixer_music src/music.c $(SDL) $(MIXER)
 
 time src/time.c $(SDL)
 joystick src/joystick.c $(SDL)
 draw src/draw.c $(SDL)
+image src/image.c $(SDL)
 
 
 
 # BREAK = change breaks existing code
 # BUG   = fixed a bug that was crashing
 
-Mar 14, 2001
+May 15, 2001
+	image module is now builtin, but formats are optional
+	enhanced save function in image (handles opengl)
+	Surface.save is now depracated
+
+May 14, 2001
 	smarter internal module handling
 	fixed blit() (broken on May 9th change)
 
 
 <hr>
 
-<font size=+1><b>Text File Documentation</b></font><br><li><a href=../README.TXT>README</a> - Pygame version 1.0.1</li>
+<font size=+1><b>Text File Documentation</b></font><br><li><a href=../README.TXT>README</a> - Pygame version 1.0.2</li>
 <li><a href=LGPL>LGPL</a> - Gnu lesser general public license</li>
 <li><a href=fullinstall.txt>fullinstall</a> - Build instructions for building and installing pygame</li>
 <li><a href=init.txt>init</a> - Information about importing and initializing pygame</li><br>&nbsp;<br><font size=+1><b>Tutorials</b></font><br><li><a href=tut/ChimpLineByLine.html>tut/ChimpLineByLine</a> - Line by Line Descriptions of the Chimp Example
 <a href=ref/pygame_font.html#get_init>pygame.font.get_init</a> - get status of font module initialization<br>
 <a href=ref/pygame_font.html#init>pygame.font.init</a> - initialize the display module<br>
 <a href=ref/pygame_font.html#quit>pygame.font.quit</a> - uninitialize the font module<br>
+<a href=ref/pygame_image.html#get_extended>pygame.image.get_extended</a> - save surface as BMP data<br>
 <a href=ref/pygame_image.html#load>pygame.image.load</a> - load an image to a new Surface<br>
+<a href=ref/pygame_image.html#save>pygame.image.save</a> - save surface as BMP data<br>
 <a href=ref/pygame_joystick.html#Joystick>pygame.joystick.Joystick</a> - create new joystick object<br>
 <a href=ref/pygame_joystick.html#get_count>pygame.joystick.get_count</a> - query number of joysticks on system<br>
 <a href=ref/pygame_joystick.html#get_init>pygame.joystick.get_init</a> - query initialization of joystick module<br>

docs/ref/Surface.html

 rectangle sizes will be ignored.
 
 <br>&nbsp;<br>
-Note that blitting alpha surfaces onto an 8bit destination will
-crash SDL. Pygame will disable the alpha when these blits are attempted.
+Note that blitting surfaces with alpha onto 8bit destinations will
+not use the surface alpha values.
 
 </ul><br>&nbsp;<br>
 
 </b></font><br><font size=+1><tt>
 Surface.save(file) -> None
 </tt></font><ul>
-This will save your surface in the BMP format. The given file
-argument can be either a filename or a python file-like object
-to save the BMP image to.
+This function is depracated, please don't use it. It will print
+a warning when called, but eventually be removed from pygame.
+You should now use the enhanced <a href=pygame_image.html#save>pygame.image.save()</a> function.
 </ul><br>&nbsp;<br>
 
 <a name=set_alpha><font size=+2><b>set_alpha

docs/ref/pygame_image.html

 </td></tr></table>
 <br>
 <h2 align=center>pygame.image</h2>
-Contains routines to load Surfaces from image files. This
-module must be manually imported, since it requires the use of
-the SDL_image library.
+This module contains functions to transfer images in and out
+of Surfaces. At the minimum the included <a href=pygame_mixer_music.html#load>load()</a> function will
+support BMP files. If SDL_image is properly installed when
+pygame is installed, it will support all the formats included
+with SDL_image. You can call the <a href=#get_extended>get_extended()</a> function to test
+if the SDL_image support is available.
+<br>&nbsp;<br>
+Some functions that communicate with other libraries will require
+that those libraries are properly installed. For example, the <a href=Surface.html#save>save()</a>
+function can only save OPENGL surfaces if pyopengl is available.
 
 <hr>
 
 <table>
+<tr><td><a href=#get_extended>get_extended</a></td><td> -
+save surface as BMP data</td></tr>
+
+
 <tr><td><a href=#load>load</a></td><td> -
 load an image to a new Surface</td></tr>
 
 
+<tr><td><a href=#save>save</a></td><td> -
+save surface as BMP data</td></tr>
+
+
 </table>
 
 <hr>
 
+<a name=get_extended><font size=+2><b>get_extended
+</b></font><br><font size=+1><tt>
+pygame.image.get_extended() -> int
+</tt></font><ul>
+This will return a true value if the extended image formats
+from SDL_image are available for loading.
+</ul><br>&nbsp;<br>
+
 <a name=load><font size=+2><b>load
 </b></font><br><font size=+1><tt>
 pygame.image.load(file, [namehint]) -> Surface
 either the filename or extension as the namehint string. The
 namehint can help the loader determine the filetype.
 <br>&nbsp;<br>
-You will only be able to load the types of images supported by
-your build of SDL_image. This will always include GIF, BMP, PPM,
-PCX, and TGA. SDL_image can also load JPG, PNG, and TIF, but they are
-optional.
+If pygame was installed without SDL_image support, the load
+will only work with BMP images. You can test if SDL_image is
+available with the <a href=#get_extended>get_extended()</a> function. These extended
+file formats usually include GIF, PNG, JPG, PCX, TGA, and more.
+</ul><br>&nbsp;<br>
+
+<a name=save><font size=+2><b>save
+</b></font><br><font size=+1><tt>
+pygame.image.save(Surface, file) -> None
+</tt></font><ul>
+This will save your surface in the BMP format. The given file
+argument can be either a filename or a python file-like object
+to save the BMP image to. This will also work for an opengl
+display surface.
 </ul><br>&nbsp;<br>
 
 

docs/ref/pygame_mixer_music.html

 <br>&nbsp;<br>
 The music module has many of the same types of functions as the
 Sound objects. The main difference is only one music object can
-be loaded at a time, with the <a href=pygame_image.html#load>load()</a> function. Music
+be loaded at a time, with the <a href=#load>load()</a> function. Music
 must be stored in an individual file on the system, it cannot be
 loaded from special file-like objects through python.
 

docs/tut/ChimpLineByLine.html

  
 <h1 align=center><font size=-1>Pygame Tutorials</font><br>Line By Line Chimp</h1>
 <h2 align=center>by Pete Shinners<br><font size=-1>pete@shinners.org</font></h2>
-<h3 align=center>Revision 1.1, January 5th, 2001</h3>
+<h3 align=center>Revision 1.2, May 15th, 2001</h3>
 <br><br>
 
 
 from pygame.locals import *
 </td></tr></table><br>
 
-The os module is imported to simple help us create cross platform
-pathnames.<br>
+The os module is imported to simple help us create cross platform pathnames.<br>
 <br>
 You'll see there is a good sized list of different <i>pygame</i> modules
 that we actually need. Importing just <i>pygame</i> will give you many
 Crossplatform file paths.<br>
 
 <br><table border=1 bgcolor=#ddcc88><tr><td><pre>
-chimpfile = os.path.join('data', 'chimp.gif')
-fistfile = os.path.join('data', 'fist.gif')
+chimpfile = os.path.join('data', 'chimp.bmp')
+fistfile = os.path.join('data', 'fist.bmp')
 hitfile = os.path.join('data', 'punch.wav')
 missfile = os.path.join('data', 'whiff.wav')
 </td></tr></table><br>
 
 <br><table border=1 bgcolor=#ddcc88><tr><td><pre>
 chimp = pygame.image.load(chimpfile).convert()
+chimp.set_colorkey(chimp.get_at((0, 0)))
 fist = pygame.image.load(fistfile).convert()
+fist.set_colorkey(chimp.get_at((0, 0)))
 whiffsound = pygame.mixer.Sound(missfile)
 hitsound = pygame.mixer.Sound(hitfile)
 </td></tr></table><br>
 First we load two graphics files as new Surfaces. In this case the
 graphics are GIF files with transparancy information already set.
 Note that after loading we use convert to make them the same format
-as the screen. This will keep them running as fast as possible.<br>
+as the screen. This will keep them running as fast as possible. We
+also set a colorkey for each of these images. A colorkey makes a
+certain color of an image transparent when we display it. Notice when
+we set the colorkey here, we just make it the same color as the pixel
+in the topleft corner.<br>
 <br>
 Loading the sound effects is even easier. The sound constructor
 can take the filename of the source sound. These sounds will be

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>
+<HTML>
+<HEAD>
+<STYLE>
+.S0 {
+	color: #808080;
+}
+.S1 {
+	font-family: Comic Sans MS;
+	color: #007F00;
+	font-size: 9pt;
+}
+.S2 {
+	color: #007F7F;
+}
+.S3 {
+	font-family: Courier New;
+	color: #7F007F;
+	font-size: 10pt;
+}
+.S4 {
+	font-family: Courier New;
+	color: #7F007F;
+	font-size: 10pt;
+}
+.S5 {
+	font-weight: bold;
+	color: #00007F;
+}
+.S6 {
+	color: #7F0000;
+}
+.S7 {
+	color: #7F0000;
+}
+.S8 {
+	font-weight: bold;
+	color: #0000FF;
+}
+.S9 {
+	font-weight: bold;
+	color: #007F7F;
+}
+.S10 {
+	font-weight: bold;
+}
+.S12 {
+	color: #7F7F7F;
+}
+.S13 {
+	font-family: Courier New;
+	color: #000000;
+	background: #E0C0E0;
+	font-size: 10pt;
+}
+SPAN {
+	font-family: Verdana;
+	font-size: 10pt;
+}
+</STYLE>
+</HEAD>
+<BODY>
+<SPAN class=S0></SPAN><SPAN class=S1>#/usr/bin/env&nbsp;python</SPAN><SPAN class=S0><BR>
+<BR>
+</SPAN><SPAN class=S7>"""This&nbsp;simple&nbsp;example&nbsp;is&nbsp;used&nbsp;for&nbsp;the&nbsp;line-by-line&nbsp;tutorial<BR>
+that&nbsp;comes&nbsp;with&nbsp;pygame.&nbsp;It&nbsp;is&nbsp;based&nbsp;on&nbsp;a&nbsp;'popular'&nbsp;web&nbsp;banner.<BR>
+Note&nbsp;there&nbsp;are&nbsp;comments&nbsp;here,&nbsp;but&nbsp;for&nbsp;the&nbsp;full&nbsp;explanation,&nbsp;<BR>
+follow&nbsp;along&nbsp;in&nbsp;the&nbsp;tutorial.&nbsp;This&nbsp;code&nbsp;contains&nbsp;little&nbsp;error<BR>
+checking&nbsp;to&nbsp;make&nbsp;it&nbsp;a&nbsp;little&nbsp;clearer.&nbsp;The&nbsp;full&nbsp;tutorial&nbsp;explains<BR>
+where&nbsp;and&nbsp;how&nbsp;better&nbsp;error&nbsp;checking&nbsp;will&nbsp;help."""</SPAN><SPAN class=S0><BR>
+<BR>
+<BR>
+</SPAN><SPAN class=S1>#Import&nbsp;Modoules</SPAN><SPAN class=S0><BR>
+</SPAN><SPAN class=S5>import</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>os</SPAN><SPAN class=S0><BR>
+</SPAN><SPAN class=S5>import</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>font</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>image</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>mixer</SPAN><SPAN class=S0><BR>
+</SPAN><SPAN class=S5>from</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>locals</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S5>import</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>*</SPAN><SPAN class=S0><BR>
+<BR>
+<BR>
+</SPAN><SPAN class=S1>#Resource&nbsp;Filenames</SPAN><SPAN class=S0><BR>
+</SPAN><SPAN class=S11>chimpfile</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>os</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>path</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>join</SPAN><SPAN class=S10>(</SPAN><SPAN class=S4>'data'</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S4>'chimp.bmp'</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+</SPAN><SPAN class=S11>fistfile</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>os</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>path</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>join</SPAN><SPAN class=S10>(</SPAN><SPAN class=S4>'data'</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S4>'fist.bmp'</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+</SPAN><SPAN class=S11>hitfile</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>os</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>path</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>join</SPAN><SPAN class=S10>(</SPAN><SPAN class=S4>'data'</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S4>'punch.wav'</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+</SPAN><SPAN class=S11>missfile</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>os</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>path</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>join</SPAN><SPAN class=S10>(</SPAN><SPAN class=S4>'data'</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S4>'whiff.wav'</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+<BR>
+<BR>
+</SPAN><SPAN class=S5>def</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S9>main</SPAN><SPAN class=S10>():</SPAN><SPAN class=S0><BR>
+</SPAN><SPAN class=S1>#Initialize&nbsp;Everything</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>init</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>screen</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>display</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>set_mode</SPAN><SPAN class=S10>((</SPAN><SPAN class=S2>468</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>60</SPAN><SPAN class=S10>),</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>HWSURFACE</SPAN><SPAN class=S10>|</SPAN><SPAN class=S11>DOUBLEBUF</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>display</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>set_caption</SPAN><SPAN class=S10>(</SPAN><SPAN class=S4>'Monkey&nbsp;Fever'</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>mouse</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>set_visible</SPAN><SPAN class=S10>(</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
+</SPAN><SPAN class=S1>#Create&nbsp;The&nbsp;Backgound</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>background</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>Surface</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>screen</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>get_size</SPAN><SPAN class=S10>())</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>background</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>fill</SPAN><SPAN class=S10>((</SPAN><SPAN class=S2>250</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>250</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>250</SPAN><SPAN class=S10>))</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;<BR>
+</SPAN><SPAN class=S1>#Put&nbsp;Text&nbsp;On&nbsp;The&nbsp;Background,&nbsp;Centered</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>font</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>font</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>Font</SPAN><SPAN class=S10>(</SPAN><SPAN class=S5>None</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>36</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>text</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>font</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>render</SPAN><SPAN class=S10>(</SPAN><SPAN class=S3>"Pummel&nbsp;The&nbsp;Chimp,&nbsp;And&nbsp;Win&nbsp;$$$"</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>1</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>(</SPAN><SPAN class=S2>10</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>10</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>10</SPAN><SPAN class=S10>))</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>textpos</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>text</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>get_rect</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>textpos</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>centerx</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>background</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>get_rect</SPAN><SPAN class=S10>().</SPAN><SPAN class=S11>centerx</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>background</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>blit</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>text</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>textpos</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+<BR>
+</SPAN><SPAN class=S1>#Display&nbsp;The&nbsp;Background&nbsp;While&nbsp;Setup&nbsp;Finishes</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>screen</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>blit</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>background</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>(</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>))</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>display</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>flip</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;<BR>
+</SPAN><SPAN class=S1>#Load&nbsp;Resources</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>chimp</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>image</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>load</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>chimpfile</SPAN><SPAN class=S10>).</SPAN><SPAN class=S11>convert</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>chimp</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>set_colorkey</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>chimp</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>get_at</SPAN><SPAN class=S10>((</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>)))</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>fist</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>image</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>load</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>fistfile</SPAN><SPAN class=S10>).</SPAN><SPAN class=S11>convert</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>fist</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>set_colorkey</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>chimp</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>get_at</SPAN><SPAN class=S10>((</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>)))</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>whiffsound</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>mixer</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>Sound</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>missfile</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>hitsound</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>mixer</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>Sound</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>hitfile</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;<BR>
+</SPAN><SPAN class=S1>#Prepare&nbsp;To&nbsp;Animate</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>chimppos</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>chimp</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>get_rect</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>chimppos</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>bottom</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>screen</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>get_height</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>chimpmove</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>2</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>reload</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>0</SPAN><SPAN class=S0><BR>
+<BR>
+</SPAN><SPAN class=S1>#Main&nbsp;Loop</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>while</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>1</SPAN><SPAN class=S10>:</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S1>#Handle&nbsp;Input,&nbsp;Check&nbsp;For&nbsp;Quit</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>event</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>event</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>poll</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>if</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>event</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>type</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>==</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>QUIT</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S5>or</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>event</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>type</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>==</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>KEYDOWN</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S5>and</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>event</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>key</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>==</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>K_ESCAPE</SPAN><SPAN class=S10>):</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>break</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S1>#Move&nbsp;The&nbsp;Monkey</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>chimppos</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>left</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>+=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>chimpmove</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>if</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S5>not</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>screen</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>get_rect</SPAN><SPAN class=S10>().</SPAN><SPAN class=S11>contains</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>chimppos</SPAN><SPAN class=S10>):</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>chimpmove</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>-</SPAN><SPAN class=S11>chimpmove</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S1>#Move&nbsp;And&nbsp;Punch&nbsp;The&nbsp;Fist</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>fistpos</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>mouse</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>get_pos</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0>&nbsp;&nbsp;&nbsp;&nbsp;<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>pressed</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>mouse</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>get_pressed</SPAN><SPAN class=S10>()[</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>]</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>if</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S5>not</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>reload</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S5>and</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pressed</SPAN><SPAN class=S10>:</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>if</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>chimppos</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>collidepoint</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>fistpos</SPAN><SPAN class=S10>):</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>hitsound</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>play</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>else</SPAN><SPAN class=S10>:</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>whiffsound</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>play</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>reload</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>pressed</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S5>if</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S5>not</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>reload</SPAN><SPAN class=S10>:</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>fistpos</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>=</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>fistpos</SPAN><SPAN class=S10>[</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>]</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>-</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>20</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>fistpos</SPAN><SPAN class=S10>[</SPAN><SPAN class=S2>1</SPAN><SPAN class=S10>]</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>-</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>10</SPAN><SPAN class=S0><BR>
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S1>#Draw&nbsp;The&nbsp;Entire&nbsp;Scene</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>screen</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>blit</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>background</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>(</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S2>0</SPAN><SPAN class=S10>))</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>screen</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>blit</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>chimp</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>chimppos</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>screen</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>blit</SPAN><SPAN class=S10>(</SPAN><SPAN class=S11>fist</SPAN><SPAN class=S10>,</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>fistpos</SPAN><SPAN class=S10>)</SPAN><SPAN class=S0><BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=S11>pygame</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>display</SPAN><SPAN class=S10>.</SPAN><SPAN class=S11>flip</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+<BR>
+</SPAN><SPAN class=S1>#Game&nbsp;Over</SPAN><SPAN class=S0><BR>
+<BR>
+<BR>
+</SPAN><SPAN class=S1>#this&nbsp;is&nbsp;python&nbsp;code&nbsp;to&nbsp;kickstart&nbsp;the&nbsp;program&nbsp;if&nbsp;not&nbsp;imported</SPAN><SPAN class=S0><BR>
+</SPAN><SPAN class=S5>if</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>__name__</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S10>==</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S4>'__main__'</SPAN><SPAN class=S10>:</SPAN><SPAN class=S0>&nbsp;</SPAN><SPAN class=S11>main</SPAN><SPAN class=S10>()</SPAN><SPAN class=S0><BR>
+</SPAN></BODY>
+</HTML>

examples/aliens.py

 try: import pygame.font as font
 except ImportError: font = None
 
+if not pygame.image.get_extended():
+    raise SystemExit, "Requires the extended image loading from SDL_image"
+
 
 #constants
 FRAMES_PER_SEC = 45

examples/arraydemo.py

         e = pygame.event.poll()
         if e.type == MOUSEBUTTONDOWN: break
         elif e.type == KEYDOWN and e.key == K_s:
-            screen.save(name+'.bmp')
+            pygame.image.save(screen, name+'.bmp')
         elif e.type == QUIT: raise SystemExit
 
 
 
 
 #imgarray
-imagename = os.path.join('data', 'arraydemo.jpg')
+imagename = os.path.join('data', 'arraydemo.bmp')
 imgsurface = pygame.image.load(imagename)
 imgarray = surfarray.array2d(imgsurface)
 surfdemo_show(imgarray, 'imgarray')

examples/chimp.py

 
 
 #Resource Filenames
-chimpfile = os.path.join('data', 'chimp.gif')
-fistfile = os.path.join('data', 'fist.gif')
+chimpfile = os.path.join('data', 'chimp.bmp')
+fistfile = os.path.join('data', 'fist.bmp')
 hitfile = os.path.join('data', 'punch.wav')
 missfile = os.path.join('data', 'whiff.wav')
 
     
 #Load Resources
     chimp = pygame.image.load(chimpfile).convert()
+    chimp.set_colorkey(chimp.get_at((0, 0)))
     fist = pygame.image.load(fistfile).convert()
+    fist.set_colorkey(chimp.get_at((0, 0)))
     whiffsound = pygame.mixer.Sound(missfile)
     hitsound = pygame.mixer.Sound(hitfile)
     

examples/data/arraydemo.bmp

Added
New image

examples/data/arraydemo.jpg

Removed
Old image

examples/data/chimp.bmp

Added
New image

examples/data/chimp.gif

Removed
Old image

examples/data/fist.bmp

Added
New image

examples/data/fist.gif

Removed
Old image

examples/data/liquid.bmp

Added
New image

examples/data/liquid.gif

Removed
Old image

examples/liquid.py

     screen = pygame.display.set_mode((640, 480), HWSURFACE|DOUBLEBUF, 8)
 
     #load image
-    imagename = os.path.join('data', 'liquid.gif')
+    imagename = os.path.join('data', 'liquid.bmp')
     bitmap = pygame.image.load(imagename)
 
     #get the image and screen in the same format

examples/oldalien.py

 import pygame, pygame.image
 from pygame.locals import *
 
+if not pygame.image.get_extended():
+    raise SystemExit, "Requires the extended image loading from SDL_image"
+
 
 #constants
 FRAMES_PER_SEC = 50

examples/zipshow.py

 from pygame.locals import *
 
 
+
 def showimage(imgsurface, name):
     "put a loaded image onto the screen"
     size = imgsurface.get_size()
 import pygame.mouse
 import pygame.time
 import pygame.joystick
+import pygame.image
 
  *  image module for pygame
  */
 #include "pygame.h"
-#include <SDL_image.h>
 
 
-static char* find_extension(char* fullname)
-{
-	char* dot;
+static int is_extended = 0;
 
-	if(!fullname)
-		return NULL;
-
-	dot = strrchr(fullname, '.');
-	if(!dot)
-		return fullname;
-
-	return dot+1;
-}
 
 
 
     /*DOC*/    "either the filename or extension as the namehint string. The\n"
     /*DOC*/    "namehint can help the loader determine the filetype.\n"
     /*DOC*/    "\n"
-    /*DOC*/    "You will only be able to load the types of images supported by\n"
-    /*DOC*/    "your build of SDL_image. This will always include GIF, BMP, PPM,\n"
-    /*DOC*/    "PCX, and TGA. SDL_image can also load JPG, PNG, and TIF, but they are\n"
-    /*DOC*/    "optional.\n"
+    /*DOC*/    "If pygame was installed without SDL_image support, the load\n"
+    /*DOC*/    "will only work with BMP images. You can test if SDL_image is\n"
+    /*DOC*/    "available with the get_extended() function. These extended\n"
+    /*DOC*/    "file formats usually include GIF, PNG, JPG, PCX, TGA, and more.\n"
     /*DOC*/ ;
 
-static PyObject* load(PyObject* self, PyObject* arg)
+static PyObject* image_load_basic(PyObject* self, PyObject* arg)
 {
 	PyObject* file, *final;
 	char* name = NULL;
 	{
 		name = PyString_AsString(file);
 		Py_BEGIN_ALLOW_THREADS
-		surf = IMG_Load(name);
+		surf = SDL_LoadBMP(name);
 		Py_END_ALLOW_THREADS
 	}
 	else
 		if(!(rw = RWopsFromPython(file)))
 			return NULL;
 		if(RWopsCheckPython(rw))
-			surf = IMG_LoadTyped_RW(rw, 1, find_extension(name));
+			surf = SDL_LoadBMP_RW(rw, 1);
 		else
 		{
 			Py_BEGIN_ALLOW_THREADS
-			surf = IMG_LoadTyped_RW(rw, 1, find_extension(name));
+			surf = SDL_LoadBMP_RW(rw, 1);
 			Py_END_ALLOW_THREADS
 		}
 	}
 	if(!surf)
-		return RAISE(PyExc_SDLError, IMG_GetError());
+		return RAISE(PyExc_SDLError, SDL_GetError());
 
 	final = PySurface_New(surf);
 	if(!final)
 
 
 
+    /*DOC*/ static char doc_save[] =
+    /*DOC*/    "pygame.image.save(Surface, file) -> None\n"
+    /*DOC*/    "save surface as BMP data\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "This will save your surface in the BMP format. The given file\n"
+    /*DOC*/    "argument can be either a filename or a python file-like object\n"
+    /*DOC*/    "to save the BMP image to. This will also work for an opengl\n"
+    /*DOC*/    "display surface.\n"
+    /*DOC*/ ;
+
+PyObject* image_save(PyObject* self, PyObject* arg)
+{
+	PyObject* surfobj, *file;
+	SDL_Surface *surf;
+	SDL_Surface *temp = NULL;
+	int i, result;
+	
+	if(!PyArg_ParseTuple(arg, "O!O", &PySurface_Type, &surfobj, &file))
+		return NULL;
+	surf = PySurface_AsSurface(surfobj);
+
+	if(surf->flags & SDL_OPENGL)
+	{
+		/*we need to get ahold of the pyopengl glReadPixels function*/
+		/*we use pyopengl's so we don't need to link with opengl at compiletime*/
+		PyObject *pyopengl, *readpixels = NULL;
+		int typeflag, formatflag;
+
+		pyopengl = PyImport_ImportModule("OpenGL.GL");
+		if(pyopengl)
+		{
+			PyObject* dict = PyModule_GetDict(pyopengl);
+			if(dict)
+			{
+				formatflag = PyInt_AsLong(PyDict_GetItemString(dict, "GL_RGB"));
+				typeflag = PyInt_AsLong(PyDict_GetItemString(dict, "GL_UNSIGNED_BYTE"));
+				readpixels = PyDict_GetItemString(dict, "glReadPixels");
+			}
+			Py_DECREF(pyopengl);
+		}
+
+		if(readpixels)
+		{
+			unsigned char *pixels;
+			PyObject *data;
+
+			data = PyObject_CallFunction(readpixels, "iiiiii", 
+						0, 0, surf->w, surf->h, formatflag, typeflag);
+			if(!data)
+				return NULL;
+			pixels = PyString_AsString(data);
+
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+#define IMGMASKS 0x000000FF, 0x0000FF00, 0x00FF0000, 0
+#else
+#define IMGMASKS 0x00FF0000, 0x0000FF00, 0x000000FF, 0
+#endif
+
+			temp = SDL_CreateRGBSurface(SDL_SWSURFACE, surf->w, surf->h, 24, IMGMASKS);
+			if(!temp)
+			{
+				Py_DECREF(data);
+				return NULL;
+			}
+#undef IMGMASKS
+
+			for(i=0; i<surf->h; ++i)
+				memcpy(((char *) temp->pixels) + temp->pitch * i, pixels + 3*surf->w * (surf->h-i-1), surf->w*3);
+			
+			Py_DECREF(data);
+		}
+		else
+			return RAISE(PyExc_SDLError, "Cannot locate pyopengl module for OPENGL Surface save");
+
+		surf = temp;
+	}
+	else
+		PySurface_Prep(surfobj);
+
+	if(PyString_Check(file))
+	{
+		char* name = PyString_AsString(file);
+		Py_BEGIN_ALLOW_THREADS
+		result = SDL_SaveBMP(surf, name);
+		Py_END_ALLOW_THREADS
+	}
+	else
+	{
+		SDL_RWops* rw;
+		if(!(rw = RWopsFromPython(file)))
+			return NULL;
+		result = SDL_SaveBMP_RW(surf, rw, 1);
+	}
+
+
+	if(temp)
+		SDL_FreeSurface(temp);
+	else
+		PySurface_Unprep(surfobj);
+
+	if(result == -1)
+		return RAISE(PyExc_SDLError, SDL_GetError());
+
+	RETURN_NONE
+}
+
+
+
+    /*DOC*/ static char doc_get_extended[] =
+    /*DOC*/    "pygame.image.get_extended() -> int\n"
+    /*DOC*/    "save surface as BMP data\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "This will return a true value if the extended image formats\n"
+    /*DOC*/    "from SDL_image are available for loading.\n"
+    /*DOC*/ ;
+
+PyObject* image_get_extended(PyObject* self, PyObject* arg)
+{
+	if(!PyArg_ParseTuple(arg, ""))
+		return NULL;
+	return PyInt_FromLong(is_extended);
+}
+
+
 static PyMethodDef image_builtins[] =
 {
-	{ "load", load, 1, doc_load },
+	{ "load_basic", image_load_basic, 1, doc_load },
+	{ "save", image_save, 1, doc_save },
+	{ "get_extended", image_get_extended, 1, doc_get_extended },
 
 	{ NULL, NULL }
 };
 
 
     /*DOC*/ static char doc_pygame_image_MODULE[] =
-    /*DOC*/    "Contains routines to load Surfaces from image files. This\n"
-    /*DOC*/    "module must be manually imported, since it requires the use of\n"
-    /*DOC*/    "the SDL_image library.\n"
+    /*DOC*/    "This module contains functions to transfer images in and out\n"
+    /*DOC*/    "of Surfaces. At the minimum the included load() function will\n"
+    /*DOC*/    "support BMP files. If SDL_image is properly installed when\n"
+    /*DOC*/    "pygame is installed, it will support all the formats included\n"
+    /*DOC*/    "with SDL_image. You can call the get_extended() function to test\n"
+    /*DOC*/    "if the SDL_image support is available.\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "Some functions that communicate with other libraries will require\n"
+    /*DOC*/    "that those libraries are properly installed. For example, the save()\n"
+    /*DOC*/    "function can only save OPENGL surfaces if pyopengl is available.\n"
     /*DOC*/ ;
 
 PYGAME_EXPORT
 void initimage(void)
 {
 	PyObject *module, *dict;
+	PyObject *extmodule;
 
     /* create the module */
 	module = Py_InitModule3("image", image_builtins, doc_pygame_image_MODULE);
 	dict = PyModule_GetDict(module);
 
+
+	/* try to get extended formats */
+	extmodule = PyImport_ImportModule("pygame.imageext");
+	if(extmodule)
+	{
+		PyObject *extdict = PyModule_GetDict(extmodule);
+		PyObject* extload = PyDict_GetItemString(extdict, "load_extended");
+		PyDict_SetItemString(dict, "load_extended", extload);
+		PyDict_SetItemString(dict, "load", extload);
+		Py_INCREF(extload);
+		Py_INCREF(extload);
+		is_extended = 1;
+	}
+	else
+	{
+		PyObject* basicload = PyDict_GetItemString(dict, "load_basic");
+		PyErr_Clear();
+		PyDict_SetItemString(dict, "load_extended", Py_None);
+		PyDict_SetItemString(dict, "load", basicload);
+		Py_INCREF(Py_None);
+		Py_INCREF(basicload);
+		is_extended = 0;
+	}
+
+
 	/*imported needed apis*/
 	import_pygame_base();
 	import_pygame_surface();
+/*
+    pygame - Python Game Library
+    Copyright (C) 2000-2001  Pete Shinners
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Pete Shinners
+    pete@shinners.org
+*/
+
+/*
+ *  extended image module for pygame, note this only has
+ *  the extended load function, which is autmatically used
+ *  by the normal pygame.image module if it is available.
+ */
+#include "pygame.h"
+#include <SDL_image.h>
+
+
+static char* find_extension(char* fullname)
+{
+	char* dot;
+
+	if(!fullname)
+		return NULL;
+
+	dot = strrchr(fullname, '.');
+	if(!dot)
+		return fullname;
+
+	return dot+1;
+}
+
+
+
+static PyObject* image_load_ext(PyObject* self, PyObject* arg)
+{
+	PyObject* file, *final;
+	char* name = NULL;
+	SDL_Surface* surf;
+	SDL_RWops *rw;
+	if(!PyArg_ParseTuple(arg, "O|s", &file, &name))
+		return NULL;
+
+	VIDEO_INIT_CHECK();
+
+	if(PyString_Check(file))
+	{
+		name = PyString_AsString(file);
+		Py_BEGIN_ALLOW_THREADS
+		surf = IMG_Load(name);
+		Py_END_ALLOW_THREADS
+	}
+	else
+	{
+		if(!name && PyFile_Check(file))
+			name = PyString_AsString(PyFile_Name(file));
+
+		if(!(rw = RWopsFromPython(file)))
+			return NULL;
+		if(RWopsCheckPython(rw))
+			surf = IMG_LoadTyped_RW(rw, 1, find_extension(name));
+		else
+		{
+			Py_BEGIN_ALLOW_THREADS
+			surf = IMG_LoadTyped_RW(rw, 1, find_extension(name));
+			Py_END_ALLOW_THREADS
+		}
+	}
+
+	if(!surf)
+		return RAISE(PyExc_SDLError, IMG_GetError());
+
+	final = PySurface_New(surf);
+	if(!final)
+		SDL_FreeSurface(surf);
+	return final;
+}
+
+
+
+
+
+static PyMethodDef image_builtins[] =
+{
+	{ "load_extended", image_load_ext, 1, NULL },
+
+	{ NULL, NULL }
+};
+
+
+
+
+PYGAME_EXPORT
+void initimageext(void)
+{
+    /* create the module */
+	Py_InitModule3("imageext", image_builtins, NULL);
+
+	/*imported needed apis*/
+	import_pygame_base();
+	import_pygame_surface();
+	import_pygame_rwobject();
+}
+
     /*DOC*/    "Surface.save(file) -> None\n"
     /*DOC*/    "save surface as BMP data\n"
     /*DOC*/    "\n"
-    /*DOC*/    "This will save your surface in the BMP format. The given file\n"
-    /*DOC*/    "argument can be either a filename or a python file-like object\n"
-    /*DOC*/    "to save the BMP image to.\n"
+    /*DOC*/    "This function is depracated, please don't use it. It will print\n"
+    /*DOC*/    "a warning when called, but eventually be removed from pygame.\n"
+    /*DOC*/    "You should now use the enhanced pygame.image.save() function.\n"
     /*DOC*/ ;
 
 static PyObject* surf_save(PyObject* self, PyObject* arg)
 	PyObject* file;
 	SDL_RWops *rw;
 	int result;
+	static int warned = 0;
+
+	if(!warned)
+	{
+		warned = 1;
+		fprintf(stderr, "Surface.save() is now depracated. Please don't use.\n");
+	}
+
 	if(!PyArg_ParseTuple(arg, "O", &file))
 		return NULL;