• entries
33
51
• views
12544

# Tricky Hackery

21 views

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 itOtherGameState A = new OtherGameState(params);m_StateMngr.push(A);//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...

There are no comments to display.

## Create an account

Register a new account