Story implementation

Hello JGO,

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”?

Thanks in advance,
Fr0zen

For events… Trigger objects.

You have a collision system, right? Just have invisible objects that, when collided, trigger the event in question.

This is exactly what first person games do, by the way, whenever an event is triggered, it is because you just crashed into an invisible object. So yes, map design ends up being similar to laying traps for players.

As for the guards and the juice, same thing. The guard triggers and event when collided, and that event checks if the character’s inventory contains the needed item. If it does, take the item away and move the guard.

And surfing… You do need to check what your character is standing on! How do you check if there’s a wall in the way? Same code you use for collisions can be used to determine what type of terrain the character is on.