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 – 使用鼠标移动一个小点 sprite_collect_circle.py – 和上面的示例一样,只不过是圆点。 sprite_collect_graphic.py – 和上面的示例一样,只不过是图片。 move_sprite_mouse.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 – 两个玩家玩对碰球游戏,需要两个手柄。 breakout_simple.py – 一个简单的游戏,显示 “Game Over” 信息. 一个学生的作业. Spring 2011 另一个学生的作业. 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 无删改 仅以此纪念陈皓(左耳朵耗子)
因为经济形式整体不行导致大环境机会变少,这时远程工作的岗位就能跨越地理的限制给我们更多的机会和可能。而我也在整个大环境下选择了一个远程工作的机会,因为我个人很愿意去分享,不论是…
www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=923&itemId=931&itemUrl=zhengwuxinx…
会出现很多空格,怎么解决? 就第一个有问题,ctrl+shift+`打开新的就正常了。 指定字体没用。 你这终端字体没配好吧 感觉是终端字体问题,尝试指定 vscode …