Differences between revisions 9 and 50 (spanning 41 versions)
Revision 9 as of 2002-10-12 06:07:13
Size: 4890
Editor: cdm-66-113-120-geor
Comment:
Revision 50 as of 2020-12-03 12:57:14
Size: 3649
Comment: removed dead link
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

You can write whole games in Python using [http://www.pygame.org/ PyGame].
You can write whole games in Python using [[http://www.pygame.org/|PyGame]]. See a list of other PythonGameLibraries maintained in this Wiki, or [[http://www.devmaster.net/engines/list.php?fid=6&sid=11|this list maintained on DevMaster.net]]. A full tutorial can be found in the free book [[http://inventwithpython.com/pygame|"Making Games with Python & Pygame"]].
Line 7: Line 6:
Read [http://www.onlamp.com/pub/a/python/2002/07/11/pythonnews.html Humongous Python] for a case study. == Websites ==
[[https://coderslegacy.com/python/python-pygame-tutorial/|Pygame - The Full Tutorial]] - A complete pygame tutorial that teaches it from the ground up. Several game projects are also available with step by step explanations and the source.
Line 9: Line 9:
Another library is [http://www.alobbs.com/pykyra PyKyra]:
  PyKyra is a fast game development framework for Python. It is based in SDL and the Kyra engine. In addition to the standard features of Kyra, PyKyra also supports MPEG video, sound (MP3, Ogg Vorbis, Wav and Multichannel module files), direct images reading and much more. -- InTheirOwnWords
[[https://web.archive.org/web/20121021155936/http://onlamp.com/pub/a/python/2002/07/11/pythonnews.html|Humongous Python]] for a 2002 case study on Pygame.
Line 12: Line 11:
== Testimony == [[https://coderslegacy.com/python/pygame-rpg-game-tutorial/|Pygame RPG Series]] - A series of short tutorials over the course of which a complete RPG styled game is created using Pygame.
Line 14: Line 13:
I tried porting [http://taoriver.net/eouwiki/ Escape of the Unicorn] to Python/PySDL, but the game dropped from 30 fps to 6 fps. [[https://pygametutorials.wikidot.com/|Pygame programming tutorials]] is a compilation of a few short tutorials for Pygame.
Line 16: Line 15:
After a lot of profiling and unrolling screen draw code, I was able to reach 8 frames a second. [[https://pythonspot.com/game-development-with-pygame/|Game development with Pygame]] is a tutorial that is an introduction to Pygame. Also contains tutorials on how to make several basic games in Pygame.
Line 18: Line 17:
If you look at PyGame and PySDL games, you'll notice that they aren't action or arcade games. If you're interested in learning how to use Pygame to create 3D games, two sites that are dedicated to 3D Python are [[http://www.py3d.org/|Python 3D(py3d.org)]] and [[http://www.vrplumber.com/py3d.py|Python 3D Software]]. You can find several 3D game projects available here.
Line 20: Line 19:
I have only heard of few efforts that succeeded in embedding Python in C++, and I have forgotten them. For the most part, people (including Humongous, as described in [http://www.onlamp.com/pub/a/python/2002/07/11/pythonnews.html the case study described]) extend Python with C++. If you are going to mix Python and C++, I think it is best to extend Python- that is the intended direction. I consider this a failing of Python. [[http://www.pyweek.org/|PyWeek]] is a bi-annual programming challenge site that produces several great games.
Line 22: Line 21:
If you want to embed a scripting system because you already have a huge system, embed something like Guile. I think it is an inferior solution, but that it will result in a lot less heartbreak. == Books ==
There's also some books that specifically cover game programming in Python:
Line 24: Line 24:
I suspect I'll try to rewrite Escape of the Unicorn as a C++/Python mixture some day, and pay careful attention to how I cut the C++/Python lines.
I think only a few things need to be given to C++, such as display loops, animation management, and collision detection.
[[http://inventwithpython.com/|http://inventwithpython.com]]
Line 27: Line 26:
-- LionKimbro [[DateTime(2002-07-19T10:45:57)]]  . [[http://inventwithpython.com/|"Invent Your Own Computer Games with Python"]] is a free, Creative Commons-licensed book on Python for complete beginners with no experience programming. Each chapter has the source code for a small game such as Tic Tac toe, Hangman, Reversi, and others. The final chapters provide an introduction to Pygame.
Line 29: Line 28:
http://inventwithpython.com/pygame
Line 30: Line 30:
Not every type of game will work well with python. Although I must disagree that none of the games written in pygame are action or arcade games. Pygame can do extremely well in these environments. My first game, SolarWolf, is an action arcade game. It runs locked and limited at 40 frames per second with its 800x600 graphics, with generally over 50 animated objects on the screen. It uses time-scaling to control animations on slower machines, and has been rated very playable by people on less than 200mhz pentiums.  . [[http://inventwithpython.com/pygame|"Making Games with Python & Pygame"]] is also a free, Creative Commons-licensed book that assumes a small amount of Python programming experience. It goes into more detail with the Pygame library. There is the source code for games such as Tetris, Connect Four, Simon, Sokoban, and others.
Line 32: Line 32:
The general performance problems people have with pygame are related to using the SDL library. Without special tweaking, games usually run on SDL with no hardware acceleration. This can take a noticeable speed hit on games with fullscreen scrolling graphics. Generally, speeding up the python code will have minimal performance games, but optimizing what is drawn will have significant impact. http://www.handysoftware.com/cpif
Line 34: Line 34:
Still, I concede that there are types of games that just won't be suited towards python. But the situation is far more hopeful than the experiences of 'Escape of the Unicorn'.  . "The author set out to write a book like the one he used to teach himself programming at age 12. ... This book has been successfully used by homeschooling families and public school teachers." The library and example code supplied with the book is also available for download.
Line 36: Line 36:
-- Pete 'ShredWheat' Shinners http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470068221.html
Line 38: Line 38:

I work for a publicly held MMP game publishing company. I can't provided too many details because most of the interesting stuff is company confidential. However, I can testify that we are using Python to develop both the client and the server architectures. To be fair, the core graphics engine and high performance stuff is written in C++, but the game code is in Python. It goes something like this:

Client: The executable is the Python interpreter, and it loads C++ extension modules for 3D rendering, collision, UI, movement, and such. Game code is written in Python. The main rendering loop is in C++, however, which is a critical point for performance. In development we get around 50 FPS with a high-poly scene, and up to several hundred FPS rendering a single large triangle :P.

Server: The executable is a C++ server framework that embeds the Python interpreter, which also imports C++ extension modules. Again, high performance code, such as networking, movement, AI, and physics is in C++ (combining extensions and native code). Game code is in Python. But this is most of the code. Game code on the server consists of every system that has anything to do with the rules of the game, scripting, object interaction, combat, trade, inventory, etc. etc.

We do not use SDL, so I can't comment on it. However, I can say that, the right mix of Python and C++ is an ideal combination of technologies for game development. Just like any Python app, you have to keep the performance critical stuff in extensions, and minimize the calls between Python and C++. But the high level logic, game code, and other "fun stuff" lends itself to Python very well.

-- Matt Walker
 . "Ever want to develop your own computer game? Learn the practical concepts of object-oriented programming for game design using Python in this easy-to-follow, content-filled guide. Whether you're a student, aspiring game developer, or veteran programmer, you'll gain skills as you progress from station to station in a series of clear-cut tutorials on different styles of games. The last stop will be a finished game program for you to show off."

Game Programming With Python

You can write whole games in Python using PyGame. See a list of other PythonGameLibraries maintained in this Wiki, or this list maintained on DevMaster.net. A full tutorial can be found in the free book "Making Games with Python & Pygame".

If you have an existing game and want to add a scripting engine to make it more flexible, Python is also a very good choice. But you'll have to learn about IntegratingPythonWithOtherLanguages.

Websites

Pygame - The Full Tutorial - A complete pygame tutorial that teaches it from the ground up. Several game projects are also available with step by step explanations and the source.

Humongous Python for a 2002 case study on Pygame.

Pygame RPG Series - A series of short tutorials over the course of which a complete RPG styled game is created using Pygame.

Pygame programming tutorials is a compilation of a few short tutorials for Pygame.

Game development with Pygame is a tutorial that is an introduction to Pygame. Also contains tutorials on how to make several basic games in Pygame.

If you're interested in learning how to use Pygame to create 3D games, two sites that are dedicated to 3D Python are Python 3D(py3d.org) and Python 3D Software. You can find several 3D game projects available here.

PyWeek is a bi-annual programming challenge site that produces several great games.

Books

There's also some books that specifically cover game programming in Python:

http://inventwithpython.com

  • "Invent Your Own Computer Games with Python" is a free, Creative Commons-licensed book on Python for complete beginners with no experience programming. Each chapter has the source code for a small game such as Tic Tac toe, Hangman, Reversi, and others. The final chapters provide an introduction to Pygame.

http://inventwithpython.com/pygame

  • "Making Games with Python & Pygame" is also a free, Creative Commons-licensed book that assumes a small amount of Python programming experience. It goes into more detail with the Pygame library. There is the source code for games such as Tetris, Connect Four, Simon, Sokoban, and others.

http://www.handysoftware.com/cpif

  • "The author set out to write a book like the one he used to teach himself programming at age 12. ... This book has been successfully used by homeschooling families and public school teachers." The library and example code supplied with the book is also available for download.

http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470068221.html

  • "Ever want to develop your own computer game? Learn the practical concepts of object-oriented programming for game design using Python in this easy-to-follow, content-filled guide. Whether you're a student, aspiring game developer, or veteran programmer, you'll gain skills as you progress from station to station in a series of clear-cut tutorials on different styles of games. The last stop will be a finished game program for you to show off."

GameProgramming (last edited 2020-12-03 12:57:14 by ShadowClaw20017)

Unable to edit the page? See the FrontPage for instructions.