0 Favourites

How do I check if a point having certain coordinate already

  • Hey guys i have a new entry: How do I check if a point having certain coordinate already exists?

    I want to plot points on a Cartesian graph, but always to create new object, create a new object and it is not obeying this point with such coordination already exists, I want to make you already have a point with the coordinate P (3,5 ) for example does not create another point of coordinate Q (3,5) because P already has this coordinate Q.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • (Assuming your points are 1 by 1 pixel)

    You could create an invisible object called "CoorTest" for example.

    You could then create a function with two parameter, x and y and call it "TestCoordinates" for example.

    This function would set the coordinates of "CoorTest" to "FunctionParam(0)" (X) and "FunctionParam(1)" (Y).

    It would then test whether "CoorTest" overlaps with any point, if yes, the fuctions return value gets set to 1, if not, to 0.

    Like that, you could run the function each time you want to check for a coordinate already being occupied and getting the result as a return value.

  • randomly

    See his previous question :

    If it is about this, then i see 4 big problems, an i dont really know how to solve them. I mean, i cant do better then you.

    1. If the 'drawing' (that is basically creating sprites) happens in the same loop as the 'checking', then i cant see any easy solutions. Due the fact that you cant read from a newly created object till the next top level event.

    2. The drawing happens in lines, segments. Not in dots, points. So, there are no coordinates to check.

    3. The solutions for (y) when iterating x are floating numbers. No chance using a 'is the same as' comparison.

    4. Iterating x by 1 is relatively still a big sample rate. Even if you clearly see 2 functions intersect, the sample rate will be to big to capture it.

    Still assuming it is about the same thing in his previous questions.

  • if I put the coordinates in a text field and touch on the create sprite button, change the location to the new sprite of point position, but when i tap the button again, on the button, create points again and again new sprites over the points in the same place of the sprite point already created

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)