所以我正在尝试为 iOS 重新创建Flappy Fall游戏,但我无法让一个圆圈消失而另一个圆圈出现。现在我把它作为主循环。
while True:
if newBall==True:
x=rand(50,w-50)
y=-7
newBall=False
if x in range(xBasket-length,xBasket+length) and y in range(yBasket-int(length/2),yBasket+int(length/2)): #If the circle hit's the basket
newBall=True #Creates a new ball
score+=1
elif x in range(0,w) and y in range(700,751): #If it hits the ground
break
if newBall==False: #If there is no new ball yet
y-=7
win.fill(BLACK)
font=pygame.font.Font(None,48)
show=font.render(str(score),1,RED,None)
win.blit(show,(200,150))
pygame.draw.rect(win,RED,(0,700,w,h),0) #ground
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
if event.type==KEYDOWN:
if event.key==K_LEFT and xBasket-length!=0:
xBasket-=5
if event.key==K_RIGHT and xBasket+length!=w:
xBasket+=5
pygame.draw.circle(win,BLUE,(x,y),7) #ball that falls
pygame.draw.polygon(win,WHITE,((xBasket-length,yBasket-int(length/2)),(xBasket+length,yBasket-int(length/2)),(xBasket+length,yBasket+int(length/2)),(xBasket-length,yBasket+int(length/2)),0)) #basket
pygame.display.update()
time.delay(5)
s(0.001)
我不知道哪里出了问题,因为“篮子”显示得很好。