![](https://csdnimg.cn/release/download_crawler_static/87965943/bg1.jpg)
xxxx 大学毕业设计(论文)
xx xxxx 大 学
毕业设计(论文)
题 目 基于 Python的 Pygame 框架研究
学 院 计算机与控制工程学院
专业班级 计本 111
学生姓名 xx
指导教师 xx
成 绩
2015 年 06 月 19 日
![](https://csdnimg.cn/release/download_crawler_static/87965943/bg2.jpg)
xxxx 大学毕业设计(论文)
I
摘 要
该论文论述了 Python语言中 Pygame 库的框架结构和一些常用的该库的 API,使用
Pygame 库进行 2D 游戏开发时需要注意的事项,以及进行 2D 游戏开发的常用技巧,站
在开发者的角度,理论系统的讲解了 Pygame 游戏开发中的使开发技巧。本论文旨在帮
助入门级 Pygame 游戏开发者能够快速的适应和熟悉该框架的开发规范,能够迅速的使
用 Pygame 框架进行相应的游戏开发。
这个 Pygame 框架是一个对所有程序员开放的 Python库。Pygame 作为 Python语言
的扩展,它的所有书写规范都完全按照 Python 的语法规则来进行设计和开发。而作为
一个开放的语言库,意味着开发者能够更多的看到底层代码的运行原理,甚至修改底层
代码从而对开发者自身的程序进行优化,当然着所有都得建立在开发者熟悉 Python 语
言的基础上。
本论文站在理论的高度对 Python下的 Pygame 框架进行了全面详细的介绍和说明,
还有更进一步游戏开放方面的技术指导,作为 Python 入门级的介绍,本论文足以满足
Pygame 初学者的学习需求。
关键字:Pygame ;框架;游戏开发;源代码开放
![](https://csdnimg.cn/release/download_crawler_static/87965943/bg3.jpg)
xxxxx 大学毕业设计(论文)
II
Abstract
This paper discusses the framework Pygame Python language library and the library some
common API, matters need attention when using Pygame library 2D game development, as
well as common 2D game development skills, developer's perspective is standed , system
theory to explain the Pygame game development make development skills. This paper aims to
help entry-level Pygame game developers to quickly adapt and become familiar with
development specifications of the framework can quickly use Pygame game development
framework accordingly.
The framework is running under the Python language an opened source runtime. Pygame
Python as an extension language, it's all written specifications are fully in accordance with the
rules of grammar Python to carry out design and development. The library as an opened
language, meaning that developers can see more of the operating principle underlying code, or
even modify the underlying code so developers optimize their programs, of course, with all
the familiar developer had to build in language Python basis.
In this paper, at the height of the theoretical framework for Python Pygame under a
comprehensive detailed introduction and description of the game as well as a further opening
up of technical guidance, as Python entry-level introduction, this paper is sufficient to meet
the learning needs of beginners Pygame .
Key words:Pygame;Frame;Game Development; Open source
![](https://csdnimg.cn/release/download_crawler_static/87965943/bg4.jpg)
xxxxx 大学毕业设计(论文)
目录
摘 要 ........................................................................................................................................... I
Abstract ..................................................................................................................................... II
第 1 章 绪论 .............................................................................................................................. 1
1.1 课题研发的目的与意义 ........................................................................................ 1
1.2 可行性分析 ............................................................................................................ 2
1.3 国内外研究现状 .................................................................................................... 3
第 2 章 Pygame 基础 ................................................................................................................ 4
2.1 Pygame来自 Python .................................................................................................... 4
2.2 Pygame环境的要求 .................................................................................................... 5
2.3 Python语法简介 .......................................................................................................... 5
2.4 Pycharm简介 ............................................................................................................... 6
2.6 Pygame环境搭建 ........................................................................................................ 6
第 3 章 Pygame 模块 ................................................................................................................ 9
3.1 Pygame文件结构 ........................................................................................................ 9
3.2 事件 ........................................................................................................................... 10
3.2.1 事件机制 ........................................................................................................ 10
3.2.2 事件处理函数 ................................................................................................ 10
3.2.3 鼠标事件处理 ................................................................................................ 11
3.2.4 键盘事件处理 ................................................................................................ 12
3.2.5 事件过滤 ........................................................................................................ 12
3.3 图像 ........................................................................................................................... 12
3.3.1 色彩像素 ........................................................................................................ 12
3.3.2 图片处理 ........................................................................................................ 13
3.3.3 动画处理 ........................................................................................................ 13
3.4 声音 ........................................................................................................................... 14
3.5 动作 ........................................................................................................................... 16
3.5.1 精灵 ................................................................................................................ 16
3.5.2 向量 ................................................................................................................ 17
3.5.3 碰撞检测 ........................................................................................................ 18
3.6 控制 ........................................................................................................................... 18
3.6.1 键盘控制 ........................................................................................................ 18
![](https://csdnimg.cn/release/download_crawler_static/87965943/bg5.jpg)
xxxxx 大学毕业设计(论文)
3.6.2 鼠标控制 ........................................................................................................ 18
3.7 游戏地图 ................................................................................................................... 19
第 4 章 Pygame 进阶 .............................................................................................................. 20
4.1 AI 智能 .................................................................................................................... 20
4.1.1 状态机 ............................................................................................................ 20
4.1.2 AI 设计 ......................................................................................................... 21
4.2 游戏优化 ................................................................................................................. 21
第 5 章 Pygame 开发思路 ...................................................................................................... 23
5.1 设计游戏 ................................................................................................................... 23
5.2 开发进程 ................................................................................................................... 23
5.3 开发思路 ................................................................................................................... 24
结 论 ........................................................................................................................................ 25
参考文献 .................................................................................................................................. 26
致 谢 ........................................................................................................................................ 27