I’ve decided I’m making a roguelike game. As with most roguelikes, you only get 1 life.
First lesson: making a real time system work with turn-based code is not easy. Making a pixel-perfect system work with grid-based code is also not easy.
It seems as if my grid-based problems are solved with arrays, but this also carries the problem of doing movement animations of some kind a la the Mystery Dungeon series or Fire Emblem series. A delay to the player’s actions registering, for the length of the animation of the previous action, would work to allow me to do animations if I have time.
As far as making it turn-based… I think I’m going to go with a movement point allocation system. Basically, the player, and all enemies, have X delay points.
If the player has more delay than they have movement points available, they cannot take action. The game sees this, and allocates 1 movement point to each player and enemy. It then checks if the enemies can take a turn and takes available turns. It then checks player turn capability again; if the player is still not capable, then it continues allocating and checking turns until the player is capable.
Enemies will have higher delays than the player, so the player is taking, say, 1.5-2.5 turns for each 1 turn of an enemy. An ability that stops time, for example, would automatically give the player X number of movement points so they may act freely for a few actions without running out of movement points and therefore triggering enemy movements.
All actions that take a turn deplete movement points equal to the delay of the player/enemy doing it. The actions that count as taking a turn are meditating to restore ability points, checking the current square for items (looting and dropping items; “Nothing” is an item with no stats, and if an equipped item is swapped, that slot is unequipped), using an ability, or attempting to move (interacting with NPCs, walking into walls, and attacking enemies). Checking current inventory, saving the game, or switching equipped abilities do not count as taking a turn. Enemies treat other enemies, and NPCs, as walls for the purpose of movement.
This comes to my next problem: randomly generating dungeons. I will be using an array and a tileset, but I know next to nothing about procedural generation. I know I need to make a start room with a warp to the previous area, an end room with a warp to the next area, I need to create a dungeon maze that eventually connects the two, and I need to populate it with loot and monsters. The town will not be randomly generated.