How to create gravity in Javascript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to create gravity in Javascript

I wanna create map with 2d object. But i need to know how to create gravity, styling objects and any other information.

9th Dec 2022, 4:30 PM
Samuel Hayden
Samuel Hayden - avatar
4 Answers
+ 2
Could you please explain? What kind of 2d object? What does a map need gravity for? What is "any other information"? Are yo referring to a canvas animation?
9th Dec 2022, 5:51 PM
Lisa
Lisa - avatar
+ 1
What kind of object? Do you use a particular library? It would be helpful if you could link an example code.
9th Dec 2022, 6:21 PM
Lisa
Lisa - avatar
+ 1
The basic idea of gravity in JavaScript is that the object moves down the y axis constantly. So, create a function that moves the object in this way.
9th Dec 2022, 9:09 PM
Ausgrindtube
Ausgrindtube - avatar
0
So Lisa . Listen me. I wanna create 2d object(cube). 4 button for controlling cube. And map with gravity. " I wanna create geometry dash". i know how create object but have a problem with gravity in map. Do you have information about gravity in games?
9th Dec 2022, 5:54 PM
Samuel Hayden
Samuel Hayden - avatar