我正在制作一款自上而下的射击游戏,希望我的僵尸能够跟随我的角色移动,我的程序使用主循环。我的角色的位置是x和y,并且由箭头键控制。我有一个僵尸,现在它会在屏幕左边缘随机生成。如何使僵尸从生成点开始跟随我的位置移动?
这是僵尸函数:
这是僵尸函数:
def makezombie():
global zom
zom = Rect (0,randint(0, height-40), 49, 38)
return zom
我设置了zombie=makezombie()
在我的主循环中,我有以下代码:
for shot in shots:
if zombie.collidepoint(shot[X],shot[Y]):
zombie=makezombie()
points+=1000
impact.play()
blood.play()
import timeit; timeit.timeit('y = x**0.5', 'x=101398', number=1000000)
。测量 math.sqrt() 方法的时间:import timeit; timeit.timeit('y = sqrt(x)', 'from math import sqrt; x=101398', number=1000000)
。 - Blair