How do I get sprites from the screen?

I have made a sprite, and I want to determine how far the player and the sprite is from eachother. But since I dont got a variable
for the sprite, that is hard.

So in short: How do I get a variable of a sprite on the screen?
What...? You mean how far is player from event X? Distance?
What...? You mean how far is player from event X? Distance?
No, like from a Sprite.
Thus script might be what you're looking for.

No, like from a Sprite.

There aren’t such things as “sprites” on the game screen. A sprite is merely an image. You use the sprite image in an event to display the sprite in game.

It is possible to get the distance using eventing, as you can get the player’s x and y position and store it in a variable, as well as get the x and y position of the event displaying the sprite image.
There aren’t such things as “sprites” on the game screen. A sprite is merely an image. You use the sprite image in an event to display the sprite in game.

It is possible to get the distance using eventing, as you can get the player’s x and y position and store it in a variable, as well as get the x and y position of the event displaying the sprite image.
Alright, so like whats the formula? Or like, what do I have to write?
I found out how to store sprites in global arrays using $.
Soo, the next step is basically just checking if its nearby. I got the player x and y and same with the
sprite.
Thus script might be what you're looking for.

I kinda wanna write it myself.
please check the control variable command, it contains everything you need to do this by eventing - first load the values like the event x and event y coordinates into variables (and do the same with the player coordinates, then calculate the distance between them with the control variable command and mathematics.
If you are simply looking for the formula to determine the distance between two elements on the screen, it is the following.

Assuming that A and B are two object then the distance between A and B is
Ruby:
Math.sqrt((B.x - A.x)**2 + (B.y - A.y)**2)

Keep in mind that this formula is very generic. If your objects do not move diagonally, you can simplify it and just sum the absolute value of the difference between horizontal and vertical coordinates.

If you wanna read about it in detail, you can give this a look, or just look for it on the internet. It is a pretty basic concept when it comes down to mathematics.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-get-sprites-from-the-screen.144758/