提前谢谢您的时间.
如果我使用空格键发射子弹,则会创建一连串子弹.如果我在'if keys [pygame.K_SPACE]:'里面设置time.sleep()的延迟,那么它也会将循环冻结设定的秒数.我怎么能这样做,所以一次只发射一颗子弹?这是我的游戏循环的副本,请告诉我是否需要更多代码:
def game_loop():
global pause
x = (display_width * 0.2)
y = (display_height * 0.2)
x_change = 0
y_change = 0
blob_speed = 3
velocity = [2, 2]
pos_x = display_width/1.2
pos_y = display_height/1.2
gameExit = False
while not gameExit:
for event in pygame.event.get():#monitors hardware movement/ clicks
if event.type == pygame.QUIT:
pygame.quit()
quit()
pos_x += velocity[0]
pos_y += velocity[1]
if pos_x + blob_width > display_width or pos_x < 601:
velocity[0] = -velocity[0]
if pos_y + blob_height > …Run Code Online (Sandbox Code Playgroud)