Bad character sprite position approximation with floating point map display coordinates

Hi everyone,


 I'm having an aesthetical issue with the way charachter sprite are drawn in relation to the tileset map. I have the player character and camera movement that change the _displayX and _displayY of $gameMap with floating point numbers. The thing is apparently the map sprite and the character sprites approximate their position based on the display coordinates with different rules (maybe one use round() while the other floor()) or at least that's my guess, and this causes the character sprites to "wobble" in relation to the map while the camera is moving. Obviusly they move for only one pixel but it's enough to be noticed and is annoying to the eye.


Anyone has an idea how to solve this problem?


Thanks!
wrong guess ;-)


to make the NPCs appear to be inside the grid instead of walking on its edges, the default sprites are automatically displaced several pixels up - I think it's 4 pixels in Ace and 6 pixels in MV.


However, that would not fit with objects as there are no holes at the bottom of doors and similiar events, so this automatic displacement can be disabled by declaring the sprite to be an object sprite instead of a person sprite (which is the default).


You do that by placing a ! at the beginning of the filename for the sprite - just check the naming for door sprites and other object sprites to see how it is done.


When you're tricking the display by use of float coordinates instead of integer coordinates, that default displacement remains a fixed number of pixels and doesn't scale with the rest of your calculation. You need to change your script commands to take that into account.
I don't know if we are the same page, I'm not sure I have totally understood your answer, but i tried to put an event with !sprite graphic (a lever) and when the camera moves it wobbles aswell as the other events.


lever1.png 


these screenshots where tanken at different times while moving horizzontaly. As you can see (if watching closer) they a 1 pixel apart on the X axis, i used a transparent tile to get a black background and a better vision of this thing.


EDIT: I solved it  🤣  I found these methods


Game_CharacterBase.prototype.screenX = function() {
var tw = $gameMap.tileWidth();
return Math.round(this.scrolledX() * tw + tw / 2);
};

Game_CharacterBase.prototype.screenY = function() {
var th = $gameMap.tileHeight();
return Math.round(this.scrolledY() * th + th -
this.shiftY() - this.jumpHeight());
};


and changed "Math.round" with "Math.ceil"

Original thread: https://forums.rpgmakerweb.com/threads/bad-character-sprite-position-approximation-with-floating-point-map-display-coordinates.62044/