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.

X and Y - Maths Anyone?

Hi guys,

I'm having a small problem. I need a picture to go exactly onto my character - the only problem is, the character can be anywhere on the screen. I tryed Co-ordinates x 33, but it wouldn't work.

Lastly, I need the image to stay on that square, which means I can't go the easy way out and just use animations.

Thanks in advance,
Pokemaniac
 
It's pretty easy, really.
You'll need an event set to Parallel Process, which tracks the player's X and Y and stores them as variables.
Then, just show the picture at ([Var1],[Var2]).
 
Thank for your help,

I'll try again - However, I'm pretty sure that XP moves pictures by pixels, whereas the character's co-ordinates are taken by what tile they're on. I'm really just trying to find a "formula" to change 1 pixel into 1 square.

Thanks for your help,
Pokemaniac
 
If you're displaying a picture, you have it either positioned by the upper left corner, or the center.
The character's screen_x & screen_y coordinates are at the bottom / center of the character.

So, if you are using 'upper left',
for x subtract half of the character width, and for y subtract the character's height.

If you are using 'center',
x should be good, for y subtract half of the character's height.

Both of those assume the new picture is the same size as the character. If not, you'll have to do a little more
jockeying.

Be Well
 
Thank you!

I'll try it in a few hours, since I have to go now, but I'll give it a go when I get back home.

~Pokemaniac

EDIT: Thanks guys! After fiddling around a bit (Since the character is 33 pixels tall/wide -o-) I managed to get it right, to the pixel!

This topic resolved now I guess. Thanks once again!

~Pokemaniac
 

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