Log In  

12

Cart [#46135#] | Copy | Code | 2017-11-11 | Link
12

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

P#46113 2017-11-10 14:51

::

Nice cart, good job, very usefull, thank you

P#46114 2017-11-10 15:57

::

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:

  1. 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!

  2. 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.

  3. 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

P#46115 2017-11-10 17:16

::

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!

P#46116 2017-11-10 17:53

::

Great cart, very useful and highlighting a new feature, thumbs up! :D

P#46117 2017-11-10 19:56

::

Super useful tool, downloading it. Thank you so much!

P#46127 2017-11-11 01:01

::

@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

P#46136 2017-11-11 04:21

::

@Briix

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.

P#46156 2017-11-11 20:21

::

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.

P#46158 2017-11-11 21:51

::

@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

P#46177 2017-11-12 03:31

Log in to post a comment

user:
password:

New User | Account Help
:: New User
X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2017-11-20 01:50 | 0.212s | 1835k | Q:26