0

Please i want to move the rectangle left and right , using those buttons

Canvas JavaScript https://code.sololearn.com/W8zuiKrl7N13/?ref=app

24th Jun 2022, 7:40 PM
Patrick agbenyo paul
Patrick agbenyo paul - avatar
5 Answers
+ 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.
25th Jun 2022, 3:04 AM
Emerson Prado
Emerson Prado - avatar
+ 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.
25th Jun 2022, 6:10 PM
Emerson Prado
Emerson Prado - avatar
25th Jun 2022, 4:37 PM
Patrick agbenyo paul
Patrick agbenyo paul - avatar
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 !
25th Jun 2022, 6:04 PM
Abhay
Abhay - avatar
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
25th Jun 2022, 8:42 PM
Patrick agbenyo paul
Patrick agbenyo paul - avatar