+ 1

Animation help with game development with js

Why doesn't the square move? https://code.sololearn.com/WeJNaEGyv979/?ref=app

12th Jan 2022, 1:33 PM
Jalaj Madaan
Jalaj Madaan - avatar
10 Answers
+ 2
I've made the changes to it and it works.
12th Jan 2022, 1:48 PM
Jalaj Madaan
Jalaj Madaan - avatar
+ 1
Tysm! Moshe Schnitzler and AnonyMouse , what do you mean no reference? I made a canvas, gave it an id, used the id in the js section with the function and used setInterval to call it.
12th Jan 2022, 1:46 PM
Jalaj Madaan
Jalaj Madaan - avatar
+ 1
Jalaj Madaan it looks nice, well done!
12th Jan 2022, 1:53 PM
Moshe Schnitzler
Moshe Schnitzler - avatar
+ 1
Jalaj Madaan You’re welcome Happy coding!
12th Jan 2022, 6:37 PM
Moshe Schnitzler
Moshe Schnitzler - avatar
25th Jun 2023, 5:35 AM
Jalaj Madaan
Jalaj Madaan - avatar
0
The x and y variables should be declared outside the draw function. Everytime you call the function you redeclare x and y so its not being incremented
12th Jan 2022, 1:40 PM
Moshe Schnitzler
Moshe Schnitzler - avatar
0
I don't see any reference to the javascript anywhere in the html or css, the function draw never seems to be called
12th Jan 2022, 1:41 PM
AnonyMouse
AnonyMouse - avatar
0
Also, before you start drawing, clear the previous frame with context.clearRect(0, 0, 600, 400)
12th Jan 2022, 1:42 PM
Moshe Schnitzler
Moshe Schnitzler - avatar
0
Tysm for the help! I was confused with it, that helped me in another way to animate with js too!
12th Jan 2022, 3:19 PM
Jalaj Madaan
Jalaj Madaan - avatar
0
I can't find this course. Is It still available?
15th Jun 2023, 12:17 PM
Gentili Giuliano