Game Mechanics troubles with a rogue-like game

M

MRG

Guest
For a school project I'm making a rogue-like game based on the mobile game which is turn/gridbased
Unfortunately I'm having some problems with the changing of the turns and I'm wondering if anyone has some tips to make my game work. I've thought of a global variable or something to check if the player has moved. if anyone has ideas on this topic, please let me know.
(btw the grid is 32x32 and after each turn the enemies and player have to stand still)
 

NightFrost

Member
A simple solution would be a variable that tracks whose turn it is. When it says player's turn, the game does nothing but wait for player to pick an action. Every player action resolution would end with the code flipping the variable to indicate enemy turn. Once your code that handles enemy actions figures all enemies have acted once, the variable is flipped back to indicate player turn.

This all with the assumption that every action takes "one turn" to resolve. System with variable action speeds would be completely different.
 
M

MRG

Guest
A simple solution would be a variable that tracks whose turn it is. When it says player's turn, the game does nothing but wait for player to pick an action. Every player action resolution would end with the code flipping the variable to indicate enemy turn. Once your code that handles enemy actions figures all enemies have acted once, the variable is flipped back to indicate player turn.

This all with the assumption that every action takes "one turn" to resolve. System with variable action speeds would be completely different.
Thank you for this information, do you by any chance know how I should use such a variable?
 

Genetix

Member
Create a global variable like "current_turn" - Then with the player object, only allow actions (walk, attack, etc.) if current_turn = 0 (players turn)

With environment, enemies, npc's, etc.... Only allow their actions if current_turn = 1

Likely will need to utilize alarms or something when the turn is changed to tell objects that the turn is theirs and they can perform actions.
 

YanBG

Member
Right now for my open world RPG i use a global variable that is increased each time the player enters the next tile(or grid cell). You can divide it by 60 or 24 and use that for hours or days that have passed, in case there are timed events(e.g. you have to finish a quest in 3 days).
 

NazGhuL

NazTaiL
I use an object called obj_turn that hold a list of all id of instances that will perform an action this turn. The obj_turn then give a 'go' to the first one and wait a 'call_back' when its turn is done. obj_turn then send a 'go' to the second one and so on... When the list is empty obj_turn go the the next 'round' and calls every instance that can perform an action again, adding their id. Repeat...
 
Top