# How does the velocity work

**URL:** <https://forum.makecode.com/t/how-does-the-velocity-work/33900>\
**Category:** Help\
**Created:** [February 16, 2025, 7:18pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900 "2025-02-16T19:18:05Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![babol](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/babol/32/27355_2.png) [@babol](https://forum.makecode.com/u/babol)\
**Post date:** [February 16, 2025, 7:18pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/1 "2025-02-16T19:18:05Z")

</div>

i really need to know this, because i’m porting one of my games to another engine. i’d highly appreciate an explainition on how it actually works.

---

<div class="post-metadata">

**Author:** ![CodeOnTheCob](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/codeonthecob/32/19306_2.png) [@CodeOnTheCob](https://forum.makecode.com/u/CodeOnTheCob)\
**Post date:** [February 18, 2025, 5:52pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/2 "2025-02-18T17:52:18Z")

</div>

it instantly changes it constant speed to something acceleration increases the speed friction slow it down to zero velocity in both directions

---

<div class="post-metadata">

**Author:** ![babol](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/babol/32/27355_2.png) [@babol](https://forum.makecode.com/u/babol)\
**Post date:** [February 18, 2025, 11:49pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/3 "2025-02-18T23:49:09Z")

</div>

i know THAT part, i mean like how many pixels it moves the sprite each frame and why it just goes turbo mode whenever the FPS slows down and all that weird stuff that shouldnt happen  
vx = 1 is not equal to 1 pixel on the x axis per frame, its weird.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [February 18, 2025, 11:51pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/4 "2025-02-18T23:51:34Z")

</div>

@babol the velocity is in pixels per second, not pixels per frame. similarly, acceleration is in pixels per second squared

all the physics are adjusted for the amount of time that has passed since the previous frame. e.g., if a frame takes three times as long to render, the physics will move the sprite by three times the distance

---

<div class="post-metadata">

**Author:** ![babol](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/babol/32/27355_2.png) [@babol](https://forum.makecode.com/u/babol)\
**Post date:** [February 19, 2025, 6:36pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/5 "2025-02-19T18:36:52Z")

</div>

well, what was the reason for it to be pixels per second and not pixels per frame?  
(and, could you guys add a pixels per frame velocity system? maybe a toggle between the 2 for sprites)

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [February 19, 2025, 10:28pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/6 "2025-02-19T22:28:52Z")

</div>

@babol this is what most modern game engines do; it makes it so that gameplay seems natural even with a variable frame rate. otherwise, your game might run faster on a faster computer.

---

<div class="post-metadata">

**Author:** ![babol](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/babol/32/27355_2.png) [@babol](https://forum.makecode.com/u/babol)\
**Post date:** [February 20, 2025, 6:26pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/7 "2025-02-20T18:26:41Z")

</div>

but wouldnt it make more sense to add the other one, considering makecode arcade is meant to recreate the arcade game feel? and what about the request? it would really help me out with some projects.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [February 20, 2025, 6:44pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/8 "2025-02-20T18:44:50Z")

</div>

i think this is probably too niche a feature for us to add. that being said, you can sorta force this behavior if you add some js that looks like this to your project:

```ts
const LOCKED_FPS = 30;
game.currentScene().eventContext.registerFrameHandler(-1, () => {
    game.currentScene().eventContext.deltaTimeMillis = Math.idiv(1000, LOCKED_FPS);
});

```

this will lock the game physics to the frame rate by setting a constant time between frames. it won’t make it so that a velocity of 1 equals 1 pixel per frame, though. you might be tempted to change the LOCKED\_FPS variable to 1 to get that behavior, but it won’t work because our physics engine has a maximum time step it supports and it’s less than one second.

working in pixels per frame would be awkward anyway. do you really want to give a sprite a velocity of 0.5?

---

<div class="post-metadata">

**Author:** ![babol](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/babol/32/27355_2.png) [@babol](https://forum.makecode.com/u/babol)\
**Post date:** [February 21, 2025, 7:39pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/9 "2025-02-21T19:39:17Z")

</div>

> working in pixels per frame would be awkward anyway

i personally have to disagree with that since i’ve worked with pixels per frame is what i’ve worked with my entire life and it just works better considering the fact that its actually consistent and doesnt make you wanna tear your lips off when trying to port games (i recall spending hours trying to get the movement to be accurate when porting a game of mine to GMS2 by finding a multiplier, unaware that its not pixels per frame but pixels per second)

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [February 23, 2025, 5:53am UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/10 "2025-02-23T05:53:11Z")

</div>

Why can’t you just move the character a certain amount every frame?  
Let MyVelX = 1  
On game update, change mySprite [position x] by (MyVelX)

This really isn’t that hard to do. Velocity is just increasing VelocityX by some amount every frame, etc, etc

---

<div class="post-metadata">

**Author:** ![babol](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/babol/32/27355_2.png) [@babol](https://forum.makecode.com/u/babol)\
**Post date:** [February 24, 2025, 5:39am UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/11 "2025-02-24T05:39:07Z")

</div>

well what about collision?

---

<div class="post-metadata">

**Author:** ![not\_a\_lemon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/not_a_lemon/32/35289_2.png) [@not\_a\_lemon](https://forum.makecode.com/u/not_a_lemon)\
**Post date:** [April 26, 2026, 1:16am UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/12 "2026-04-26T01:16:34Z")

</div>

> [@richard](#):
>
> acceleration is in pixels per second squared

How does this work exactly? is it the pixels squared or the seconds squared, and if seconds, seconds since what? Could you provide an equation for this or something?

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [April 26, 2026, 1:20am UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/13 "2026-04-26T01:20:48Z")

</div>

It’s the standard acceleration equation. Speed is how quickly something moves through space-time, and acceleration is how quickly speed changes.

Position = (x, y)  
Speed = (change in x, change in y) / second  
Acceleration = (change in x-speed, change in y-speed) / second  
So,  
Acceleration = ((change in x / second) / second, (change in y / second) / second)  
And  
Acceleration = (change in x / second 2, change in y / second 2)

---

<div class="post-metadata">

**Author:** ![babol](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/babol/32/27355_2.png) [@babol](https://forum.makecode.com/u/babol)\
**Post date:** [April 27, 2026, 5:07pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/14 "2026-04-27T17:07:05Z")

</div>

i know that. i was asking how the velocity system in makecode arcade worked, because for some reason 1 x velocity did not move the sprite 1 pixel to the right each frame, and it was too inconsistent for me to set a constant to compare the velocity values to.

---

<div class="post-metadata">

**Author:** ![not\_a\_lemon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/not_a_lemon/32/35289_2.png) [@not\_a\_lemon](https://forum.makecode.com/u/not_a_lemon)\
**Post date:** [April 27, 2026, 5:23pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/15 "2026-04-27T17:23:07Z")

</div>

So if I set ay to 500 it will change the velocity 500 times per second? Or does it multiply it by 500 or something?

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [April 27, 2026, 5:56pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/16 "2026-04-27T17:56:12Z")

</div>

A velocity of 1 is not one pixel per frame. It’s one pixel per second.

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [April 27, 2026, 5:59pm UTC](https://forum.makecode.com/t/how-does-the-velocity-work/33900/17 "2026-04-27T17:59:42Z")

</div>

If you set `ay` to 500 then, in one second, the sprite’s vertical velocity will be 500 times greater. The change doesn’t happen all at once — it’s not like the sprite’s velocity suddenly changes each second.
