vendredi 17 janvier 2020

im in opygame trying to bouce a ball, but it gets stuck

import pygame

Red = 255, 0, 0
Black= 0,0,0
rectXpos = 2
rectypos = 2
speed = 2
screenedgex = 500

pygame.init()

window = pygame.display.set_mode(size=(500, 500))

clock = pygame.time.Clock()
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

        pygame.display.update()

        window.fill(Black)
        square = pygame.draw.rect(window, Red, [rectXpos, rectypos, 50, 50],2)
        rectXpos += 2

        if rectXpos < 500:
            rectXpos -= 2



        clock.tick(60)
        print(rectXpos)`enter code here`

so what am i doing wrong? i tried making a if statment to stop the ball and reverse it but it keeps the ball at the edge of the window

Aucun commentaire:

Enregistrer un commentaire