【脚本语言系列】关于Python游戏工具Pygame,你需要知道的事
来源:互联网 发布:花千骨衣服淘宝 编辑:程序博客网 时间:2024/05/16 14:14
如何使用Pygame
- 安装Pygame
* 使用pip安装Pygame
pip install pygame
* 使用easy_install安装Pygame
easy_install pygame - 制作简单的游戏
1. 导入所需要的Pygame模块
import pygame, sysfrom pygame.locals import *
2. 初始化显示区域
pygame.init()screen = pygame.display.set_mode((400, 300))pygame.display.set_caption('Hello World!')
3. 添加游戏主循环
while True: sysFont = pygame.font.SysFont("None", 19) rendered = sysFont.render ('Hello World', 0, (255, 100, 100)) screen.blit(rendered, (100, 100)) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit()pygame.display.update()
什么是Pygame
Pygame最初是由Pete Shinners编写的一套Python架构。顾名思义,Pygame可以用于制作电子
游戏。自2004年起,Pygame成为GPL(General Public License,通用公共许可证)下的开源免费
软件,这意味着你可以使用它制作任何类型的游戏。Pygame基于SDL(Simple DirectMedia Layer,
简易直控媒体层)。SDL是一套C语言架构,可用于在各种操作系统中(包括Linux、Mac OS X和
Windows)访问图形、声音、键盘以及其他输入设备。
0 0
- 【脚本语言系列】关于Python游戏工具Pygame,你需要知道的事
- 【脚本语言系列】关于Python系统管理,你需要知道的事
- 【脚本语言系列】关于Python容器,你需要知道的事
- 【脚本语言系列】关于Python测试工具lettuce, 你需要知道的事
- 【脚本语言系列】关于Python测试工具mock, 你需要知道的事
- 【脚本语言系列】关于Python测试工具unittest, 你需要知道的事
- 【脚本语言系列】关于Python测试工具docstrings, 你需要知道的事
- 【脚本语言系列】关于Python测试工具Pyflakes, 你需要知道的事
- 【脚本语言系列】关于Python测试工具Pylint, 你需要知道的事
- 【脚本语言系列】关于Python性能分析工具timeit, 你需要知道的事
- 【脚本语言系列】关于Python代码分析工具line_profiler,你需要知道的事
- 【脚本语言系列】关于Python调试报错,你需要知道的事
- 【脚本语言系列】关于Python开发环境搭建,你需要知道的事
- 【脚本语言系列】关于Python数值计算NumPy, 你需要知道的事
- 【脚本语言系列】关于Python机器学习scikits-learn,你需要知道的事
- 【脚本语言系列】关于Python数值计算Pandas,你需要知道的事
- 【脚本语言系列】关于Python统计分析statsmodel,你需要知道的事
- 【脚本语言系列】关于Python邮件服务smtplib,你需要知道的事
- JDBC的使用(mysql)
- spring源码-4-applicationContext(环境上下文)
- linux下valgrind内存泄露检查
- Ubuntu16.04使用小心得
- JS手撸数据结构系列(二) —— 树的遍历
- 【脚本语言系列】关于Python游戏工具Pygame,你需要知道的事
- css笔记1
- 类和对象
- Kanzi基础---Kanzi的4层框架
- 不一样的师徒盛宴
- Kafka笔记三之java操作
- java spring mvc Error:No mapping found for HTTP request with URI
- 蓝桥杯--第七届决赛:路径之谜
- 极化码的原理