So, I've been making a roguelike for a while, and I've just recently started thinking about the turn system. Right now, I have a very simple system. Every entity has a step() method. Every time a key is pressed, first the player's step method is called, then I loop through the enemies and npc's and call their step methods. This has worked fine so far, but it's a bit limited.

For example: Let's say we want the player to fire an arrow, and then every other entity waits until the arrow has hit something. This would not work with my system, because the enemies step right after the player steps. The other entities would step right as the arrow is fired, instead of waiting for it to hit something.

So, does anyone know of a method for timing a roguelike that is better than mine, but not too complex? Thanks!

One of the nice things is that most of the logic goes in the action, so it can be shared between player, npc and enemies easily. Shooting an arrow would be in a ShootArrowAction, and once it's created it works the same regardless of who actually shot it.

I'm not sure why the firing action isn't resolved in the player's step()? Is the arrow a separate entity? If so, then you probably need to prioritize the arrow's step() before anyone else. If you want to animate the arrow in steps, you should think of animation steps as separate from the simulation steps.

It essentially keeps a list of which events occur on each tick. When advanceTime() is called (For example, when the player moves, he might call advanceTime(5)), it cycles through each tick and calls whatever AI or Events need updating until it reaches the new tick. Unfortunately I need to leave for class now, but this should hopefully help point you in the right direction when creating your system.

I'm sure that there's improvements to be made here, as I've only been learning Java for a couple of months now, so just remember that this is probably not as well written as it could be.

You don't put missiles in the same system as player/monster turns in roguelikes (althrough it would be logical if you were making RPG). Missiles are instant things, these are part of display system, not game logic system. Players/monsters do their things. When one of the actions is fire a missile, you stop the execution of player turns (actually you don't have to stop anything since roguelikes are turn based) and display animation of missile moving around. When all animations are finished the player is allowed to press next button.

Also note that things will get hairy if you have various speed of monsters. In such case the typical solution is to move the entity (monster/player) with the highest remaining speed, when none of the entites have enough speed to move the speed is replenished by the base speed.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org