FinalZero wrote:I don't understand what "adding 157 and reversing the bits" means. If I understand correctly, 157 is the bias, which is added to the subpixel velocity, and if the result exceeds 256, then the pixel position is incremented. I don't understand when the reversing is done.
I think I was explaining how I changed the fake global sub-pixel position each frame, but it's been a while. I'll take a look at the test code I write for this later today and I'll clarify this.
In an rpg like Dragon Warrior or Final Fantasy, or any game that has tile-based movement, how is movement between tiles made smooth?
I don't know if this is related to the first question, but let me get something out of the way: this normally doesn't have anything to do with sub-pixel movement, seeing as movement in grid-based RPGs doesn't use acceleration.
Anyway, the basic idea is that you move the characters pixel by pixel every frame, but only allow them to change directions or stop moving when they're perfectly aligned to the grid. If you want to allow diagonal movement, you need vertical and horizontal speed variables, which can have values -1, 0 or 1, which you add to the character every frame (if you don't want diagonal movement, just allow one of the speed variables to be non-zero). After moving, you check whether the character is aligned to the grid. This test consists in isolating the lower bits of the character's position to see if they are in the exact position necessary for the character's to be centered in a square of the grid.
For example, if the grid and the character's are 16x16 pixels large, and their coordinates represent their top left corners, you'd need to AND the vertical and horizontal coordinates with %00001111 and only when both results are 0 is the character aligned to the grid. This is when you'd check the controller and modify the speed variables accordingly.
Again, in an rpg like Dragon Warrior or Final Fantasy (and all their sequels), (a) how is a map stored? (b) How would it *ideally* be stored?
That varies a lot from game to game, since each game has different requirements.
I assume you have one grid (an array of arrays) of tiles (grass, forest, desert, water, etc), but what about chests? Are they stored in the same grid? or a different grid? or an array? How do you store whether they've been looted or not?
It depends. If the maps are stored in RAM, it's common to have these kind of items be part of the map. RPGs can have numerous large maps though, so even if you have a lot of extra RAM you won't be able to store every map.
For this reason, sometimes it makes more sense to store collectible items as objects, and use bits of RAM to indicate whether they've been collected or not. Each item should have an ID that you'd use to locate its state bit.
What about people that wander around? Are they in an array or a grid? If they're in an array, that'd mean you'd have to iterate the array when you press A to try to talk to whoever's in front of you (to find the one with the right location), but if they're in a grid, that'd mean you'd have to test each tile if it has a person so you can make them wander.
Moving objects should not be part of the map. The map might even contain "clues" indicating when/whete to spawn the objects (although having a separate list just for objects is the norm), but once they're "alive" they definitely shouldn't be considered part of the map.