My character won't go down. Flappy Bird Clone [closed]












-3














My character won't go downwards. I don't know what to do. My Character will only do up and not down. I've tried many things but I can't seem to figure out what to do. I'm new to Python so if this is something obvious, then sorry.



import pygame

black = pygame.Color("#000000")
white = pygame.Color("#FFFFFF")
blue = pygame.Color("#7ec0ee")

pygame.init()

size = 1024,768
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Flappy Bird v.1b")

done = False
clock = pygame.time.Clock()

def ball(x,y):
pygame.draw.circle(screen,black,[x,y], 20)

def gameover():
text = render("Game Over!", True, black)
screen.blit(text, [150, 250])


x = 350
y = 250
x_speed = 0
y_speed = 0
ground = 480

while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
y_speed = -10

if event.type == pygame.KEYUP:
if event.key == pygame.K_UP:
y_speed = 5

screen.fill(blue)
ball(x,y)

y += y_speed

if y > ground:
gameover()
y_speed = 0

pygame.display.flip()
clock.tick(60)

pygame.quit()









share|improve this question















closed as off-topic by eyllanesc, Robert Columbia, user6655984, sideshowbarker, Machavity Nov 12 at 3:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – eyllanesc, Community, sideshowbarker, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Look at your pygame.KEYDOWN check - it has pygame.K_UP as its event.key check...
    – Jon Clements
    Nov 12 at 0:15












  • @Jon that appears intentional.
    – sam-pyt
    Nov 12 at 0:22










  • Doesn't work, I've already tried that. Do you think it may have something to do with my computer? It seems to work for my friend who has a similar code.
    – Orang O' Man
    Nov 12 at 0:22












  • @sam-pyt yeah... sorry... tired eyes... thanks for the nudge
    – Jon Clements
    Nov 12 at 0:23








  • 2




    this seems to be some type of indentation problem. I put this in a file and fixed the indentation and it works as expected. ah yes, see your check for pygame.KEYUP events is nested inside the conditional for pygame.KEYDOWN.
    – sam-pyt
    Nov 12 at 0:23


















-3














My character won't go downwards. I don't know what to do. My Character will only do up and not down. I've tried many things but I can't seem to figure out what to do. I'm new to Python so if this is something obvious, then sorry.



import pygame

black = pygame.Color("#000000")
white = pygame.Color("#FFFFFF")
blue = pygame.Color("#7ec0ee")

pygame.init()

size = 1024,768
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Flappy Bird v.1b")

done = False
clock = pygame.time.Clock()

def ball(x,y):
pygame.draw.circle(screen,black,[x,y], 20)

def gameover():
text = render("Game Over!", True, black)
screen.blit(text, [150, 250])


x = 350
y = 250
x_speed = 0
y_speed = 0
ground = 480

while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
y_speed = -10

if event.type == pygame.KEYUP:
if event.key == pygame.K_UP:
y_speed = 5

screen.fill(blue)
ball(x,y)

y += y_speed

if y > ground:
gameover()
y_speed = 0

pygame.display.flip()
clock.tick(60)

pygame.quit()









share|improve this question















closed as off-topic by eyllanesc, Robert Columbia, user6655984, sideshowbarker, Machavity Nov 12 at 3:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – eyllanesc, Community, sideshowbarker, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Look at your pygame.KEYDOWN check - it has pygame.K_UP as its event.key check...
    – Jon Clements
    Nov 12 at 0:15












  • @Jon that appears intentional.
    – sam-pyt
    Nov 12 at 0:22










  • Doesn't work, I've already tried that. Do you think it may have something to do with my computer? It seems to work for my friend who has a similar code.
    – Orang O' Man
    Nov 12 at 0:22












  • @sam-pyt yeah... sorry... tired eyes... thanks for the nudge
    – Jon Clements
    Nov 12 at 0:23








  • 2




    this seems to be some type of indentation problem. I put this in a file and fixed the indentation and it works as expected. ah yes, see your check for pygame.KEYUP events is nested inside the conditional for pygame.KEYDOWN.
    – sam-pyt
    Nov 12 at 0:23
















