最近培训小朋友学编程,首先带入门的是MIT提供的scratch,尽量站在算法和数据结构的高度去引导学生。最近在思考接下来怎么去协助小朋友扩展,思索良久,决定用Python帮助他们去进阶。最好的敲门砖就是游戏了,那么得好好备课下pygame。首先是Pygame的安装,这个比较简单,Pygame官网里直接给的介绍是:
Pygame requires Python; if you don't already have it, you can download it from python.org. Use python 3.6.1 or greater, because it is much friendlier to newbies, and additionally runs faster.
The best way to install pygame is with the pip tool (which is what python uses to install packages). Note, this comes with python in recent versions. We use the --user flag to tell it to install into the home directory, rather than globally.
python3 -m pip install -U pygame --user
安装的过程如下:
安装的结果如下:
To see if it works, run one of the included examples:
python3 -m pygame.examples.aliens
效果如下:
If it works, you are ready to go!
激动人心的时刻快点来临吧。