A control scheme inspired by Touhou movement. Uses both buttons to allow precise movement along a wide variety of speeds. The fastest speed isn't very useful in the small space used in this demo. A very slight zoom out is used at the fast speed, and a slight zoom in for the slow speed.

I didn't make any effort to minimize code length, so this collection of a few extremely simple tools uses more than one frikking thousand tokens out of the 8 thousand token limit. Some possible space saving options are obvious.

Comments

Log in with itch.io to leave a comment.

Using "purer" functions has been a big help in code writing. Trying to clear away any side effects from a function makes it easier to design and debug.

px,py,vx,vy=update(px,py,vx,vy,ax,ay) is a pure or at least mostly pure function. The only data the function reads is the inputs, and the function does nothing except return the correct values.

And writing things out in pure functions made it obvious that the dimensions were independent, so I can write...

function update(p,v,a,t)

 t=t or 0.033333333 --approx. 1/30 sec frame time

 return p+v*t+0.5*a*t*t, v+a*t

end

function updateball(ball,otherstuff)

--100 times more readable than putting everything in one line

ball.px,ball.vx=update(ball.px,ball.vx,ball.ax)

ball.py,ball.vy=update(ball.py,ball.vy,ball.ay)

--can use it for both 2 and 3 dimensions

end


(It's silly that I like to write p_new=p+v*t+0.5*a*t*t instead of just p_new=p+v*t, the extra accuracy is probably never needed. But how the heck should I be able to compare tradeoffs in speed and accuracy? Both speed and accuracy of even a crappy computer are light-years beyond what I need to emulate a PICO8 fantasy console. Most people use a simpler formula because of laziness, not desire for efficiency.)