-3












-3








-3







My character won't go downwards. I don't know what to do. My Character will only do up and not down. I've tried many things but I can't seem to figure out what to do. I'm new to Python so if this is something obvious, then sorry.



import pygame

black = pygame.Color("#000000")
white = pygame.Color("#FFFFFF")
blue = pygame.Color("#7ec0ee")

pygame.init()

size = 1024,768
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Flappy Bird v.1b")

done = False
clock = pygame.time.Clock()

def ball(x,y):
pygame.draw.circle(screen,black,[x,y], 20)

def gameover():
text = render("Game Over!", True, black)
screen.blit(text, [150, 250])


x = 350
y = 250
x_speed = 0
y_speed = 0
ground = 480

while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
y_speed = -10

if event.type == pygame.KEYUP:
if event.key == pygame.K_UP:
y_speed = 5

screen.fill(blue)
ball(x,y)

y += y_speed

if y > ground:
gameover()
y_speed = 0

pygame.display.flip()
clock.tick(60)

pygame.quit()









share|improve this question















My character won't go downwards. I don't know what to do. My Character will only do up and not down. I've tried many things but I can't seem to figure out what to do. I'm new to Python so if this is something obvious, then sorry.



import pygame

black = pygame.Color("#000000")
white = pygame.Color("#FFFFFF")
blue = pygame.Color("#7ec0ee")

pygame.init()

size = 1024,768
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Flappy Bird v.1b")

done = False
clock = pygame.time.Clock()

def ball(x,y):
pygame.draw.circle(screen,black,[x,y], 20)

def gameover():
text = render("Game Over!", True, black)
screen.blit(text, [150, 250])


x = 350
y = 250
x_speed = 0
y_speed = 0
ground = 480

while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
y_speed = -10

if event.type == pygame.KEYUP:
if event.key == pygame.K_UP:
y_speed = 5

screen.fill(blue)
ball(x,y)

y += y_speed

if y > ground:
gameover()
y_speed = 0

pygame.display.flip()
clock.tick(60)

pygame.quit()






python python-2.7 pygame






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 0:24









eyllanesc

72.5k93054




72.5k93054










asked Nov 12 at 0:13









Orang O' Man

73




73




closed as off-topic by eyllanesc, Robert Columbia, user6655984, sideshowbarker, Machavity Nov 12 at 3:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – eyllanesc, Community, sideshowbarker, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by eyllanesc, Robert Columbia, user6655984, sideshowbarker, Machavity Nov 12 at 3:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – eyllanesc, Community, sideshowbarker, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.












  • Look at your pygame.KEYDOWN check - it has pygame.K_UP as its event.key check...
    – Jon Clements
    Nov 12 at 0:15












  • @Jon that appears intentional.
    – sam-pyt
    Nov 12 at 0:22










  • Doesn't work, I've already tried that. Do you think it may have something to do with my computer? It seems to work for my friend who has a similar code.
    – Orang O' Man
    Nov 12 at 0:22












  • @sam-pyt yeah... sorry... tired eyes... thanks for the nudge
    – Jon Clements
    Nov 12 at 0:23








  • 2




    this seems to be some type of indentation problem. I put this in a file and fixed the indentation and it works as expected. ah yes, see your check for pygame.KEYUP events is nested inside the conditional for pygame.KEYDOWN.
    – sam-pyt
    Nov 12 at 0:23




















  • Look at your pygame.KEYDOWN check - it has pygame.K_UP as its event.key check...
    – Jon Clements
    Nov 12 at 0:15












  • @Jon that appears intentional.
    – sam-pyt
    Nov 12 at 0:22










  • Doesn't work, I've already tried that. Do you think it may have something to do with my computer? It seems to work for my friend who has a similar code.
    – Orang O' Man
    Nov 12 at 0:22












  • @sam-pyt yeah... sorry... tired eyes... thanks for the nudge
    – Jon Clements
    Nov 12 at 0:23








  • 2




    this seems to be some type of indentation problem. I put this in a file and fixed the indentation and it works as expected. ah yes, see your check for pygame.KEYUP events is nested inside the conditional for pygame.KEYDOWN.
    – sam-pyt
    Nov 12 at 0:23


















