Log In  
Follow
Thiskul

huge nerd

all pronouns

:: Unfold ::

Cart #jegurokug-1 | 2022-10-22 | Code ▽ | Embed ▽ | No License

Hello, im wondering why the velocity and acceleration (vx and va) dont go to zero when you go left then let go.
Also note that the maximums are different.

Controls:
Left -- go left
Right -- go right
X -- force vx and va values to zero

is this just a quirk with pico-8?

Thanks :)

Code:

function _init()
x=0
vx=0
ax=0
end

function _update60()
    if btn(➡️) then
        ax+=.01
    end
    if btn(⬅️) then
        ax-=.01
    end
    if btn(❎) then
        ax=0
        vx=0
    end

    vx+=ax
    x+=vx

    vx*=.9
    ax*=.9
end

function _draw()
    cls()
    line(x,0,x,127,7)

    print(vx.." velocity",0,0,2)
    print(ax.." acceleration")
    print(x.." x")

end

P#119443 2022-10-22 05:41 ( Edited 2022-10-22 06:07)

Follow Lexaloffle:          
Generated 2023-02-02 02:06:22 | 0.068s | Q:9