我编写了一个关于视觉短期记忆的实验。我想画一次8个方格(4英尺/ 4个)。我编码了一个循环,心理模型每帧绘制8个方格,但在一次试验中我只想要8个方格。我怎么摆脱这个?
def drawLearn():
for i in range(len(squaresLeft)):
while True:
squaresLeft[i].pos = (xL(),y())
validPosition = True
for j in range(i):
if overlaps(squaresLeft[i], squaresLeft[j]):
validPosition = False
if validPosition:
break
for i in range(len(squaresRight)):
while True:
squaresRight[i].pos = (xR(),y())
validPosition = True
for j in range(i):
if overlaps(squaresRight[i], squaresRight[j]):
validPosition = False
if validPosition:
break
Sqr1.draw ()
Sqr2.draw ()
Sqr3.draw ()
Sqr4.draw ()
Sqr5.draw ()
Sqr6.draw ()
Sqr7.draw ()
Sqr8.draw ()
真实审判的一部分:
while True:
if Timer.getTime() >= startLearn and Timer.getTime() <= startLearn + timeLearn.
drawLearn()
if len( event.getKeys(['q']) ) > 0:
break
Wind.flip()
Wind.close()
感谢您的帮助
更新:我想测试320个试验,每个试验由8个方块组成。主要的问题是,每个帧都绘制了8个正方形而RealTrial-Loop但是我希望它们在drawLearn函数中绘制一次。
答案 0 :(得分:0)
您的代码绘制所有正方形并翻转窗口。你得到了你正在编码的东西。也许您想要做的是绘制一次并将getKeys
置于定时循环中?例如,
drawLearn()
Wind.flip()
while True:
if Timer.getTime() >= startLearn and Timer.getTime() <= startLearn + timeLearn.
if len( event.getKeys(['q']) ) > 0:
break