Python 和 PyGame 的一些示例
看到一个网页收集了很多使用Python和PyGame写游戏的示例,分享给大家。(注:我不知道用Python/PyGame写游戏其性能会怎么样,但是一些小游戏应该是没有问题的)
这个网页同时给了一本介绍Python和PyGame的电子书(PDF),下面的这些例子就是这本书的示例。所有的这些示例可以打包下载。
目录
基础 Python 示例Pygame 图形示例Pygame 示例游戏示例创建一个安装包搜索和排序示例文件示例其它信息
基础 Python 示例
if_statement_examples.py – if 语句的一个简单示例
for_loop_examples.py – for 语句的一个简单示例.
while_loop_examples.py – while 语句的一个简单示例
Pygame 图形示例
pygame_base_template.py – 开启一个黑的 pygame 窗口。当你要写一个新的代码时,你可以使用这个示例的代码初始化你的程序。![]()
simple_graphics_demo.py – 作图,画一些简单的图形。![]()
functions_and_graphics.py – 图一些雪人。![]()
animating_snow.py – 下雪动画。![]()
move_keyboard.py – 使用键盘移动一个图形
move_mouse.py – 使用鼠标移动一个图形
move_game_controller.py – 使用游戏手柄移动一个图形
bitmapped_graphics.py – 显示一些图片(png, jpb),并加入一些声音。
array_backed_grid.py – 一个网格,可以用来开发一些棋类的游戏。
Pygame 示例
sprite_collect_blocks.py – 使用鼠标移动一个小点move_sprite_keyboard_jump.py – 用键盘移动一个点(跳动式的)
move_sprite_keyboard_smooth.py – 用键盘移动一个点(平滑式的).
move_sprite_game_controller.py – 用游戏手柄移动一个点
move_with_walls_example.py – 移动一个点,但是会被墙阻止。
游戏示例
bounce_ball_with_paddle.py – 两个玩家玩对碰球游戏,需要两个手柄。
另一个学生的作业. Fall 2010Download games – .
创建一个安装包
Python Pygame 安装包教程
搜索和排序示例
example_sorted_names.txt – Sample file of names used in searching_example.py searching_example.py – Example linear and binary searches AliceInWonderLand.txt – Text of Alice In Wonderland. Source: Project Gutenberg AliceInWonderLand200.txt dictionary.txt sorting_examples.py – Example code for the insertion and selection sorts.文件示例
high_score.py – Example that shows how to read and write a high score to the disk so that it persists between program runs.
其它信息
Pygame Website – Pygame 主站 Pygame Documentation – Pygame 文档——————————
最后,不好意思很久没有更新酷壳,这段时间在国外出差,事多,5月31回国。大家见谅!
转载于酷壳CoolShell 无删改 仅以此纪念陈皓(左耳朵耗子)
(感谢网友 @Hesey小纯纯 投稿 博客 | 原文链接) Java程序员在编码过程中通常不需要考虑内存问题,JVM经过高度优化的GC机制大部分情况下都能够很好地处理堆(He…
我说这个事,只是觉得闲鱼的处理有失偏颇,原因不详,看看大家的看法,还请大家手下留情 我尽量准确客观的描述,但毕竟一面之词难免会有我没有意识到的不准确的地方,但大概的时间线就是这…
最近玩 win10 虚拟机,研究怎么彻底关闭/禁用 WD ,即 Windows Defender ,做个记录 手动到安全中心一个个关闭,重启后大部分保持关闭,但最关键的“实时保…
合速度