版本1和3间的区别 (跳过第2版)
于2006-07-28 23:12:07修订的的版本1
大小: 10953
编辑: czk
备注:
于2006-09-01 12:58:41修订的的版本3
大小: 2050
编辑: czk
备注:
删除的内容标记成这样。 加入的内容标记成这样。
行号 3: 行号 3:
About = pygame概述 =
行号 5: 行号 5:
    Pygame is a cross-platfrom library designed to make it easy to write multimedia software, such as games, in Python. Pygame requires the Python language and SDL multimedia library. It can also make use of several other popular libraries. pygame是一组用于编写游戏的模块的集合。pygame是构筑在SDL库的基础上的,它使我们能够用Python语言来创建功能完整的游戏和多媒体程序。pygame是高度可移植的,几乎可以在任何平台和操作系统上运行。
行号 7: 行号 7:
pygame是自由、免费的,以LGPL协议发布。你可以用它来创建开源、自由、免费、共享或者商业游戏。
行号 8: 行号 9:
Installation = pygame的安装 =
行号 17: 行号 18:
Help If you are just getting started with pygame, you should be able to get started fairly quickly. Pygame comes with many tutorials and introductions. There is also full reference documentation for the entire library. Browse the documentation from the documenantation index. docs/index.html.
行号 19: 行号 20:
    If you are just getting started with pygame, you should be able to get started fairly quickly. Pygame comes with many tutorials and introductions. There is also full reference documentation for the entire library. Browse the documentation from the documenantation index. docs/index.html. On the pygame website, there is also an online copy of this documentation. You should know that the online documentation stays up to date with the development version of pygame in cvs. This may be a bit newer than the version of pygame you are using.
行号 21: 行号 22:
    On the pygame website, there is also an online copy of this documentation. You should know that the online documentation stays up to date with the development version of pygame in cvs. This may be a bit newer than the version of pygame you are using. Best of all the examples directory has many playable small programs which can get started playing with the code right away.
行号 23: 行号 24:
    Best of all the examples directory has many playable small programs which can get started playing with the code right away. = pygame游戏的编辑和运行 =
行号 26: 行号 27:
Dependencies http://www.pygame.org/readme.html
行号 28: 行号 29:
    Pygame is obviously strongly dependent on SDL and Python. It also links to and embeds several other smaller libraries. The font module relies on SDL_tff, which is dependent on freetype. The mixer (and mixer.music) modules depend on SDL_mixer. The image module depends on SDL_image, which also can use libjpeg and libpng. The transform module has an embedded version of SDL_rotozoom for its own rotozoom function. The surfarray module requires the python Numeric package for its multidimensional numeric arrays. http://www.pygame.org/install.html
行号 30: 行号 31:
License http://www.pygame.org/docs/tut/intro/intro.html
行号 32: 行号 33:
    This library is distributed under GNU LGPL version 2.1, which can be found in the file "doc/LGPL". I reserve the right to place future versions of this library under a different license. http://www.gnu.org/copyleft/lesser.html

    This basically means you can use pygame in any project you want, but if you make any changes or additions to pygame itself, those must be released with a compatible license. (preferably submitted back to the pygame project). Closed source and commercial games are fine.

    The programs in the "examples" subdirectory are in the public domain.

Pygame Installation

Python can be built from source, but the easiest way is to get a binary package for your type of system and version of Python. This document will give you information on either type of installation.

Windows Binary Installer

    This is probably the most popular method of installation. If you are running on windows, it is highly recommended you use this form of installing. The installers come with with nearly everything you need, and have an easy point and click installers.

    The first thing you will need is an installation of Python. Python binary installers make it easy to get this done. Pygame binaries usually come for the latest 2 releases of Python, so you'll want to be fairly up to date.

    Once that is in place, you want to download the appropriate windows binary. From the pygame downloads page you can find the .EXE file you need. This will automatically install all of pygame and all the SDL dependencies. The windows binaries have filenames like this; "pygame-1.7.1.win32-py2.4.exe". This would be the installer for pygame version 1.7.1, for Python version 2.4. You shouldn't have trouble finding the correct binary from the "Windows" section of the download page. http://www.pygame.org/download.shtml.

    You will also probably want to install the windows documentation and installation package. This will add easy links to the different documentation and games that come with pygame. The installer for this is found next to the other windows binary downloads. The filename looks like this; "pygame-docs-1.7.1.exe". And this would install the documentation and examples for pygame-1.7.1

    One other thing the windows binaries are missing is the Numeric Python package. You can easily install this separately and it will allow you to use the pygame "surfarray" module. This module is optional, so there is no need to do this. There are binary installers from the Numeric download page. http://sourceforge.net/project/showfiles.php?group_id=1369.


Unix Binary Packages

    For many unix systems, the easiest way to install pygame is from source. Still, there are binary packages available for different distributions.

    There are several binary RPM packages for linux machines. These are actually a little bit of work to install, since you will also need several RPM packages for the dependencies. There is a good chance your linux distribution came with the needed dependencies (like Python and SDL). There are binary RPMs available from the website for each dependency.

    For debian systems, pygame is actively maintained in the debian archives. Visit the debian pygame page for more information. http://packages.qa.debian.org/p/pygame.html

    FreeBSD also has an active pygame package. While techinicaly it isn't binary, it is automatically built and installed by the ports manager. See the FreeBSD package page for more information. http://www.freebsd.org/cgi/ports.cgi?query=py-game&stype=name

    Gentoo has a builtin package for pygame. This is compiled for your system as it installs, similar to BSD, http://www.gentoo.org/dyn/pkgs/dev-python/pygame.xml


