Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Tricky Hackery

Sign in to follow this  


General Update
Phew. Just saved myself from hitting the bottom of the journal list. Progress has been slow due to last minute running training and a spate of nights out with friends (yes the two do contradict each other in their goals)

I have wrote approximately 50% of the State Manager / States infrastructure however I've had a great idea and I'll need more time to investigate how to do it.

Procedurally Event-Driven

So I push a state on my stack, great. Now I come to pop it but where should execution continue? Well the obvious way is that it drops in to the state that pushed the last state on to the top and continues processing from the beginning. Wouldn't it be nice however if I could make it look a bit more procedural?

//Other State update code above

//Create a new state and push it
OtherGameState A = new OtherGameState(params);

//Code execution continues here when the state is popped

Which means I don't have to have States store State Status information. This could be bad though because what happens if a message is propagated down the stack and it hits this bit of code again, we could end up with an interesting order of execution.

There's two ways I could achieve that but the most obvious one is using recurssion and an event loop specific to the state.

m_StateMngr.push(A) would effectively call a function in the StateMngr called RunEventLoop() which works off the top state on the stack. Popping the state would drop it off and then it'd naturally drop down in to the state below's event loop. Mmm I like this idea...
Sign in to follow this  


Recommended Comments

There are no comments to display.

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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!