Tile Based Movement

Get help using Construct 2

Post » Wed Nov 13, 2013 10:11 pm

Hello!

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: https://drive.google.com/file/d/0B1keSNvq9c4JNjc2VE1MamNPdVk/edit?usp=sharingravelin2013-11-13 22:12:28
B
4
Posts: 13
Reputation: 226

Post » Wed Nov 13, 2013 11:29 pm

Something like this?
B
46
S
16
G
74
Posts: 2,088
Reputation: 44,185

Post » Thu Nov 14, 2013 6:19 pm

Hi Plinkie,

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).
B
4
Posts: 13
Reputation: 226

Post » Thu Nov 14, 2013 7:15 pm

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.
B
63
S
19
G
8
Posts: 341
Reputation: 12,130

Post » Thu Nov 14, 2013 10:33 pm

For anyone interested, here is what I worked out:
https://drive.google.com/file/d/0B1keSNvq9c4JbjhBTTd6YUhwbHc/edit?usp=sharing

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: http://www.scirra.com/forum/final-fantasy-example_topic78390.htmlravelin2013-11-14 22:34:05
B
4
Posts: 13
Reputation: 226


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests