Smooth Movement in RTS/Zelda like games? How is it done?[Solved]

Started by
5 comments, last by code_nerd 18 years, 8 months ago
hi folks, since my last posting concerning this was a bit misleading, i am reposting it here. Let's assume we have coded an 2-D-TileBased RPG / RTS where you can move in HEXTILES (like "Battle Isle", "Mech Warrior I"). I understand how this works generally (array with tiles and so on), but i think it looks bad, since every movement is just a change of the player/vehicle to another hextile. Now, let´s look at games like Zelda, Command&Conquer (early), StarCraft, Rage of Mages, Diablo,... The pure movement is "smooth" in these games, you click somewhere in your map and the char/vehicle moves (animated) to exactly that place (as there were no tiles at all). Now to my question, how is the technique called that allows this kind of movement? Which GFX Engines are involved (is it 2D? 3D? Iso?) and how are maps created/saved in these case!? I am really only interested in the movement/mapbuilding process, i know that accomplishing a game like diablo,... is not possible, but only this way of handling movement would really interest me. Thanks for your time! [Edited by - code_nerd on August 3, 2005 2:23:09 AM]
Advertisement
Well, the maps could be made the same way (array of tiles). The type of movement found in games like Starcraft, Warcraft, and C&C, is actually very simple (until you start talking about pathfinding). What you want to do is have an end destination for your units, find the angle you would have to go to reach the end destination, and then use sin and cosine to move the unit along that angle at a certain speed until it reaches the destination. This will work just fine until you need have your unit get around an object/unwalkable tile. In order to do that you should probably look into the A* pathfinding algorithm.

Also , it doesn't matter if you are using 2D or 3D, the movement will be the same concept the same in both cases.

Sorry if I was a little incoherent, its early where I live, let us know if you need anymore help.

EDIT: I really didn't answer some of your questions, I'll post a better answer later in the day.
My Current Project Angels 22 (4E5)
The basic idea (from a mapbuilding perspective) is that while a map consists of a big array containing tile info and such, units are free entities that are instead stored individually and have their individual coordinates saved with them. These coordinates would be to a grid that subdivides the tilemap (splits tiles into many spaces).

That didn't come out as well as I'd hoped, but hopefully it gets you thinking in the right direction. [wink]
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
hmm... let's see if i get it right

If thats the background:
xxxxxxxx
xxxxxxxx
xxxxxxxx
xxxxxxxx

And thats a spaceship:
...A
.AAAAA
..AAA
...A

...it does NOT work like this (move the complete spaceship
to background in one single step):
xxxAxxxx
xAAAAAxx
xxAAAxxx
xxxAxxxx

...instead like it works like this:
Axxxxxx
AAAxxxx
AAxxxxx
Axxxxxx

xAxxxxxx
AAAAxxxx
AAAxxxxx
xAxxxxxx

xxAxxxxxx
AAAAAxxxx
xAAAxxxxx
xxAxxxxxx

and so on.

Is "smooth" movement done that way!?

And, is it possible with all common GFX libs like DirectX, GDI+, SDL, OGL,...?
If I understand your question correctly, you are asking how you can get your units or characters to move smoothly between tiles, rather than jumping from tile to tile, yes?

There's heaps of ways to code this, but the principle is that the position of the units doesn't have to be linked directly to the tiles. You can have units on "fractional" positions, half in one tile, and half out. This can be coded literaly as a decimal fraction of tile units, or as pixel coordinates, or in a variety of other ways.
This article might help you understand how it's done. The player isn't just moved a tile at a time. The player has screen coordinates that are translated to map coordinates to determine what tile the player is on. When the player wants to move his position is just updated with the speed of the player. It's a little more complicated than that but that's the general idea.
now i got it, thanks to all posters,
you really helped me understanding this.

Great community here^^

This topic is closed to new replies.

Advertisement