MoveCharacter and MoveCharacterDirect

Started by DoorKnobHandle, Sat 12/03/2005 14:16:51

Previous topic - Next topic

DoorKnobHandle

Hello,

I have a question: As you know, I am working on this real-time strategy game.

Now when I move units (characters), I either use MoveCharacter or MoveCharacterDirect... MoveCharacter is fine, but it is getting very slow as soon as I move more than 5 units at a time. MoveCharacterDirect is very fast and perfect, but of course ignores the walkable areas...
Why is that? I guess it is because AGS has to precalculate if the moving characters are crossing space which is not walkable and then it has to find an alternative route for every unit...

What I'd need is something that is as fast as MoveCharacterDirect, but still prevents units from going over unwalkable space...

Is there a way to do something like this?

Pumaman

You've correctly described the problem.

However, if there was an easy solution then MoveCharacter would already use it and be faster.

Pathfinding is unfortunately quite a time consuming operation. Strategy games like Command & Conquer work around this by having a much less accurate pathfinder that usually won't take the shortest route, but just takes a route towards its destination and then follows walls until it gets there. That sort of thing wouldn't be appropriate for an adventure game engine.

Radiant

A workaround for you may be to have your game run on a grid or matrix of tiles (which it might already do). Make the screen a grid of 20x20 tiles or thereabouts (logically, not visually) and have an array that indicates whether a tile is walkable or not (or possibly, crossable only by flying units, or something). Then do your own code which uses MoveDirect to move chars from one tile to the next. Warcraft II uses this to great effect.


DoorKnobHandle

Thank you for your help, Radiant, but I already thought about that. It wouldn't be possible to display those tiles with AGS. What should I use? Overlays? Only 20 allowed and they would be in the foreground all the time... Or Room Objects? Wouldn't be good either...

I would use this grid system, if I would write my game using cpp or some language, where you can simply "blit" images to the screen...

Pumaman

The point is that you don't need to display the tiles. The tiles are just conceptual in terms of how you calculate your paths, the user never sees them.

DoorKnobHandle

Oh, I get it... That's why he wrote:

Quote
...logically, not visually...

Thank you! That might be a good idea... I'll think about it!

RickJ

You could possibly use the RawDraw() functions to draw such tiles if you wanted to do that. 

SMF spam blocked by CleanTalk