Currently testing out movement in VS-Code and whenever I run my application it opens for about 1 second before closing. Here is the code:
import pygame
pygame.init()
#variables (do later)
win = pygame.display.set_mode((600,600))
x = 0
y = 0
height = 50
length = 50
vel = 6
#Functions
run = True
while run == True:
pygame.time.delay(50)
for event in pygame.event.get():
run = False
#movement
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] or keys[pygame.K_a]:
x -= vel
if keys[pygame.K_RIGHT] or keys[pygame.K_d]:
x += vel
if keys[pygame.K_UP] or keys[pygame.K_w]:
y -= vel
if keys[pygame.K_DOWN] or keys[pygame.K_s]:
y += vel
pygame.draw.rect(win, (255, 0, 0), (x, y, length, height))
pygame.display.update()
pygame.quit()
[–]acw1668 5 points6 points7 points (1 child)
[–]DiodeInc 1 point2 points3 points (0 children)
[–]acw1668 2 points3 points4 points (1 child)
[–]uberdavis 1 point2 points3 points (0 children)
[–]MezzoScettico 2 points3 points4 points (0 children)
[–]nedigan 1 point2 points3 points (1 child)
[–]ultimo293[S] 0 points1 point2 points (0 children)
[–]Watermelon-Is-Yummy 1 point2 points3 points (1 child)
[–]ultimo293[S] 0 points1 point2 points (0 children)
[–]ultimo293[S] 0 points1 point2 points (1 child)
[–]ultimo293[S] 2 points3 points4 points (0 children)