Log In  

Cart #sdd_test_animation-2 | 2023-10-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

I just got started with Pico 8 and wanted to try out publishing a cart, so I made a really simple hello world animation as my first attempt. Looking forward to experimenting with much more substantial carts in the future.

P#135235 2023-10-01 20:35 ( Edited 2023-10-01 21:33)

welcome

I optimized a little bit your code, so it needs less tokens

--test animation
--by superderpyderps
function bounce()
    sfx"0"
    bkg = rnd"16"
    fill = (bkg-8) % 16
end

function _init()
    r=4
    x,y,dx,dy 
     = rnd(128-r)
     , rnd(128-r)
     , rnd"2" + 1
     , rnd"2" + 1
    bounce()
end

function _update60()
    if x >= 128 - r then
        dx = -rnd"2" - 1
        bounce()
    elseif x <= r then
        dx = rnd"2" + 1
        bounce()
    end

    if y >= 128 - r then
        dy = -rnd"2" - 1
        bounce()
    elseif y <= r then
        dy = rnd"2" + 1
        bounce()
    end

    x += dx
    y += dy
end

function _draw()
    cls(bkg)
    circfill(x, y, r, fill)
end
P#135268 2023-10-02 09:52

[Please log in to post a comment]