
本期介绍九宫格拼图游戏的python编程,仍然是基于pgzero。关于该软件包的基础使用技巧可参考本人专栏文章:
老娄:python游戏编程之pgzero使用介绍zhuanlan.zhihu.com
笔者使用的完整代码如下:
import pgzrun
import random
import pgzrun
from copy import deepcopy
#In order to find out the height of each picture, we could do it by calling the next attribute
pig1 = Actor("pig01")
SIZE = pig1.height
# then we can figure out the exact width and height of the screen
WIDTH = SIZE * 3
HEIGHT = SIZE * 3
pics = []
for i in range(1,10):
pig = Actor("pig0"+str(