When I'm making games or tweetcarts, I often adjust numbers just a tiny bit, then rerun the whole game. e.g. I change the player speed by 0.1, then change it back, then try 0.05...
This is a bit slow, so here's a library I made to help me do it faster. I also find it useful for analyzing other people's tweetcarts -- if I can easily adjust the values they use, I can quickly figure out what they mean
setup
load #twiddler
- copy the
knobs.lua
+helpers
tabs into your game - use
kn[1]
,kn[2]
, ...kn[8]
in place of any number - add
twiddler()
to the end of your_draw
function
Now, run your code:
- press tab and adjust the values (see "controls" below)
- press tab again -- the values will be copied to your clipboard
- paste the values into the start of your code to save them
example 1
Start with a tweetcart you want to study. For example, this one by 2DArray: https://twitter.com/2DArray/status/1492566780451205120
?"\^!5f10ââđąâ4ě9♥" ::_::?"âś1âśc" w=t()/8 c=cos(w) s=sin(w) n=1800 for i=0,n do a=i*.618 j=1-i/n*i/n y=1+j*j-2*j*j*j r=1-(1-j)^3+sin(a*10)/9 p=(6+sin(a*10)*(.5+r/2))*(.7+y*y/3) circfill(64+cos(a+w)*r*20,80-y*30+sin(a+w)*r*12,2,p) end goto _ |
Add the knobs, and replace some interesting-looking numbers with knobs:
kn={.5,.7,.618,2,0,0,0,0} --changed ?"\^!5f10ââđąâ4ě9♥" ::_::?"âś1âśc" w=t()/8 c=cos(w) s=sin(w) n=1200 --changed -- twiddler needs a little bit of cpu to run for i=0,n do a=i*kn[3] --changed j=1-i/n*i/n y=1+j*j-2*j*j*j r=1-(1-j)^3+sin(a*10)/9 p=(6+sin(a*10)*(kn[1]+r/2))*(kn[2]+y*y/3) --changed circfill(64+cos(a+w)*r*20,80-y*30+sin(a+w)*r*12,kn[4],p) --changed end twiddler() --changed goto _ |
Now run the code and play around! looks like knobs 1 and 2 control the color gradient, knob 3 controls the spiralness of the circles. cool! Add new knobs, remove old knobs, keep going until satisfied.
example 2
This process works on your own code that you're in the middle of writing, too. Write kn[1]
etc instead of a number, open the knobs panel, and edit the value until it looks right:
This is from the dev process of a recent tweetcart of mine (twitter, cohost)
controls:
Press Tab or W to open/close the knob panel
- LMB - change slider value
- MMB - pan slider range
- RMB - cancel current interaction
- wheel - zoom slider range
When you close the panel (Tab/W), knob values will be copied to your clipboard -- paste them into your code to save them.
When you're done with the knobs, you can replace kn[1]
etc with the literal value of the knobs, and delete the twiddler code. This is a tool meant for development, not meant to be used during a finished game. (although, a finished game that used something like this would be pretty nifty!)
[Please log in to post a comment]