Formula to see if point is occupied

Hi, I am new to programming and am playing around with building a simple game. In my game I want to move children within a group, but only if the space they are moving into isn’t occupied by another child.

Is there a boolean type formula you can put in the x and y coordinates for that tells you whether or not an object currently occupies the space?

Thank you for your help. I have searched all over but can’t find anything.

Programing is only tool, you must think :slight_smile:

Is there a boolean type formula you can put in the x and y coordinates for that tells you whether or not an object currently occupies the space?

Sorry, but no magic can happen. If somebody asks you in real life such question how would you answer - “I must first see space and then I will tell you” probably.

So you want to know if some child is on (x, y) position. Ask yourself how can you know it?

“Huh, I must somehow know keep information about this position and if it’s occupied or not”

So you need some kind of storage.

Here comes tool - programming. What can you use to represent 2d space -> tables!

So you use table to store positions (multidimentional table). Then you must mark if at position x, y there is someone. 

postions[x][y] = true/false

Thank you for your help.

I am actually pretty familiar with the process of thinking…

You wrote an entire paragraph and essentially all you said was “There isn’t a function. Use a table.” Everything else you wrote just seemed condescending.

Programing is only tool, you must think :slight_smile:

Is there a boolean type formula you can put in the x and y coordinates for that tells you whether or not an object currently occupies the space?

Sorry, but no magic can happen. If somebody asks you in real life such question how would you answer - “I must first see space and then I will tell you” probably.

So you want to know if some child is on (x, y) position. Ask yourself how can you know it?

“Huh, I must somehow know keep information about this position and if it’s occupied or not”

So you need some kind of storage.

Here comes tool - programming. What can you use to represent 2d space -> tables!

So you use table to store positions (multidimentional table). Then you must mark if at position x, y there is someone. 

postions[x][y] = true/false

Thank you for your help.

I am actually pretty familiar with the process of thinking…

You wrote an entire paragraph and essentially all you said was “There isn’t a function. Use a table.” Everything else you wrote just seemed condescending.

A little late, if you are usings physics, but how about a rayCast?

http://docs.coronalabs.com/api/library/physics/rayCast.html

A little late, if you are usings physics, but how about a rayCast?

http://docs.coronalabs.com/api/library/physics/rayCast.html