Bad character sprite position approximation with floating point map display coordinates

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
20
First Language
Italian
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!
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
20
First Language
Italian
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  :guffaw:  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"
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top