ok well by state i just used the "offical" name for what you should be trying to achieve. most modern games are programmed using state machines, a state machine is basically a few states an object or game could be in. ie. for game, could be in menu-room_start-running-changing_room-loose_state-game_over
for they could be anything. and when you were in each state(just a variable named something like state, which stores its current state) would run code specific to that state eg. you dont need to have the same code acessible on a menu to what you need when the gameplay is actually running. so you put 2 different sets of codes inside the "if" or "switch" statement
so for our player object we would have:
//*create event*
state="start";
//put your other create code here
//*step event*
switch (state)
{
case "start": {
//put any start up code for the object
}; break;
case "running": {
//put all normal gameplay code
}; break;
case "bag": {
//put bag code
}; break;
case "dead": {
//put any dead code
}; break;
default: //put some backup code if your switch statement doesnt work;
}
//*draw event*
switch (state)
{
case "start": {
//draw start up code
}; break;
case "running": {
//draw player gameplay
}; break;
case "bag": {
//draw inventory
}; break;
case "dead": {
//draw death state
}; break;
default: //put some backup code if your switch statement doesnt work;
}
and then when you press B you just need to toggle the state to and from bag
you may want to use a state switch statement on other code areas like keyboard events or anything else
if you really need a full example i may have the time
ps. sorry if any of my code layout is wrong i just mocked it up
Edited by Jack Indie Box, 03 May 2012 - 01:39 PM.