Popular recipes tagged "pygame"http://code.activestate.com/recipes/tags/pygame/popular/2015-01-03T02:04:02-08:00ActiveState Code RecipesSnake the game (Python) 2015-01-03T02:04:02-08:00Burak Tandoganhttp://code.activestate.com/recipes/users/4191373/http://code.activestate.com/recipes/578996-snake-the-game/ <p style="color: grey"> Python recipe 578996 by <a href="/recipes/users/4191373/">Burak Tandogan</a> (<a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/snake/">snake</a>, <a href="/recipes/tags/the/">the</a>). Revision 3. </p> <p>Popular Snake game with Python-Pygame module. <strong>Important:</strong> If you try to run this script without special <strong>png-wav</strong> files it will fail, you have to put following files to a directory with this script. "apple.png","snakehead.png","intro.wav","dead.wav". They are basically apple picture, head of snake, intro sound and dead sound.Without them script will not run. Just make inactive the statements intro.wav and dead.wav, and find a little apple picture and snake head :).Or you can play the game just install it. <strong>Here is the installer:</strong> <a href="http://dosya.co/7c6f15c0f4d04514/Flafel-1.26-win32.rar" rel="nofollow">http://dosya.co/7c6f15c0f4d04514/Flafel-1.26-win32.rar</a> It will install the game in program files, you can find it in search "Flafel" and click to Flafel.exe. </p> Python Game of Life (Python) 2014-01-14T14:34:17-08:00Christian Careagahttp://code.activestate.com/recipes/users/4186639/http://code.activestate.com/recipes/578808-python-game-of-life/ <p style="color: grey"> Python recipe 578808 by <a href="/recipes/users/4186639/">Christian Careaga</a> (<a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>Conway's Game of Life written in Python with Pygame!</p> <p>Here is a screenshot: <a href="http://adf.ly/c4cnA" rel="nofollow">http://adf.ly/c4cnA</a></p> <p>Here is the exe version!: <a href="http://adf.ly/c4bMO" rel="nofollow">http://adf.ly/c4bMO</a></p> <p>Hope you like it!</p> A Complete Morse Code Generator in Python with Sound (Python) 2013-01-08T18:13:33-08:00Captain DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578411-a-complete-morse-code-generator-in-python-with-sou/ <p style="color: grey"> Python recipe 578411 by <a href="/recipes/users/4184772/">Captain DeadBones</a> (<a href="/recipes/tags/morse_code/">morse_code</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>This is a complete Morse Code Generator with sound. You can <a href="http://temp3.net/thelivingpearl_downloads/morse_sound_files.zip">download the sound files (ogg) for Morse Code</a>. For more information checkout the article <a href="http://thelivingpearl.com/2013/01/08/morse-code-and-dictionaries-in-python-with-sound/">Morse Code and Dictionaries in Python</a></p> Recursive Mandelbrot Generation (Python) 2013-08-11T03:46:46-07:00Bill Picketthttp://code.activestate.com/recipes/users/4174028/http://code.activestate.com/recipes/578635-recursive-mandelbrot-generation/ <p style="color: grey"> Python recipe 578635 by <a href="/recipes/users/4174028/">Bill Pickett</a> (<a href="/recipes/tags/mandelbrot/">mandelbrot</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/recursion/">recursion</a>). Revision 12. </p> <p>This program recursively generates a Mandelbrot set using Python and PyGame. The size of the window must be a power of two or you will get rendering errors in the final image. It was written as an exercise in recursion, primarily to further my own understanding of that.</p> Play a Sound File in Python using PyGame (Python) 2013-01-08T18:08:55-08:00Captain DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578410-play-a-sound-file-in-python-using-pygame/ <p style="color: grey"> Python recipe 578410 by <a href="/recipes/users/4184772/">Captain DeadBones</a> (<a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/sound/">sound</a>). </p> <p>This is how you can play an ogg sound file in python using the pygame library. This is part of an article about <a href="http://thelivingpearl.com/2013/01/08/morse-code-and-dictionaries-in-python-with-sound/">Morse Code and Dictionaries in Python</a></p> Libreenect (OpenKinect) Minimum Value Joystick With Display - Kinect Demo Using OpenKinect SDK (Python) 2012-03-18T18:52:42-07:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/578080-libreenect-openkinect-minimum-value-joystick-with-/ <p style="color: grey"> Python recipe 578080 by <a href="/recipes/users/4179768/">Alexander James Wallar</a> (<a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/computer_vision/">computer_vision</a>, <a href="/recipes/tags/depth/">depth</a>, <a href="/recipes/tags/joystick/">joystick</a>, <a href="/recipes/tags/kinect/">kinect</a>, <a href="/recipes/tags/libfreenect/">libfreenect</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/opencv/">opencv</a>, <a href="/recipes/tags/programming/">programming</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/virtual_joystick/">virtual_joystick</a>). Revision 3. </p> <p>This demo requires you to be using a Linux machine and to have libfreenect installed with the python wrapper. This demo also requires you to have opencv, numpy, and pygame. They can all be installed using sudo apt-get install {PROGRAM NAME HERE}. Here are instructions on installing libfreenect: <a href="http://openkinect.org/wiki/Getting_Started" rel="nofollow">http://openkinect.org/wiki/Getting_Started</a>. Okay, so what this demo does is finds the minimum point on the depth image and uses the index of this minimum point to create a four button joystick that codes for 'A', 'B', 'X', 'Y'. It also uses the minimum point and the RGB image to put a circle on the minimum point on the screen. So basically a dot will follow your hand on the RGB image. If the minimum value is larger than 600 (arbitrary units), the color of the dot will change from red to purple and the dot will remain stationary. Also, if the Kinect is not properly opened the first time, unplug it and plug it back in and run in the terminal sudo freenect-glview. After try running the program again. One more thing, this code requires super user privileges so run it through the terminal. Here is how to do this for linux n00bs.</p> <ol> <li>Change your directory the the directory the code is in (use cd {PATH})</li> <li>Run the code using sudo python {FILENAME}</li> <li>Don't forget to add the the .py at the end</li> </ol> Planet Terrain Heightmap Generator (Python) 2010-03-10T16:35:37-08:00Shea Kauffmanhttp://code.activestate.com/recipes/users/4168682/http://code.activestate.com/recipes/576929-planet-terrain-heightmap-generator/ <p style="color: grey"> Python recipe 576929 by <a href="/recipes/users/4168682/">Shea Kauffman</a> (<a href="/recipes/tags/creation/">creation</a>, <a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/heightmap/">heightmap</a>, <a href="/recipes/tags/landscape/">landscape</a>, <a href="/recipes/tags/map/">map</a>, <a href="/recipes/tags/pil/">pil</a>, <a href="/recipes/tags/planet/">planet</a>, <a href="/recipes/tags/planted/">planted</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/terrain/">terrain</a>, <a href="/recipes/tags/world/">world</a>). Revision 9. </p> <p>The process is simply: 1. Take a plane 2. Cut out a shape 3. Make it a little taller 4. Repeat</p> <ul> <li>Similar to the <a href="http://freespace.virgin.net/hugo.elias/models/m_landsp.htm">spherical landscape</a> algorithm by Hugo Elias.</li> <li>I found a combination of Ovals and Triangles to produce the best results.</li> </ul> Play sound files with pygame in a cross-platform manner (Python) 2007-06-21T14:16:58-07:00Chris Arndthttp://code.activestate.com/recipes/users/1499228/http://code.activestate.com/recipes/521884-play-sound-files-with-pygame-in-a-cross-platform-m/ <p style="color: grey"> Python recipe 521884 by <a href="/recipes/users/1499228/">Chris Arndt</a> (<a href="/recipes/tags/multimedia/">multimedia</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/sysadmin/">sysadmin</a>). Revision 4. </p> <p>This simple script shows how to play back a sound file using the mixer module from the pygame library. If you have pygame installed, this will work on all major platforms. The mixer module supports WAV and OGG files with many different sample rates, bits per sample and channels. The script will play back all supported files given on the command line sequentially.</p>