i am trying to make a flappy bird movement that moves the rect forward and down at the same time but after implementing it. The rect on the pygame window doesnt appear and the window crashes. I tried it with a for and while statement but both gave the same result.
#whole code
import pygame
import random
from random import randint
import math
import time
pygame.init()
window = pygame.display.set_mode((600, 600))
clock = pygame.time.Clock()
# main application loop
run = True
while run:
# limit frames per second
clock.tick(100)
# event loop
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
# clear the display
window.fill(0)
x = 270
y = 270
speed = 5
key_input = pygame.key.get_pressed()
xr = random.randint(30, 270)
yr = random.randint(30, 270)
color1 = (255, 102, 255)
dead = False
while dead == False:
x + 2
y + 2
if key_input[pygame.K_UP]:
y - 2
main = pygame.draw.rect(window, color1, pygame.Rect(x, y, 30, 30))
# update the display
pygame.display.flip()
pygame.quit()
exit()
#code crashing the game
while dead == False:
x + 2
y + 2
if key_input[pygame.K_UP]:
y - 2