I'm writing a program for school, but when I press a specific key to make my laser move across the screen, it disappears instantly. How can I make it move slowly, so the player can see it going from the left side to the right side of the screen ?
Here's the code (I wrote it again so I had only the part doing the laser moves)
#import pygame, time
from pygame_functions import*
pygame.init()
win = pygame.display.set_mode((1440, 480))
laserImg = pygame.image.load('laser.png')
backgroundImg = pygame.image.load('bg.jpg')
laserX = 90
laserY = 400
clock = pygame.time.Clock()
run = True
while run:
clock.tick(14)
win.blit(backgroundImg, (0, 0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
win.blit(laserImg, (laserX, laserY))
if event.type == pygame.KEYDOWN:
print("touche")
if keys[pygame.K_UP]:
while laserX < 1500:
laserX += 10
pygame.display.update()
pygame.quit
#
Thanks if you can help me
edit : idk why but there wasn't the line saying "while laserX < 1500"