I have two objects that I control with my keboard, one with WASD and the other with the arrows. (Imagine a 2D game)
I recently made the code to make them keep moving while the key is pressed but if I keep pressing W and up arrow at the same time only one works and the other one stops. I would like to know a fix.
This is the movement code:
if e.type == pygame.KEYDOWN:
if e.key==K_d:
PX += movimentenpx
EnergiaD +=energiapermoviment
if e.key==K_a:
PX -= movimentenpx
EnergiaD +=energiapermoviment
if e.key==K_w:
PY -= movimentenpx
EnergiaD +=energiapermoviment
if e.key==K_s:
PY += movimentenpx
EnergiaD +=energiapermoviment
if e.key ==K_UP:
PY2 -= movimentenpx
EnergiaD2 +=energiapermoviment
if e.key ==K_LEFT:
PX2 -= movimentenpx
EnergiaD2 +=energiapermoviment
if e.key ==K_DOWN:
PY2 += movimentenpx
EnergiaD2 +=energiapermoviment
if e.key ==K_RIGHT:
PX2 +=movimentenpx
EnergiaD2 +=energiapermoviment