1. 简介
pygame 是基于对 SDL库的python 封装,提供python接口。SDL(Simple DirectMedia Layer) 是一个跨平台的游戏开发库,方便游戏开发和移植。目前最新版本SDL1.2.14. 下载地址:http://www.libsdl.org/download-1.2.php. SDL库作者Sam
Lantinga,采用C语言开发。SDL还有perl, erlang, Pango,ruby等语言的封装。
pygame 作者是Pete Shinners。
2. 下载pygame包
http://www.oschina.net/p/pygame
软件下载
或通过apt-get 直接安装。没测试。
sudo apt-get install python-pygame
如果是直接下载的,则需要手动配置如下的软件。
3. 安装SDL
我下载的是pygame-1.9.1release.tar.gz,2MB大小。解压后进入目录执行
python config.py
提示
sh: sdl-config: not found
sh: smpeg-config: not found
SDL没有安装,执行
sudo aptitude install libsdl1.2-dev
我按装时遇到缺少依赖的库,就百度,然后下载deb包、安装。
其余源码和其他平台的安装包如rpm可以访问
http://www.libsdl.org/download-1.2.php
找到。
4. 安装其他必须软件
再执行python config.py
提示
Hunting dependencies...
sh: smpeg-config: not found
WARNING: "smpeg-config" failed!
SDL : found 1.2.13
FONT : not found
IMAGE : not found
MIXER : not found
SMPEG : not found
PNG : not found
JPEG : not found
SCRAP : not found
PORTMIDI: not found
PORTTIME: not found
不要放过这些 not found,一个个搞定的。
sudo apt-get install libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl-gfx1.2-dev libsdl-net1.2-dev libsdl-sge-dev libsdl-sound1.2-dev libportmidi-dev libsmpeg-dev
其中mixer是混音库,sound是声音库,ttf是字体库,gfx,sge,image都是图形处理的。smpeg是播放mpeg电影的。midi是处理midi声音的。
安装库的时候,有些依赖可能没有,别怕怕,有百度。哈哈。
如果python没有安装开发库,也会导致pygame不能安装,比如找不到python.h 等文件
sudo apt-get install python2.6-dev
根据机器python版本安装相应的开发库。我的python是2.6.4版本,所以安装2.6的开发库。
还需安装python的numeric库,用于处理向量和数值计算,某些游戏需要。
sudo apt-get install python-numeric python-numpy python-scipy
5. 安装pygame.再次执行
sudo ./config.py
SDL : found 1.2.14
FONT : found
IMAGE : found
MIXER : found
SMPEG : found 0.4.5
PNG : found
JPEG : found
SCRAP : found
PORTMIDI: found
PORTTIME: found
执行
sudo python setup.py
成功后pygame即安装完毕。如果有问题再根据错误安装相应软件和库。
6.试用pygame
进入examples,执行
chmod +x *
./aliens.py
你就尽情的去试吧。
分享到:
相关推荐
安装pygame与pip
安装pygame库
详细给出安装64位pygame的步骤,解决安装whl文件的关键。易学、实用。
压缩包内包含python3.8.10-win32、对应版本pygame、欧陆词典、Thonny IDE。适合初学者懒人包
"8 " " "7 "文件操作 "4 " " "8 "异常处理 "6 " " "9 "游戏开发 "6 " " "10 "网络爬虫 "4 " " "11 "办公自动化 "4 " " "合计 " "64 " " "课题 "游戏开发(一)—— 安装Pygame第三方库 " "课时 "2课时(90 min) " ...
pygame安装
安装pygame库的总结(安装python库通用)(csdn)————程序
pygame模块,且包含所支持的模块
pygame中文文档
2、pygame cmd安装命令 python -m pip install --user pygame-1.9.4-cp37-cp37m-win_amd64.whl (需要cmd cd进入到pygame-1.9.4-cp37-cp37m-win_amd64.whl所在文件夹) 其他版本下载 https://www.lfd.uci.edu/~...
直接敲击键盘,奏出美妙乐章,包含参考琴谱。
在进行增强现实的时候我们需要用到两个工具包:PyGame 和 PyOpenGL,本章在python环境下对这两个工具包的安装进行说明。 一、安装PyGame PyGame 是非常流行的游戏开发工具包,它可以非常简单地处理显示窗口、输入...
基于pygame实现自动扫雷,环境要求:python3(建议Anaconda),安装pygame模块
由Python语言,基于模块pygame开发的简易3D引擎
pygame-1.9.3.tar.gz pygame-1.9.3.tar.gz pygame-1.9.3.tar.gz pygame-1.9.3.tar.gz pygame-1.9.3.tar.gz
安装pygame库,Python以及Pygame模块的安装流程
pygame for Python3.4
pygame 源码及安装包 1.9.1 for python 2.7 开发python游戏开源模块 Pygame is a set of Python modules designed for writing games. Pygame adds functionality on top of the excellent SDL library. This ...
初始化pygame和设置窗口:初始化pygame,并设置了窗口的大小为800x600像素,并设置了窗口标题为"Fireworks Show"。 定义烟花粒子类Particle:Particle类包含了烟花粒子的属性和方法,其中包括位置(x, y)、颜色...