我想要这样,玩家只有一个500-600毫秒的帧来输入1或2.我不知道该怎么做以及我发现的唯一定时器只有
time.sleep(1)
这是我的代码:
game = 1
while game == 1:
play = input(print("'display picture in other window' [1] for right [2] for wrong "))
if '1' in play:
print("You shot the Criminal! + 1 point")
point = point + 1
row = row + 1
if row == 3:
unlock2 = 1
print ("You gained 2 bonus points!")
point = point + 2
row = 0
if unlock2 == 1:
point = point + (point/2)
print ("You gained bonus points!")
elif '2' in play:
print("You shot an innocent! Game Over!")
break
game = 0
编辑:编辑编辑
答案 0 :(得分:0)
执行所需操作的最简单方法是衡量用户响应所需的时间,如下所示:
use Exception;
use Illuminate\Http\Request;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Exception\HttpResponseException;
use Symfony\Component\Debug\Exception\FlattenException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
用法:
import time
def respond_in_time(msg, s):
start = time.time()
response = input(msg)
end = time.time()
print(end-start)
if end - start > s:
return False
else:
return response