Code Explanation


Below is the unwrapped code. There's actually not a whole lot to this one: 105 of the 280 characters fits on a single line. So, let's look at that in isolation:

?i!=g and sub(a,j,j)or"",x,y,x==mid(x,c-5,c)and y==mid(y,d-5,d)and(0==m(34)and 7or g+1==i and 3or 2)or 5

It's not as scary as it looks! ? is shorthand for "print" - so this line is responsible for printing text the screen. And the text we want is the hidden objects! Let's take a better look at what parameters we're passing:

Texti!=g and sub(a,j,j)or""
X-positionx
Y-Positiony
Colorx==mid(x,c-5,c)and y==mid(y,d-5,d)and(0==m(34)and 7or g+1==i and 3or 2)or 5

75 of the 105 characters are solely used for color of the text!

But before we look at that, it will help to know what's going on with the text string.

The input for the text parameter is, essentially, a ternary statement:

If i != g is true, then the text is parameter becomes sub(a,j,j). Otherwise, it becomes "", an empty string.

i is the index of the a loop we're in, and g  is a random value chosen at the start.

So, what this does, is print every character, twice, except for one, which is only printed once.

Now that we know that, the color parameter won't be so bad: It's just a double-nested ternary statement:

ConditionValue if true
Value if false
x==mid(x,c-5,c) and y==mid(y,d-5,d)<See next line>5 (Gray)
0==m(34)7 (White)
<See next line>
g+1==i3 (Red)
2 (Green)

The C and D variables are the x and y positions of the mouse. So, the first condition checks if the character is near the mouse. If not, draw the character gray.

The next condition is checking if you're pressing a mouse button: If you're not, we want to draw it white - because we still want to show that you're hovering over this character.

If you are pressing left click, then we do one, final, ternary statement: This one is checking if the object was randomly selected or not. And then, we draw the text green or red, to show if you are right or wrong.


Full unwrapped code:

poke(24365,1)
a="cluter!?☉★✽♥웃⌂🐱♪😐:<|>"
r=rnd
g=2*flr(r(20))+2
b=r()
m=stat
::_::
cls()
srand(b)
c=m(32)
d=m(33)
for i=2,43do
j=flr(i/2)
x=r(99)
y=r(99)
?i!=g and sub(a,j,j)or"",x,y,x==mid(x,c-5,c)and y==mid(y,d-5,d)and(0==m(34)and 7or g+1==i and 3or 2)or 5
end
?0,c,d,6
flip()
goto _

Files

pico_clutter_html.zip Play in browser
Dec 29, 2020

Leave a comment

Log in with itch.io to leave a comment.