# How do I check if a point having certain coordinate already

Get help using Construct 2

### » Sat Oct 29, 2016 9:30 pm

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.
Last edited by sielxm3d on Sat Oct 29, 2016 11:42 pm, edited 1 time in total.
B
33
S
9
G
3
Posts: 280
Reputation: 4,297

### » Sat Oct 29, 2016 9:50 pm

(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.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

### » Sat Oct 29, 2016 10:28 pm

@randomly

See his previous question :
viewtopic.php?f=147&t=183342

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.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Sat Oct 29, 2016 11:40 pm

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
B
33
S
9
G
3
Posts: 280
Reputation: 4,297