A Coding Theory: Identification


(I put this under collab because this is a group discussion)

This theory is partially based off a game I want to make, Farmer Simulator. It would be a sort of a tapper, except instead of tapping you take care of farming needs in trade of earning money to use to add to your farm. The home screen of your farm is a view from the skies looking down at the farm. Each building or station is marked with a little dot which you can move around and when you tap it, a little tab above it appears that says what the station is (Ex: Wheat Farm) and you will have an option to enter it and do certain actions like water a garden or harvest the food, which will give you money, which you use to upgrade your farm.

Now, I thought about this theory with the part where the tab says what that station is, a theory I call Identification. The theory of 2 values communicating to each other through Check Once Ifs and set values, to come out with a product of an object knowing what the object that was tapped is.

This topic is for spreading conversations of this theory proving it right or wrong using different examples and strings of code.


Are you talking about something like this?


In that example, it can identify which clone you're pressing & and it resets when you're no longer pressing the clone. Identifying taps is a bit simpler.


If they are seperate objects, obviously you could just use a when '(object)' is tapped. If they are clones, you can have a when object is tapped, and then have:
Check one if |x position-last touch x| + |y position-last touch y| <20 where "|" denotes absolute value, which is detecting whether last touch x and y is within 20 of the object's x position and y position.


@BuildASnowman I didn't understand a thing you just said.


Psuedo-code translation of what he said,

WHEN clone is tapped
CHECK ONCE IF distance between last touch spot & clone* < 20
-then this is the clone that was tapped, so [do something]

In most static circumstances using a threshold of 20 would be fine.

In a dynamic application where the distance between clones could be less than 20, you could follow the example in the linked project "Clone Press ID" above. The difference is it compares and sets the min distance found to a variable (iterates twice to ensure the closest is found).

*note: he didn't actually show a strict distance calculation, but as with the threshold of 20 if the clone's separation is large enough, the simplification still works.


This is code from the linked example to find the absolute closest clone when necessary:
(This uses invisibility as the clone's index)

2nd image to show right portion of equations

The end result of the above code is a variable (PlaneID) set to the tapped clone's index. But this could have also been used with a CHECK IF block to take some action