I'd like to make a program so that bullets can be fired when I press the x key. I made my own code. I want one bullet to fly when I press it, not when I press it hard. When you press the x key, the bullet should fly naturally, but the position suddenly changes and you teleport. please help me. here is my code
while True:
clock.tick(100)
pressed = pygame.key.get_pressed()
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if pressed[pygame.K_LEFT] or pressed[pygame.K_RIGHT]:
last_direction_key = event.key
if pressed[pygame.K_DOWN] or pressed[pygame.K_UP]:
last_key = event.key
if pressed[pygame.K_x]:
bullet_x += 10
Bullet_x is the horizontal position variable of the bullet. How can I make it fly away naturally?