0
\$\begingroup\$

I am developing a tile based game to help improve my skills, there will be an entity spawning and following the player, to get around the various obstacles around the map i think that the best way would be for the entity to simply shadow the players movements.

What is the best way to store the players action e.g. jump, move left/right etc.

Would there be an alternative better way for the entity to hunt down the player?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Would a bog-standard pathfinding solution like A* not serve your needs here? \$\endgroup\$
    – DMGregory
    Commented Aug 18, 2017 at 0:01
  • \$\begingroup\$ Is "shadowing player" an essential part of your gameplay or do you simply want the entity to follow/chase player? \$\endgroup\$ Commented Aug 18, 2017 at 0:21
  • \$\begingroup\$ Too many possible ways to do this to get a single answer. \$\endgroup\$
    – Almo
    Commented Aug 18, 2017 at 14:00

1 Answer 1

1
\$\begingroup\$

Use the Command pattern and a circular or regular buffer.

The former encapsulates all the information you need to store a command (of your general design) as a single class instance, while the second allows you to limit the length of your history of commands so that you don't run out of memory.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .