Log In  

I'm making a circle grow by simply increasing its radius. However, I want it to grow slower than +1 per frame. I'm doing this now by making a counter var for the circle, checking it against a frame timer and then moving on. I end up using this method a lot for various things and that makes me believe there is a better way.

This method clearly works but is there some sort of shorthand or anything I can do to get the same result?

circle={x=64,y=64,r=1,t=0,f=3}

function _update()
    if circle.t>=circle.f then
        circle.r+=1
        circle.t=0
    end

    circle.t+=1

end

function _draw()
    circ(circle.x, circle.y, circle.r, 10)
end
P#21584 2016-05-28 22:48 ( Edited 2016-05-29 04:36)

Try just incrementing by less than 1! The draw functions generally deal when you throw them non-integers. There are cases where it can yield jitter or unevenness, but then you just drop in a flr().

circle={x=64,y=64,r=1,t=0,f=3}

function _update()

    circle.r+=0.2

end

function _draw()
  circ(circle.x, circle.y, circle.r, 10)
end

edit: insert caveat about habits and strongly typed languages or something along those lines

P#21588 2016-05-28 23:41 ( Edited 2016-05-29 03:47)

Good point. Didn't really think about that...guess in my brain the P8 just deals with integers since that's how the pixels end up working but you're right. I'll give it a shot. Thanks!

P#21591 2016-05-28 23:45 ( Edited 2016-05-29 03:45)

You can call flip() which will end the frame cycle giving you essentially 15 fps, but that's pretty much the limit.

Just throw a flip() to slow down the loop.

P#21597 2016-05-29 00:36 ( Edited 2016-05-29 04:36)

[Please log in to post a comment]