I am working on a simple "Arena" style rpg game with tile based movement, a-la Final Fantasy 1-6 (you may noticed the sprites are borrowed from Final Fantasy IV from Squaresoft).
The first step is to make a map movement system! I have something basic worked out, but right now my character just jumps from one tile to the next.
How do I change the movement mechanic so that the player character actually moves smoothly pixel by pixel from one 16x16 tile to the next? I do want to recreate the classic such that the player can only end within the specific 16x16 tiles (not half in one tile, and half in the other).
Any ideas? Here is what I have so far: drive.google.com/file/d/0B1keSNvq9c4JNjc2VE1MamNPdVk/edit
Something like this?
Thanks for taking a look!
Unfortunately this is not quite what I'm looking for. You've got the pixel by pixel bit, but not the 16x16 tile-based bit.
Let me try describing what I'm looking for another way.
You can think of this background map as consisting entirely of 16x16px tiles, which are fit together to make a map. They used to do this because it allowed them to reuse specific "tiles" in the same map, and save space on old game cartridges.
The player sprite is also 16x16px, and so takes up the same space as one tile.
What I am looking for is when the user presses a direction on the keyboard (this can be just a tap), the player sprite will move from one tile to the tile adjacent in the direction pressed, but also for the movement to be shown, instead of just teleporting from one tile to the next.
It is very important to me that the player always end up on one of these 16x16 tiles. With the pixel by pixel movement in your example, the player sprite could end up with 8 pixels on one tile, and 8 pixels on another (essentially putting them between tiles).
I'm sure there's something in the stickied "Frequently Asked Questions" topic on this subject. One method is to add instance variables to the player object for "DestinationX" and "DestinationY". When the layout starts, set their values to the player's X and Y position. When one of the direction keys is pushed, add/subtract the desired distance from the appropriate instance variable (e.g. when up is pressed, subtract 16 from DestinationY). Then, have the player object move towards DestinationX and DestinationY. Ignore any more keyboard input until the player object has reached its destination.
The desired effect is a bit more complicated, but this should get you started. Knowing how to use the Distance() and Angle() expressions is key. A boolean instance variable on the player object representing whether or not the object is moving would be helpful when choosing when to accept/ignore keyboard input.
Develop games in your browser. Powerful, performant & highly capable.
For anyone interested, here is what I worked out:
Zatyka, I did find an example of tile based movement in the FAQs, but it did not animate the movement, it just "teleported". If I missed another one that goes over this, I apologize.
I did eventually find this example via search, but decided to come up with my own solution: scirra.com/forum/final-fantasy-example_topic78390.html