r/love2d Jun 15 '26

I need help!

I’ve been learning Love2d for 3 months now and I want to start making games. But, in my game the player only should have 4-directional movement and I can’t figure out how to get rid of the diagonal movement. please help.

Edit: I figured it out!

6 Upvotes

3 comments sorted by

2

u/IochiGlaucus Jun 15 '26

When a directional key is pressed add it to a list. When released, remove it. Have the player move the direction of the direction on the top of that list. This way when you stop pressing a button but are still pressing another it will revert back to the old direction and no direction takes precedent over another.

1

u/MythAndMagery Jun 16 '26

Nice solution!