#๐Ÿ”’ Falppybird pipe rect

9 messages ยท Page 1 of 1 (latest)

granite wadiBOT
#

@shell oriole

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

shell oriole
#

here is the full code

#
import random
import time

pygame.init()
WIDTH, HEIGHT = 1000, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
timer = pygame.time.Clock()
pygame.display.set_caption("Flappy Square")

fps = 60
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 255, 0)
Blue = (0, 0, 255)
Lightblue = (173, 216, 230)

jumppower = -10
gravity = 0.4


class Bird:
    def __init__(self):
        self.x = 10
        self.y = HEIGHT/2
        self.velocity = 0
        self.rect = pygame.Rect(self.x, self.y, 40, 40)
    def jump(self):
        self.velocity = 0 + jumppower
    def update(self):
        self.velocity += gravity
        self.y += self.velocity
        self.rect.y = self.y
        print(self.y)
        print(self.velocity)
class Pipe:
    def __init__(self):
        self.x = 500
        self.gap_start = random.randint(50, 300)
        #self.rect.top = pygame.Rect(self.x, 0, 50, self.gap_start)

bird = Bird()
pipes = Pipe()

running = True
# startscreen = False
# while startscreen:
#     screen.fill((Lightblue))
#     timer.tick(fps)
#     for event in pygame.event.get():
#         if event.type == pygame.QUIT:
#             pygame.quit()
#             if event.type == pygame.KEYDOWN:
#                 if event.key == pygame.K_SPACE:
#                     startscreen = False
#                     running = True
#                     pygame.quit()
#
#     pygame.draw.rect(screen, Blue, bird.rect)
#     pygame.display.update()

while running:
    screen.fill(Lightblue)
    timer.tick(fps)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_SPACE:
                bird.jump()

    pygame.draw.rect(screen, Blue, bird.rect)
    pygame.draw.rect(screen, GREEN, pipes.rect.top)

    bird.update()
    pygame.display.update()


pygame.quit()
#

Falppybird need help

granite wadiBOT
#

@shell oriole

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Falppybird need help

granite wadiBOT
#

@shell oriole

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.