• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
ka0tix

Handling Turns in a Turn-Based Game

6 posts in this topic

A friend and I are making a turn based game, but I'm not entirely sure how to handle the turn system.

 

Basically we want to:

-Start the turn which opens a menu

-Allow the user to go through menus, buy things, sell things, etc.

-End turn

 

And I would like to be able to do this for multiple users. Any tips? Also, I searched for a topic like this one but couldn't find it, so if there is one please link it.

0

Share this post


Link to post
Share on other sites

Haven't made any progress so far. I'm not looking for actual code, just some ideas on how to structure the code.

 

So far, all I've really got is that it would make sense to write a function + helper functions which handle the actions. But I've never written anything like this, so I'm not sure exactly how or where to handle the actual turns. Should they be handled directly in the main loop, or should I deliberate the turns to a separate function?

 

I'm not too sure what to do here, so sorry if I seem a bit incoherent.

0

Share this post


Link to post
Share on other sites

Haven't made any progress so far. I'm not looking for actual code, just some ideas on how to structure the code.

 

So far, all I've really got is that it would make sense to write a function + helper functions which handle the actions. But I've never written anything like this, so I'm not sure exactly how or where to handle the actual turns. Should they be handled directly in the main loop, or should I deliberate the turns to a separate function?

 

I'm not too sure what to do here, so sorry if I seem a bit incoherent.

I think you should implement it. It will enrich your knowledge. What you do not know will hurt you. In fact, struggle with it and we can better help you if you show us what you have done. There is no one-way ticket to do things. It's programming! There are many ways you can implement it!

1

Share this post


Link to post
Share on other sites

I think you should implement it. It will enrich your knowledge. What you do not know will hurt you. In fact, struggle with it and we can better help you if you show us what you have done. There is no one-way ticket to do things. It's programming! There are many ways you can implement it!

 

I agree with warnexus.    I'm also building a turn based game and my first design was lets just say less than ideal.   But I learned a ton about how I really wanted my game to work.    Chances are at the stage it sounds like you are in your going to end up changing a few times away.

 

My recommendation would be to just map out what you want a player to be able to do on their turn.   Then build out those functions.    when you get to the point of advancing the turn chances are a few options will present themselves.

 

Maybe not the "best way" to go about design, but certainly one that will make you learn.    Plus as warnexus pointed out, once you actually have somethign going it will be easier for folks here to give "real" advice on direction.    Also I've found (as a hobby developer) if I spend too much time designing and not coding...its easy to get sidetracked with everything else in my life and not advance my project while I wait for "THE design"

0

Share this post


Link to post
Share on other sites

Here is how the game logic is structured in Goblinson Crusoe. It isn't exactly what you are looking for, but it might give you some things to think about.

 

1) At the beginning of the round, check to see if our turn-list is empty. If it is empty, pump out a request to all combat objects. The request is for a packet of information including:

a) Are you alive?

b) Are you interested in participating this round?

c) What is your faction?

 

2) Iterate the list returned from the request above. Check to see if there is at least one player-controlled object in the list. If not, it indicates a loss condition. Then, iterate and see if there is at least one hostile enemy combatant in the list. If not, it indicates a victory condition. Otherwise, continue.

 

3) Initiative determination. Compile a list of all participating combatants and, based on haste modifiers, roll for initiative. Insert them into a list sorted by order of their initiative rolls, re-rolling to break any ties as needed.

 

4) Check to see if we have a currently active object. If we don't, pull the next object off the turn list compiled above.

 

5) (If we have a new combatant)  Send the combatant a BeginCombatTurn message. This message in effect passes a "token" to the object, indicating that the object is free to move. If it is an AI controlled object, this pulls the AI out of its Wait state and into an Active state. If it is a player object, this passes a message to any linked UI components telling them to activate and show themselves. These UI components are "owned" by the object; that is, each player object has an instance of PlayerUI that is customized to their own individual settings and characteristics. (Siege machinery has a different UI than the player character, etc...) During BeginCombatTurn, the number of movement points to be allocated to the object is passed.

 

6) (If we already have an active combatant) Pass a CombatUpdate message. For Player objects, this merely checks to see if there is anything in the Command Queue for that object (list of steps to take, attacks to make, etc....) whereas for AI objects it checks to see if the command queue is empty and, if so, calls Think() on the AI controller. Think() will evaluate the current situation based on certain criteria, and attempt to come up with a reasonable set of commands to place in the queue.

 

7) While an object has movement points and chooses not to Pass, call CombatUpdate.

 

8) For Player characters, the UI is used to gather input and generate commands for the command queue. Any input action done while an object's UI is active is screened and tested for validity, then used to push commands onto the queue. UI generates a Move command? Call the pathfinder, validate the path, and push the steps onto the queue.

 

9) CombatUpdate checks the command queue, as indicated, and if there are pending actions it will pull an action off the queue and execute it. If it is a movement command, then TakeStep is called on the combatant controller to move the unit in the given direction. If it is a spell-cast command, then another sequence of steps are executed.

 

10) When CombatUpdate is called and the queue is empty, and the controller either elects to Pass or hasn't enough movement points to do anything, then the object will de-activate itself so that when, at step 4 above, we check to see if we have an active object, the answer will now be false and the scheduler will move on to the next object. At this point, pass the object an EndCombatTurn message. This de-activates any UI (for player objects) and places any AI controllers in a suspend state.

 

All of this continues in progression until step 2 indicates a victory/loss condition.

 

Basically, at heart, it's just a token-passing system. Pass the "Active" token to each object in turn, and when they are done with it hand it on down the line. Exactly how you structure this, though, is really dependent upon your game.

Edited by JTippetts
0

Share this post


Link to post
Share on other sites

Also I've found (as a hobby developer) if I spend too much time designing and not coding...its easy to get sidetracked with everything else in my life and not advance my project while I wait for "THE design"

 

Fortunately, the game is basically designed. It's nothing too complex, so we're pretty fortunate on that. Thanks for the advice, though. That's actually how I've begun to proceed.

 

Basically, at heart, it's just a token-passing system. Pass the "Active" token to each object in turn, and when they are done with it hand it on down the line. Exactly how you structure this, though, is really dependent upon your game.

 

Awesome, thank you! It's not exactly what I need for the type of game I'm making, but that definitely gives me a few ideas. I'll update later.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0