0

So i'm trying to recreate the Flappy Fall game for iOS and I'm having trouble making one circle disappear and another show up. Right now I have this as the main loop.

    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)

I don't know where it's going wrong because the "basket" is showing up just fine.

rmaddy
  • 314,917
  • 42
  • 532
  • 579

2 Answers2

0

Try

print x,y

right before you draw the circle to check your values. It looks like your y value is negative and I believe* you need positive coordinate to draw on the canvas.

Edit: Confirmed, I got your code working by changing y=-7 to y=300, a little blue ball went up the screen. Also, it may be unrelated but I had to edit the font line to read:

 show=font.render(str(score),1,RED)#,None)

but I think that has more to do with my version of python and pygame than anything else.

town_math
  • 61
  • 4
0

On line 12, you only have y = -7 maybe you also want to include the x = rand(50, 50-w) line just before it so that you have an x and a y position instead of just the y position.

x = rand(50, 50-w)

y = -7

sshashank124
  • 31,495
  • 9
  • 67
  • 76