• 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
Nausea

Game states?

11 posts in this topic

So this is a pretty simple question.

Since I would use game states for Intro, Menu, In-game etc.
Would I have a separate game state for every level in the game or just a "in-game" state which loads every level?

And if it´s just one game state, how would this work when you only want to load a level once it´s going to be used.
So you don´t load ten levels at the same time just to play the first level.

Thanks :)
0

Share this post


Link to post
Share on other sites
Typically an individual game state is one of several available methods for creating an interface between the user and the game's "hidden" persistent state.

For instance, for an RPG you're walking around on the world map and you hit the button to being up the menu. You change game states to do this. Once you're done checking your items you close the menu. Now if you were storing your player's position and etc in the map state then you're going to find a problem here since when closing the map state you lost all that information. (Unless you're using a stack-style state manager, which is something that was mentioned to me recently and sounds like it would be fun to try out.)

If you have a map class that encapsulates that information then you can use your map state to represent and interact with that information. Then when you close the menu you just switch back to the map state and it can pick up right where it left off because the map class object is part of the persistent state rather than the gamestate. Likewise, if you move to a new map your map state just fades the screen, replaces the current map class object, then fades the screen back in.

Having your game states clearly separated from the game's persistent state (this is why I call them 'scenes' instead of 'game states', lol) also makes it a lot easier to do things like saving and loading the game. All of the data that you would want to save or load will belong to the persistent state rather than the scene/gamestate.

Typically I assign the following responsibilities to a scene/gamestate:[list]
[*]load or acquire the graphics, audio and other resources required to represent the state
[*]react to user input
[*]provide the user with a means of affecting the persistent state (the menu scene gives an interface for changing the inventory, the map scene changes your location, etc)
[*]represent the persistent state in a meaningful way to the player using the audio/video/etc resources that were loaded
[*]perform logic, including trigger AI updates or trigger the update of any continual process in the game world, such as physics, etc (depending on the game type these things may be triggered outside for an un-pausable game)
[/list]
That's the general idea as I see it, anyway. This is a subject that I'm presently reviewing, however.

Hope that helps. Edited by Khatharr
2

Share this post


Link to post
Share on other sites
Several game states:

Well, a game state should hold all the game logic. The way you COULD do this is to have game state with sub states that are called like level1State, level2State etc. The problem here is that when doing level transitions I'm guessing you'd like something like "Now entering level 2" or something, and that is more like a menu state and when entering that state you will remove the game state which could cause problems. There are probably several ways to get around this as well, but I can't really think of one on the top of my head^^

One game state:

I guess you need something that indicates that you would load the next level. As you said, you don't want to load all levels at once. I can't really see what the problem here is since you just need to divide the logic on what to load and what to not load depending on what level the player is at. I'm just brain storming here, but you could have a class for each level and just create instances for each level when needed, I guess ^^

I'm not that good at programming and haven't used states yet, even if I know the basics concerning it.

Hope I was of any help ^^!
1

Share this post


Link to post
Share on other sites
Hi there! I'm also working on a state based engine and the way I'm doing it is that when I call my engine's ChangeState() function it accepts a gamestate object and an integer value as an argument ex: Function ChangeState( CgameState * state, Int i). each state can use this value how it wants. for example if I pass in the "in-game" state, I use the integer value to specify which level I want to load.The levels themselves are stored seperately as "level" objects, not as states. With this method, Loading/Switching to level 3 is as simple as calling Changestate(inGame,3). If you want to keep data that is constant between states, I would suggest creating a class that holds the game data. Whenever you load a new level you just read the data from the GameData class. I hope This helps :D
1

Share this post


Link to post
Share on other sites
Ok thank you all for your thoughts/tips. I will have to think about this some more before I go ahead and implement something. Thank you :)
0

Share this post


Link to post
Share on other sites
My [url="http://www.gamefromscratch.com/page/Game-from-Scratch-CPP-Edition-Part-2.aspx"]C++ tutorial series[/url] demonstrates exactly what you are describing. It uses game states to control transitions between Main Menu, Playing, etc.. It might be worth checking. The basics are shown in part two ( what I linked ), but involved upon as the tutorial progresses.
0

