Archived

This topic is now archived and is closed to further replies.

DaJiangZhong

How to trace a sprite?

Recommended Posts

Recently,I have written a game that need to write method to let a sprite to trace another in a grid terrain(some grid coud move across,some coudn''t).The method have been written but it couldn''t run very well. Do you have some experence about this or you have some idea about this ?could you give me some advice? thanks alot.

Share this post


Link to post
Share on other sites
I have a hard time understanding your question, frankly, but are you talking about drawing a sprite on a tile-based map?

If so, which programming language are you using? And have you selected an API? (If you don''t know what API means, then I suggest looking up "GDI" in google; you should start by that).

Share this post


Link to post
Share on other sites
hi,RuneLancer:
quote:
Original post by RuneLancer
I have a hard time understanding your question, frankly, but are you talking about drawing a sprite on a tile-based map?


yes.I draw some sprites and roads on a tile-based map.Those sprites can move on the road.Then,I want to let a good-sprite trace the bad sprite until the good-sprite catch the bad ones.
I implements a trace algorithm but I fill not good so I serch help here.

Share this post


Link to post
Share on other sites
Oh! You mean you want to have the sprites chase each other? Ah, in that case I did misunderstand.

There are many ways to do this. The easiest is to have the predator take a step in the prey''s direction every frame. This isn''t very realistic though, and quickly becomes impossible to avoid unless there are obstacles that can get the predator stuck momentarily. In that case, the predator could easily just get jammed behind a wall.

You could also look up A* and use that to calculate the shortest route towards the prey. This''ll avoid cases where the predator would get stuck behind a wall.

You could also implant some "noise" every step so that the predator won''t always run directly at the prey, giving a more life-like movement.

Share this post


Link to post
Share on other sites
Yeah, I think trace would be ther wrong word here; it sounds like what the OP is looking for is a chase algorithm. You might want to google for Pacman AI, it might be useful. AFAIK, there are several different types of AI monsters in Pacman (some are aggressive, some try and cut you off, etc...) so that might help you in deciding what type of chasing tactics you''d like to use.

Share this post


Link to post
Share on other sites