0
Please i want to move the rectangle left and right , using those buttons
Canvas JavaScript https://code.sololearn.com/W8zuiKrl7N13/?ref=app
5 Respuestas
+ 2
Pls edit your question and include in its description a link to your code in Code Playground. We need to know what to help you on.
+ 1
Some hints:
Make your life easier by proper use of files - tabs, in Code Playground - and functions. Put all JavaScript in the JavaScript tab, and leave HTML only for HTML. Also, you initialize variables, move and draw in the same function. Have functions do less and do better.
Better use of files and functions is a little effort which pays off a lot. This mix is big part of what got you lost.
There also seems to be some confusion on the roles of x and y. Have it 100% clear in your mind which one goes vertical or horizontal.
0
Patrick agbenyo paul are you trying to move it up and down or left and right ? Rn it looks like the direction is downwards !
0
Thanks I refactor the code knowing the vertical and horizontal position. How do I change the value of x so that when the left button is clicked on the rectangle moves to the opposite direction..sorry for disturbing your soul