Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

comparing picture coordinates with a call script?

Hey guys.

Heres the skinny.

I'm make a game where the player is displayed as a picture at x,y coordinates.
No problem.

next, as he gets close to other pictures, they are repelled by the player.
Again, no problem.

To do this, I have an event set on Parallel process running a call script to controll each enemy picture that says
[conditonal event-Script]

($game_variables[@event_id] - $game_variables[1]).abs <= 30
and
($game_variables[@event_id + 50] - $game_variables[2]).abs <= 30

then... repel enemy picture. by adding/subtracting 1 from the enemies x/y depending on where they are in relation to the player.

[end]
where:
$game_variables[@event_id] = enemies picture X coordinate
$game_variables[@event_id + 50] = enemies picture Y coordinate
$game_variables[1] = Players X
$game_variables[2] = Players Y

now my question is this. I would like to add the magnetic effect so that enemies repel eachother as well.

So, is there a method, and how would I implement it, that would check to see if a picture is within 30 pixels of another picture, and if it is, add/subtract to the correct variables so they are repelled?

Thanks!
 

poccil

Sponsor

The game's pictures can be retrieved using "$game_system.pictures".  The game system actually has two sets of pictures, one for map pictures and the other for battle pictures.  To find the coordinates of a picture you can use these two functions:

Code:
# Returns the picture's X coordinate.
def getPictureX(index)
  index+=$game_temp.in_battle ? 50 : 0
  return $game_screen.pictures[index].x
end
# Returns the picture's Y coordinate.
def getPictureY(index)
  index+=$game_temp.in_battle ? 50 : 0
  return $game_screen.pictures[index].y
end
 
thanks.

It's used on the map though. So the pictures have id's.
I'm using the call script
$game_screen.pictures[id].show("name", origin, x,y,zoom x, zoom y, opacity, blend)
And i already know the coordinates.
What i need is a method to compare the coordinates with all the other pictures.

thanks!

edit-
maybe you knwo whatyour talking about, I don't know much abour RGSS.
How would I implament that code? And does it check the other pictures coordinates?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top