0

だから私は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)

「バスケット」がうまく表示されているため、どこが間違っているのかわかりません。

4

2 に答える 2

0

12 行目では、y = -7 しかありません。おそらく、その直前に x = rand(50, 50-w) 行を含めて、位置だけでなくx、位置を持たせたいと思うかもしれません。yy

x = rand(50, 50-w)

y = -7

于 2014-03-16T08:46:31.633 に答える