Mac OS X Binaries

    For Mac OS X 10.3 and above, binary packages are available from pythonmac.org packages: http://pythonmac.org/packages/

    This package includes almost of the dependencies required for pygame (SDL, SDL_image, etc.), but you need PyObjC 1.2 or later, and may also want to get Numeric and PyOpenGL.

    To build self-contained pygame applications, you should use py2app. There is an example in: /Developer/Python/pygame/Examples/macosx/aliens_app_example



Installing From Source

    Compiling and installing pygame is handled by Python's distutils. Pygame also comes with some scripts to automatically configure the flags needed to build pygame. Use the "setup.py" script to start the installation.

    The first time you run the setup script, it will call the "config.py" script. This will build a "Setup" file which stores all the information needed to compile. The "config.py" will do a good job of detecting what dependencies are available and where they are located. If it isn't perfect, it is easy to build your own, or edit the created "Setup" text file. This "Setup" file is a simple Makefile-like text file. It defines variables needed to use each dependency, and then enables all the pygame modules with found dependencies. If you have trouble compiling, you should be able to easily fix any problems inside the "Setup" file.

    Running the "setup.py" script will call distutils to build and install the pygame package. Distutils actually supports a wide variety of compile and install options. running "python setup.py help" will start to show you the different options available. You can change many things like install locations, compiler to use, and more. Calling the "setup.py" script with no arguments and it will just ask you if you want the default flags needed to compile and install.


Windows Compiling Info

    Compiling all the dependencies on windows is a real challenge. Fortunately there is zip file with all the libraries and headers you need to compile. You should definitely unzip this into your pygame source folder, and all the files go into a "prebuilt" subdirectory. The autoconfigure "config.py" script will find this prebuilt directory and make use of it for you. http://www.pygame.org/ftp/win32-dependencies.zip. If you don't use the prebuilt binaries directory, the autoconfig script will scan the neighboring directory trees to find the dependencies.

    When installing on windows, the "setup.py" script will also copy all the used .DLL files into the pygame directory.

    If compiling with VisualC, these instructions are all you'll need to do. If you are using Borland's free compiler or cygwin, you will need an extra step. You need to convert the VisualC style .LIB files into the format used by your compiler. Both Borland and Cygwin include a command to do this. To convert the Python library the command looks like this with Borland: COFF2OMF python22.lib python22_bcpp.lib. For Cygwin, this is the command you need: DLLTOOL --dllname python15.dll --def python15.def --output-lib libpython15.a. You will also need to do this conversion on all the LIB files that come with the prebuilt dependencies (in the prebuilt/lib directory). Note that with cygwin you should replace the --def flag and argument with --export-all-symbols since they do not come with .def files.

    Mingw is well supported by SDL, but a little rougher for Python extensions. Here is a link with more information to compiling with non-ms compilers. http://www.python.org/doc/current/inst/non-ms-compilers.html


Unix Compiling Info

    Compiling from linux shouldn't give you any problems. One thing you must keep in mind is that most linux RPM packages separate the actual library from the "dev" files needed to compile. To build you will need to make sure the packages like "SDL-dev" are installed.

    You can check to see if SDL is ready to be built from by running the command sdl-config and seeing if it is found. If the sdl-config script is not on the path (or you have more than one?) Set the environment variable SDL_CONFIG to its location.

    Sometimes you will have the SDL libraries installed in once location, and the other SDL libraries in another. This tricks the pygame config scripts, but you can help it out by setting the environment LOCALBASE to a path prefix where the other libraries are. The common case for this is SDL installed in /usr and other SDL libs installed in /usr/local. The command for this situation is "LOCALBASE=/usr/local python setup.py install".


Mac OS X Compiling Info

    Make sure to have Numeric, PyObjC 1.3 or later, PIL, and the SDL frameworks installed. Compilation should work just same as the unix compiling instructions. Python 2.3 and Mac OS X 10.2 or later are required. To build an installer for Mac OS X that includes pygame, the examples, and the SDL frameworks use the following command: python setup.py bdist_mpkg
http://www.pygame.org/docs/tut/ImportInit.html

在这里详述 Python游戏设计基础/第6讲:Pygame介绍.

pygame概述

pygame是一组用于编写游戏的模块的集合。pygame是构筑在SDL库的基础上的,它使我们能够用Python语言来创建功能完整的游戏和多媒体程序。pygame是高度可移植的,几乎可以在任何平台和操作系统上运行。

pygame是自由、免费的,以LGPL协议发布。你可以用它来创建开源、自由、免费、共享或者商业游戏。

pygame的安装

  • You should definitely begin by installing a binary package for your system. The binary packages usually come with or give the information needed for dependencies. Choose an appropriate installer for your system and version of python from the pygame downloads page. http://www.pygame.org/download.shtml Installing from source is fairly automated. The most work will involve compiling and installing all the pygame dependencies. Once that is done run the "setup.py" script which will attempt to auto-configure, build, and install pygame. Much more information about installing and compiling is available in the install.html file.

If you are just getting started with pygame, you should be able to get started fairly quickly. Pygame comes with many tutorials and introductions. There is also full reference documentation for the entire library. Browse the documentation from the documenantation index. docs/index.html.

On the pygame website, there is also an online copy of this documentation. You should know that the online documentation stays up to date with the development version of pygame in cvs. This may be a bit newer than the version of pygame you are using.

Best of all the examples directory has many playable small programs which can get started playing with the code right away.

pygame游戏的编辑和运行

http://www.pygame.org/readme.html

http://www.pygame.org/install.html

http://www.pygame.org/docs/tut/intro/intro.html

http://www.pygame.org/docs/tut/ImportInit.html

Pygame起步 (2010-01-29 16:48:28由s235-200编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.