1
\$\begingroup\$

Say I have the general engine working and the only thing missing is a story line.

Let's take the Pokemon games as an example: How would I implement surfing if I don't want to check wether the next tile is a water tile on every step I take? (I assume this would be horrible performance wise) The guards will let me pass once I have delivered some juice to them. How would this be done?

The second one should I should be able to implement with a state machine. Am I correct in understanding that a state machine is an enum(java) with my different states?

The other thing I am a little bit confused about is Events. For example how would I implement that if I step on a certain tile my character dies - again without checking this for EVERY tile I step on. I believe the tile would need to call some sort of Event that then kills my character. How should I write my "EventHandler"?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Please ask one question at a time. Also, checking conditions on every step does not sound bad at all, because it's only for one player. \$\endgroup\$ May 10, 2013 at 8:35

1 Answer 1

1
\$\begingroup\$
  1. Checking for next tile being water is not going to hurt your performance in any way. It takes very little computing power. Modern games operate with thousandfold amounts of data at 60 times per second, and your occasional checking of next tile is nothing.

  2. You can implement state machine in different ways. For example having a variable "isFirstPlayerTurn = 1" or having it at 0 is a state machine. You can use few or dozens of variables to describe certain state.

  3. You can use player (sprite, object, whatever you have) to handle this logic, just check on what tile you are standing once in a while (once a frame?) and if it is lava for example, perform function that kills player and resets game.

\$\endgroup\$

You must log in to answer this question.

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