Share this post


Link to post
Share on other sites
I got another question now.
When I leave a state, for example a stage in the game, should I release the assets for the stage from my asset manager even if I would enter the stage again later? Edited by Nausea
0

Share this post


Link to post
Share on other sites
[quote name='Nausea' timestamp='1354309463' post='5005843']
I got another question now.
When I leave a state, for example a stage in the game, should I release the assets for the stage from my asset manager even if I would enter the stage again later?
[/quote]

That ultimately depends on you.
0

Share this post


Link to post
Share on other sites
[quote name='Nausea' timestamp='1354309463' post='5005843']
I got another question now.
When I leave a state, for example a stage in the game, should I release the assets for the stage from my asset manager even if I would enter the stage again later?
[/quote]

It depends. I believe you would want to release the state you're exiting, since all you want your state machine to do is create, enter, exit and release states. There is no meaning in keeping track of a state you're not currently in, in my opinion. However, you could also use back compatibility in several different situations. If you are in the game state and then presses the key that enters the menu state, of course you would like to be able to resume playing without having to restart the game.
0

Share this post


Link to post
Share on other sites
[quote name='PwFClockWise' timestamp='1354313395' post='5005862']
[quote name='Nausea' timestamp='1354309463' post='5005843']
I got another question now.
When I leave a state, for example a stage in the game, should I release the assets for the stage from my asset manager even if I would enter the stage again later?
[/quote]

It depends. I believe you would want to release the state you're exiting, since all you want your state machine to do is create, enter, exit and release states. There is no meaning in keeping track of a state you're not currently in, in my opinion. However, you could also use back compatibility in several different situations. If you are in the game state and then presses the key that enters the menu state, of course you would like to be able to resume playing without having to restart the game.
[/quote]

I guess I could do it for when a stage reaches "completed", when the game wont return to that stage at least at this time?
And for in-game menu etc I keep the other states assets.
0

Share this post


Link to post
Share on other sites
The answer to your first question is to use one state.

That state can load any level. Just pass a number to that state so that it knows which level to load.
I have outlined how states work here: [url="http://lspiroengine.com/?p=351"]General Game/Engine Structure[/url]
And how to pass data to them: [url="http://lspiroengine.com/?p=361"]Passing Data Between Game States[/url]


[quote name='Nausea' timestamp='1354309463' post='5005843']
I got another question now.
When I leave a state, for example a stage in the game, should I release the assets for the stage from my asset manager even if I would enter the stage again later?
[/quote]
Generally yes. If you know you are revisiting the same stage again, that usually only happens in special-case circumstances such as via the “Restart” pause-menu option. These cases can be handled by simply not leaving the current game state etc., so the general policy is to catch the most common cases that cause the same stage to be played again and handle them separately, while otherwise just unloading and loading on any other stage-change.


L. Spiro
2

Share this post


Link to post
Share on other sites
[quote name='L. Spiro' timestamp='1354314654' post='5005870']
The answer to your first question is to use one state.

That state can load any level. Just pass a number to that state so that it knows which level to load.
I have outlined how states work here: [url="http://lspiroengine.com/?p=351"]General Game/Engine Structure[/url]
And how to pass data to them: [url="http://lspiroengine.com/?p=361"]Passing Data Between Game States[/url]


[quote name='Nausea' timestamp='1354309463' post='5005843']
I got another question now.
When I leave a state, for example a stage in the game, should I release the assets for the stage from my asset manager even if I would enter the stage again later?
[/quote]
Generally yes. If you know you are revisiting the same stage again, that usually only happens in special-case circumstances such as via the “Restart” pause-menu option. These cases can be handled by simply not leaving the current game state etc., so the general policy is to catch the most common cases that cause the same stage to be played again and handle them separately, while otherwise just unloading and loading on any other stage-change.


L. Spiro
[/quote]

Thank you for the advice, been reading some of those blog posts. :)
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