所以,我正在制作两个非常相似的游戏(确切的细节现在无关紧要。)
无论如何,我需要知道在哪里插入我的“pygame.time.wait”代码。
我需要的确切代码如下:
pygame.time.wait(100)
score = score + 1
目前,我的代码如下:
import sys, pygame
from pygame.locals import *
pygame.init()
size = width, height = 800,500
screen = pygame.display.set_mode(size)
pygame.display.set_caption("One Score (Created by - Not Really Working Lamp Productions:)")
WHITE = (255,255,255)
score = 0
screen.fill (WHITE)
myfont = pygame.font.SysFont("monospace", 16)
scoretext = myfont.render("Score = "+str(score), 1, (0,0,0))
screen.blit(scoretext, (5, 10))
disclaimertext = myfont.render("Copyright, 2013, Not Really Working Lamp Productions.", 1, (0,0,0))
screen.blit(disclaimertext, (5, 480))
while 1:
for event in pygame.event.get():
pygame.display.flip()
if event.type == pygame.QUIT:sys.exit()
问题是,我不知道在这段代码中我应该放置我的pygame.time.wait代码。有人能填补我吗? (我认为它出现在“while 1:”循环中,但我不知道在哪里。)
答案 0 :(得分:0)
下午好。你应该把你的'等待代码'放到FOR圈的主体中:
while 1:
for event in pygame.event.get():
pygame.display.flip()
if event.type == pygame.QUIT:sys.exit()
pygame.time.wait(100)
score = score + 1