Jump to content
  • Advertisement

Archived

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

DaJiangZhong

How to trace a sprite?

This topic is 5167 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!