Hi,
I’m trying to put together a game that has the standard start-up logos, a title screen, the actual game, some sort of ranking screen, etc, but all the demos I’ve seen so far for Panda are basically just the gameplay running; I haven’t seem one with title screens, etc.
I’ve tried putting together a simple state manager like so:
class StateManager(DirectObject.DirectObject):
#states: logo, title, gameplay, ranking, scores
#constructor
def __init__(self):
#the first state the game is in is logo mode
self.state = "logo";
#so that updateState doesn't constantly update the scene
self.doUpdate = True;
taskMgr.add(self.updateState, "Update-State");
#update the game state every frame
def updateState(self, task):
#only do the update once per call to setGameState
if self.doUpdate:
#check which state the game is in and update accordingly
if self.state == "logo":
#do this
self.stateText = OnscreenText("Logo State", parent = render2d);
elif self.state == "title":
#do this
self.stateText = OnscreenText("Title State", parent = render2d);
elif self.state == "gameplay":
#do this
assert(True);
elif self.state == "ranking":
#do this
assert(True);
elif self.state == "scores":
#do this
assert(True);
self.doUpdate = False;
#continue this task
return Task.cont;
#set the game state
def setGameState(self, state = None):
self.state = state;
self.doUpdate = True;
#get the game state
def getGameState(self):
return self.state;
This is just a very bare minimum skeleton of a state manager, but does anyone have some suggestion as to where I go from here? I’m still not completely sure if this is the best way to achieve what I’m going for.
Also, does anyone have some examples/demos that show off menu/option screen/state functionality similar to this? I’m just a bit unsure as to how I should structure the program to achieve this.
Thanks!