I just discovered this language at Aldi of all places. Got a learn how to code book using Snap for my son because he's 12 and getting curious about what dad does for work (we've sat down to talk through very high level what some of the code I'm working on does)
So in the spirit of trying something new I've been playing around in snap myself so i'm at least mildly competent when he asks me questions or gets stuck. But I've hit a point where things don't make sense
To set the stage I'm drawing a perfect black square of whatever size then saving the PenPaths to a costume, then repeating with a white square. Then i'm cloning that single object to layout a grid of whatever row and column count. finally a little when clicked to toggle white to black to white for its costume
Now to the point where i'm lost. Looking to detect (like in minesweeper) the up to 8 "touching" squares (5 on the edge, 3 in the corner) I found code like this that works
Apparently I cannot use pictures in my post so...
set Close Neighbors to list
for each Cell in my:neighbors
if touching Cell ?
add Cell to Close Neighbors
But I noticed there are functional blocks for all your map, filter, reduce needs so read through the docs on them and thought I would recreate the for loop as a single Keep From block
Set Alt Close Neighbors to keep items touching object:myself ? from my:neighbors
To me these should be logically identical
First opens an empty list loops through all the neighbors (I get the idea of neighbors is loosely defined) checks if (I assume the calling clone) is touching that sprite from its neighbors and if it is adds it to the list. Simple makes sense.
However I should ALSO be able to START with the my:neighbors list and then ONLY keep the items actually touching:myself
So why do I get things that are 2 blocks away acting like they touch in this method?