Character X,Y position vs. metasprite locations

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
darryl.revok
Posts: 520
Joined: Sat Jul 25, 2015 1:22 pm

Character X,Y position vs. metasprite locations

Post by darryl.revok »

Howdy!

I have a question. How do you guys tend to position your metasprites in relation to your character X,Y position?

It seems like there would be advantages and disadvantages to each.

If your x position is in the center, then character flipping is much easier.

If your x position is on the left, then it seems like collision detection math is a little simpler.

If your y position is on the bottom, will this save any calculations for ground checks?

Curious to hear some different opinions on this. I centered my metasprites for animation, but now that I'm doing collision detection, I'm wondering if that was the right call.
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Character X,Y position vs. metasprite locations

Post by rainwarrior »

I think you've outlined the important critera already, I don't really have much to add, other than to point out that flipping and collision are related, so centering might help flipped collision as well.

Every game has different needs, so as long as you've got a good idea of what you need and what the consequences are, you should be able to make the right choice.

In my own current game, I usually set the pivot point one pixel below the centre of the sprite. Usually the bounding boxes are symmetrical, so I can use the same ones if the character is flipped or not, and the Y value is ready to test the ground. There are some other reasons I do this, but they're very specific to my game. I also do it differently for some character types, for various reasons. If an object type has unique code it doesn't necessarily need to be set up like the others.
User avatar
thefox
Posts: 3139
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Character X,Y position vs. metasprite locations

Post by thefox »

I tend to place it at bottom-center but have also been wondering which would be the optimal setup. Placing it at one corner of the collision bounding box should make it easier to calculate the bounding box in world coordinates, like you said. I have flipped variations of the metasprites in ROM (ROM space vs CPU usage tradeoff), so the flipping thing you mentioned isn't a problem.

Of course placing the origin at the corner might mean that you will need to adjust the coordinate more in other places (say, to spawn a dust cloud at the player's feet), so yeah, it depends.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Character X,Y position vs. metasprite locations

Post by tokumaru »

I tend to use the bottom center as the reference point for meta sprites, because that's usually the point of contact with surfaces, but my meta sprite system uses signed offsets for the X and Y of each sprite, so I can have the reference point be anywhere I want. This way I can have sprites with protruding features and still keep the hotspots at the correct positions.
Post Reply