看到一个网页收集了很多使用Python和PyGame写游戏的示例,分享给大家。(注:我不知道用Python/PyGame写游戏其性能会怎么样,但是一些小游戏应该是没有问题的)


这个网页同时给了一本介绍Python和PyGame的电子书(PDF),下面的这些例子就是这本书的示例。所有的这些示例可以打包下载


基础 Python 示例



Pygame 图形示例









pygame_base_template.py
– 开启一个黑的 pygame 窗口。当你要写一个新的代码时,你可以使用这个示例的代码初始化你的程序。
Python 和 PyGame 的一些示例
simple_graphics_demo.py
– 作图,画一些简单的图形。
Python 和 PyGame 的一些示例


















functions_and_graphics.py
– 图一些雪人。
Python 和 PyGame 的一些示例
animating_snow.py
下雪动画。
Python 和 PyGame 的一些示例
move_keyboard.py
使用键盘移动一个图形

 


move_mouse.py – 使用鼠标移动一个图形


move_game_controller.py
– 使用游戏手柄移动一个图形

Python 和 PyGame 的一些示例
bitmapped_graphics.py
– 显示一些图片(png, jpb),并加入一些声音。
Python 和 PyGame 的一些示例
array_backed_grid.py
一个网格,可以用来开发一些棋类的游戏。
Python 和 PyGame 的一些示例

Pygame 示例


















sprite_collect_blocks.py
– 使用鼠标移动一个小点
Python 和 PyGame 的一些示例
sprite_collect_circle.py
– 和上面的示例一样,只不过是圆点。
Python 和 PyGame 的一些示例
sprite_collect_graphic.py
– 和上面的示例一样,只不过是图片。
Python 和 PyGame 的一些示例
move_sprite_mouse.py
用鼠标移动一个点

 


move_sprite_keyboard_jump.py
– 用键盘移动一个点(跳动式的)


move_sprite_keyboard_smooth.py
– 用键盘移动一个点(平滑式的).


move_sprite_game_controller.py
– 用游戏手柄移动一个点

Python 和 PyGame 的一些示例
move_with_walls_example.py
– 移动一个点,但是会被墙阻止。
Python 和 PyGame 的一些示例

游戏示例















bounce_ball_with_paddle.py
– 两个玩家玩对碰球游戏,需要两个手柄。
Python 和 PyGame 的一些示例
breakout_simple.py
一个简单的游戏,显示 “Game Over” 信息.
Python 和 PyGame 的一些示例
一个学生的作业. Spring 2011 Python 和 PyGame 的一些示例
另一个学生的作业. Fall 2010

 


Download games – .

Python 和 PyGame 的一些示例

创建一个安装包


Python
Pygame 安装包教程


搜索和排序示例



文件示例


high_score.py – Example that
shows how to read and write a high score to the disk so that it persists between
program runs.


其它信息



(全文完)

相关文章:

  • 2021-06-24
  • 2021-09-22
  • 2021-09-13
  • 2022-12-23
  • 2021-08-30
  • 2021-11-28
猜你喜欢
  • 2021-10-24
  • 2023-02-14
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-08-23
相关资源
相似解决方案