I wanted to make a kind of "fill the box" style game where you hold down to increase size of a ball that falls when you let go, end goal being covering a percentage of the screen.

Anyway, I wanted to attempt to make the engine myself for learning purposes (fiddle). However, using 9.8 as a global acceleration makes it feel like really low gravity.

So far, all of my movement is done via the function below. I feel like I'm missing something obvious, but just can't figure out why it seems more like moon gravity than Earth.

dt = new Date().getTime();
dt = (dt - lastFrame) / 1000;
for (var c in circles) {
  circles[c].v.y += acceleration * dt;

  if (circles[c].x + circles[c].v.x * dt > canvs.width || circles[c].x + circles[c].v.x * dt < 0) {
    circles[c].v.x *= -1;
  if (circles[c].y + circles[c].v.y * dt > canvs.height || circles[c].y + circles[c].v.y * dt < 0) {
    circles[c].v.y *= -1;

  circles[c].x += circles[c].v.x * dt;
  circles[c].y += circles[c].v.y * dt;
lastFrame = new Date().getTime();
  • 5
    \$\begingroup\$ The behaviour is dependent on units. I guess you are using pixels as your unit, 9.81 pixels/s² is really slow (Think of every pixel as a meter, now imagine watching something falling > 400 m from far away. Takes some time). You either have to define a coordinate system (x pixels per meter) or tweak the gravity value directly. \$\endgroup\$
    – LukeG
    Commented Jul 18, 2016 at 20:31
  • \$\begingroup\$ @LukeG I knew it was something obvious! Makes much more sense now. \$\endgroup\$ Commented Jul 18, 2016 at 20:32
  • \$\begingroup\$ I'll post an answer about this \$\endgroup\$
    – LukeG
    Commented Jul 18, 2016 at 20:33

1 Answer 1


As noted in a comment above, this is about units. If you use the value 9.81 as pixels/s² it's like watching something fall hundreds of meter when the ball shall cross the entire screen. It takes 9 seconds for something to fall 400 meters with v0 = 0, neglecting air resistance. It should be clear why this appears moon-like. It's all a matter of scale.

To solve this for your game you have to define a coordinate system yourself (How many pixels match 1 meter?) or just tweak your value up a bit. This gets more complicated if you want to allow the player to zoom in or out, as the coordinate system changes when doing this.

Sidenote: If you use a graphics API (Direct3D or OpenGL) this adjustment is more or less automatically done for you if your Matrix library supports direct creation of world-, view-, and projection-matrices.

  • 3
    \$\begingroup\$ Want to point out that this turns out to be a big issue for a lot of games. e.g., a game about giant Gundam mechs will have a huge character scale and so realistic physics constants will make everything feel "floaty" - as it should. But for gameplay purposes this is often not what was desired, so games might set the physics constants differently to make characters feel more human-like (matching our expectations) but then all the props/scenery looks toy-like when it gets broken (just like in old movies with giant monsters being guys in costumes smashing tiny models). \$\endgroup\$ Commented Jul 18, 2016 at 20:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .