Game Development Community

Moving around a tilemap.

by Nathan Huffman · in Torque Game Builder · 10/15/2006 (12:04 am) · 2 replies

What does TGB already have built into it for moving a character object around a tile map? ie, I press my up key, and move one square up.

I've seen lots of stuff on making a tilemap then moving around it in smaller, unset increcments (think, sonic the hedgehog)

but I'm looking for something more like SNES FF3, tile based movement.

Have I overlooked something on this?

Heads up please

Thanks;)

#1
10/15/2006 (3:14 am)
That should actually be pretty straightforward. Two ways immediately spring to mind:

1. The super-retro way would be to simply setPosition() your sprites by a fixed increment, so they jump from tile to tile (eg, Wasteland).
2. The more contemporary (and prettier) way (think of Golden Sun on the GBA) would be to use the moveTo() function. In this manner you'd basically, once again, use fixed increments. What's nice about moveTo() is that it also comes with its own callback that lets you know when an object has arrived at its destination. You can use this to make sure no other movement input will be registered until a sprite has arrived at its tile.

If nobody has expanded on this later, I'll knock up some pseudocode, but for now I'm rushing out the door. Hope that helps! :)
#2
10/18/2006 (6:35 am)
I had already implemented #1 in the little project I'm working on at the moment, but I was finding the sudden camera / character movements a little jarring - using callbacks and the moveto() function in #2 hadn't even occured to me - thanks! :)