Look at your pygame.KEYDOWN check - it has pygame.K_UP as its event.key check...
– Jon Clements
Nov 12 at 0:15






Look at your pygame.KEYDOWN check - it has pygame.K_UP as its event.key check...
– Jon Clements
Nov 12 at 0:15














@Jon that appears intentional.
– sam-pyt
Nov 12 at 0:22




@Jon that appears intentional.
– sam-pyt
Nov 12 at 0:22












Doesn't work, I've already tried that. Do you think it may have something to do with my computer? It seems to work for my friend who has a similar code.
– Orang O' Man
Nov 12 at 0:22






Doesn't work, I've already tried that. Do you think it may have something to do with my computer? It seems to work for my friend who has a similar code.
– Orang O' Man
Nov 12 at 0:22














@sam-pyt yeah... sorry... tired eyes... thanks for the nudge
– Jon Clements
Nov 12 at 0:23






@sam-pyt yeah... sorry... tired eyes... thanks for the nudge
– Jon Clements
Nov 12 at 0:23






2




2




this seems to be some type of indentation problem. I put this in a file and fixed the indentation and it works as expected. ah yes, see your check for pygame.KEYUP events is nested inside the conditional for pygame.KEYDOWN.
– sam-pyt
Nov 12 at 0:23






this seems to be some type of indentation problem. I put this in a file and fixed the indentation and it works as expected. ah yes, see your check for pygame.KEYUP events is nested inside the conditional for pygame.KEYDOWN.
– sam-pyt
Nov 12 at 0:23














1 Answer
1






active

oldest

votes


















0














Like what @sam-pyt said, it seems to be an indentation problem. I fixed the spacing inconsistencies and it worked on my end. The following is the code that worked for me.



import pygame

black = pygame.Color("#000000")
white = pygame.Color("#FFFFFF")
blue = pygame.Color("#7ec0ee")

pygame.init()

size = 1024,768
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Flappy Bird v.1b")

done = False
clock = pygame.time.Clock()

def ball(x,y):
pygame.draw.circle(screen,black,[x,y], 20)

def gameover():
text = render("Game Over!", True, black)
screen.blit(text, [150, 250])


x = 350
y = 250
x_speed = 0
y_speed = 0
ground = 480

while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
y_speed = -10

if event.type == pygame.KEYUP:
if event.key == pygame.K_UP:
y_speed = 5

screen.fill(blue)
ball(x,y)

y += y_speed

if y > ground:
gameover()
y_speed = 0

pygame.display.flip()
clock.tick(60)

pygame.quit()





