Hello!
I really loved playing around with the new fillp() possibilities, but it took me a little bit to understand how it actually worked (possibly because I'm primarily a web developer and this is quite far from any concept I've used before), so I made a small cart that helps visualize how exactly it works and what setting the different bits does. Maybe it will help someone else get a better understanding of it. If nothing else, it's fun to play around with :-)
Also this is my first post and my first published cartridge, so please let me know if I did anything wrong or if I could have done something better
Cheers
Neat! This is a very clear demonstration!
And welcome to the BBS! You said to let you know if anything could be done better, and you may have just been being polite and this may be way more than you were asking for, but in an attempt to help, I actually thought of a couple small things:
-
It feels like this post might lend itself better to either the "Workshop" or "Snippets" category, rather than "Carts"...I think those categories are fairly new so there's not a lot there yet and some historical inertia of everything ending up in the "Carts" category, but I think the new categories are a good idea and I would encourage their use!
-
It doesn't make a huge difference for this sort of cart, but you might want to put label text on the cartridge PNG (just put two commented lines at the beginning of the code and they will show up as the cartridge label text). I just mention it in case you don't know about that yet, since that feature can be easy to miss, but very useful if you ever intend to share the actual cart PNG around.
- In Lua, you don't need to put parentheses in "if" conditionals. (Unless you are using the one-line syntax which is specific to PICO-8)
lol anyway I must be bored or something but there you go :D
OMG you read my mind! I literally started a cart just like this! :D I think the only difference was I also had line() in there too. This is awesome. Nice work!
Great cart, very useful and highlighting a new feature, thumbs up! :D
@kittenm4ster Thank you so much! This was actually exactly the kind of feedback I wanted! I've updated the cart now with a label text and with no parentheses around my if conditionals :-) That is definitely gonna save me some tokens down the line.
@MBoffin Thanks :-) Updated it to also have line() in there now
Not sure how replying to comments works, but I probably didn't do it right. Anyway, thank you so much to all you for your positive comments :D
If you like reducing your token count, then these bits:
if btnp(0) then if ssx==0 then ssx=#bits-1 else ssx-=1 end end |
Can be reduced to something like this:
if btnp(0) then ssx=(ssx-1)%#bits end |
And yes, the %
operator works appropriately on negative values. -1%7 == 6
, for instance. Some people expect it to be 1 or maybe -1, but no.
Also, if you like conserving source code space (not tokens--it compiles the same) you can use PICO-8's one-line-if format:
if(btnp(0)) ssx=(ssx-1)%#bits |
Also, personally I would just be using an actual 16-bit value rather than a 2D array of bools, so that I could use the value directly in the fillp() call, rather than having to convert. I'd change ssx,ssy to be ssb and add/sub 1 for x cursoring and add/sub 4 for y cursoring, something like that. Maybe shift a bit left/right 1 and 4 instead of having a bit number. I think the resulting code would be a lot smaller and maybe easier to read... maybe not, depends on the reader.
Afterthought:
Better idea: Work directly on the pattern, but store it as a string of the binary representation of the pattern, e.g. "0b1010010110100101.1" and then just diddle the string when you're editing the pattern. Lua can coerce strings directly to numbers, so you can pass that actual string to fillp() and it'll just work, plus you can print it directly to screen, select individual bits for display in the table with a simple call to sub(), etc.
@Felice Thanks for the tip! Didn't think about using the % operator that, but it makes a lot of sense.
I definitely need to read up a bit more on shifting bits etc, it's one of my weaker areas right now that I don't fully understand. I think I originally went with a 2D array of bools because that was what my mental model looked like :D
[Please log in to post a comment]