like the title say's I do not know why my code hate's it when the screen is touched.
import pygame, time, keyboard
screen=pygame.display.set_mode((300, 300))
UpOrDown = 0
Y = 75
def backGround():
pygame.draw.rect(screen, (0,255,255), (0, 0, 300, 200))
pygame.draw.rect(screen, (0,255,0), (0, 200, 300, 100))
def ball():
pygame.draw.circle(screen, (255,0,0),
[150, Y], 30, 0)
while screen == True:
while keyboard.is_pressed('u'):
backGround()
ball()
pygame.display.flip()
time.sleep(.1)
print(Y)
if UpOrDown == 0:
Y += 10
if Y == 225:
UpOrDown = 1
elif UpOrDown == 1:
Y -= 10
if Y == 75:
UpOrDown = 0
Y = 225
UpOrDown = 1
ball()
If you could can you alter it or tell me why it doesn't work
Window crashing when it is opened