How to store an element's coordinates on a variable

I am making a game in javascript, and can’t get the characters to move when certain keys
are pressed. I know the problem- I made a variable that changes when each button is pressed, but never made anything to say when the variable changes the coordinates also change. My question is- how do you make the coordinates change when the variable changes?

You can change another variable for coordinates and change it whenever your characters move.

Thanks for replying.
I am also unclear on how to move the characters. How do you do this?

jQuery, use CSS transitions or animations in order to move an item.

If you are new to making a game in javascript, I recommend taking few courses or read tutorials.

https://www.w3schools.com/graphics/tryit.asp?filename=trygame_default_gravity

Thanks for all the help.

1 Like