share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Like what @sam-pyt said, it seems to be an indentation problem. I fixed the spacing inconsistencies and it worked on my end. The following is the code that worked for me.



    import pygame

    black = pygame.Color("#000000")
    white = pygame.Color("#FFFFFF")
    blue = pygame.Color("#7ec0ee")

    pygame.init()

    size = 1024,768
    screen = pygame.display.set_mode(size)
    pygame.display.set_caption("Flappy Bird v.1b")

    done = False
    clock = pygame.time.Clock()

    def ball(x,y):
    pygame.draw.circle(screen,black,[x,y], 20)

    def gameover():
    text = render("Game Over!", True, black)
    screen.blit(text, [150, 250])


    x = 350
    y = 250
    x_speed = 0
    y_speed = 0
    ground = 480

    while not done:
    for event in pygame.event.get():
    if event.type == pygame.QUIT:
    done = True

    if event.type == pygame.KEYDOWN:
    if event.key == pygame.K_UP:
    y_speed = -10

    if event.type == pygame.KEYUP:
    if event.key == pygame.K_UP:
    y_speed = 5

    screen.fill(blue)
    ball(x,y)

    y += y_speed

    if y > ground:
    gameover()
    y_speed = 0

    pygame.display.flip()
    clock.tick(60)

    pygame.quit()





    share|improve this answer


























      0














      Like what @sam-pyt said, it seems to be an indentation problem. I fixed the spacing inconsistencies and it worked on my end. The following is the code that worked for me.



      import pygame

      black = pygame.Color("#000000")
      white = pygame.Color("#FFFFFF")
      blue = pygame.Color("#7ec0ee")

      pygame.init()

      size = 1024,768
      screen = pygame.display.set_mode(size)
      pygame.display.set_caption("Flappy Bird v.1b")

      done = False
      clock = pygame.time.Clock()

      def ball(x,y):
      pygame.draw.circle(screen,black,[x,y], 20)

      def gameover():
      text = render("Game Over!", True, black)
      screen.blit(text, [150, 250])


      x = 350
      y = 250
      x_speed = 0
      y_speed = 0
      ground = 480

      while not done:
      for event in pygame.event.get():
      if event.type == pygame.QUIT:
      done = True

      if event.type == pygame.KEYDOWN:
      if event.key == pygame.K_UP:
      y_speed = -10

      if event.type == pygame.KEYUP:
      if event.key == pygame.K_UP:
      y_speed = 5

      screen.fill(blue)
      ball(x,y)

      y += y_speed

      if y > ground:
      gameover()
      y_speed = 0

      pygame.display.flip()
      clock.tick(60)

      pygame.quit()





      share|improve this answer
























        0












        0








        0






        Like what @sam-pyt said, it seems to be an indentation problem. I fixed the spacing inconsistencies and it worked on my end. The following is the code that worked for me.



        import pygame

        black = pygame.Color("#000000")
        white = pygame.Color("#FFFFFF")
        blue = pygame.Color("#7ec0ee")

        pygame.init()

        size = 1024,768
        screen = pygame.display.set_mode(size)
        pygame.display.set_caption("Flappy Bird v.1b")

        done = False
        clock = pygame.time.Clock()

        def ball(x,y):
        pygame.draw.circle(screen,black,[x,y], 20)

        def gameover():
        text = render("Game Over!", True, black)
        screen.blit(text, [150, 250])


        x = 350
        y = 250
        x_speed = 0
        y_speed = 0
        ground = 480

        while not done:
        for event in pygame.event.get():
        if event.type == pygame.QUIT:
        done = True

        if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_UP:
        y_speed = -10

        if event.type == pygame.KEYUP:
        if event.key == pygame.K_UP:
        y_speed = 5

        screen.fill(blue)
        ball(x,y)

        y += y_speed

        if y > ground:
        gameover()
        y_speed = 0

        pygame.display.flip()
        clock.tick(60)

        pygame.quit()





        share|improve this answer












        Like what @sam-pyt said, it seems to be an indentation problem. I fixed the spacing inconsistencies and it worked on my end. The following is the code that worked for me.



        import pygame

        black = pygame.Color("#000000")
        white = pygame.Color("#FFFFFF")
        blue = pygame.Color("#7ec0ee")

        pygame.init()

        size = 1024,768
        screen = pygame.display.set_mode(size)
        pygame.display.set_caption("Flappy Bird v.1b")

        done = False
        clock = pygame.time.Clock()

        def ball(x,y):
        pygame.draw.circle(screen,black,[x,y], 20)

        def gameover():
        text = render("Game Over!", True, black)
        screen.blit(text, [150, 250])


        x = 350
        y = 250
        x_speed = 0
        y_speed = 0
        ground = 480

        while not done:
        for event in pygame.event.get():
        if event.type == pygame.QUIT:
        done = True

        if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_UP:
        y_speed = -10

        if event.type == pygame.KEYUP:
        if event.key == pygame.K_UP:
        y_speed = 5

        screen.fill(blue)
        ball(x,y)

        y += y_speed

        if y > ground:
        gameover()
        y_speed = 0

        pygame.display.flip()
        clock.tick(60)

        pygame.quit()






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 0:48









        boonwj

        2169




        2169















            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma