Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / States

Author
Message
Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 5th May 2010 23:15 Edited at: 5th May 2010 23:22
What exactly would be the best way to manage game states? From the Dark Invaders game that comes with Dark GDK he does the states like so:



Now I understand this and know that I could use it for my game but is it the most efficient or the "best" way to do it. Is anyone else doing this for there game or are there some better methods to get familiar with.
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 6th May 2010 10:24 Edited at: 8th May 2010 13:13
Hi Poof Master,

Over the years, I've developed a sorta programming template in which I build object classes with Prime Methods to Initialize, Factories(create/destroy instances), Update, and Shutdown. In fact, this technique allowed me to see value in OOP.

Most of my objects have states. For clarification, I refer to a object with states as entities. In your example, the `Game` is the Entity.

There can be more than one set of states for an Entity Class. Most of my Entity Classes have a set of Process States. Process states are used within the Update method in the main loop very similar to the snippet above.

Entity Class


States can be applied to entities of various size and purpose. Handling Entities with States come in handy especially, when your working with asynchronous loading times, network transfer, psuedo-threading, and more. You too may find yourself using a similar programming template for practically all your object classes.

Poof Master
14
Years of Service
User Offline
Joined: 14th Jan 2010
Location:
Posted: 7th May 2010 03:54
Hey Techlord,
Thanks for the response, always helpful. I am still a little new to programming so I'm having a little trouble understanding how I would implement this into my project. If you have time do you think you could give a simple example or even a link that could help me understand it better?
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 8th May 2010 13:11 Edited at: 8th May 2010 13:13
Poof Master, sometimes psudeo-code easier to understand then actual code. In this case, I'm presenting a programming methodology. Most programs have structure for initalization, update (main loop), and shutdown. You are just applying this structure to all objects within the program. Everything in your application can have states to include the application itself.



States are finite, have specific purpose, and are simple. You can store a `state` value in a integer variable and use a switch to select a block of code based on that variable. The process switch and states are usually located in update method and select blocks of code to run based on the process state. You can change the process state value anywhere by other methods.

Writing a Particle Engine would shed lots of light on this topic. I'll see what I can drum up.

Login to post a reply

Server time is: 2024-07-07 02:05:28
Your offset time is: 2024-07-07 02:05:28