0
Gravity in javascript game
Hello, Does anybody know how I can add gravity in my game by using handleMove?
4 Réponses
+ 3
//You can use JavaScript libraries for that
//matter.js
https://brm.io/matter-js/
//physics.js
http://wellcaffeinated.net/PhysicsJS/
//without using libraries, reference code
https://code.sololearn.com/We2wI3xFuT9b/?ref=app
+ 2
you'll can add constant downforce for your entity for basic gravity.
const downforce = 10;
function jump(entity){
entity.down = downforce - 10;
}
and treat them as a acceleration, not velocity or exact Y location.
+ 2
A yt vid to add gravity
https://youtu.be/3b7FyIxWW94
0
by using gravity u need to be precise more importantly on the programming language that your using each coding language has their effect depending the language your using try Html i believer it will be easier, for me i use html and javascript..................