A question of technique

Hi, y'all,
I'm going to admit my serious lack of experience here, but I need some help. I'm trying to use the PocketFrog Game framework to write a simple game. Although this isn't my first project using PocketFrog, it is more complicated than any of my others and I'm having trouble figuring out how to organize my code.
I think I understand the basics: Most of my processing should be done in GameLoop and I write functions for ButtonDown, ButtonUP, StylusDown, etc that reacts to the various inputs. That's all well and good.
However - My game is going to have different modes. For instance: Main menu, Introduction screen, Map displays, Information displays, Next Turn prompts, etc. How do I keep track of what mode I'm in and what my game should be doing at any particular time? Let me try to explain myself with an example:
If the game is in the main menu mode and the stylus is pressed on the screen, the game will need to decide if it was pressed inside of a menu item and respond appropriately.
However, if the game is displaying the introduction and the stylus is pressed on the screen, the display will need to change to the next screen in the introduction.
How do I handle the different modes in this situation? For instance, how do I get my StylusDown function to act according to the current game mode? I have thought of two solutions.
Solution 1: Have a variable that keeps track of the current mode and put a switch statement in my StylusDown function. Have the switch statement call other functions (like MainMenuStylusDown, IntroScreenStylusDown, etc.) to execute mode-specific code.
Solution 2: Create a CMode class with a virtual StylusDown function. Then I could derive specialized child classes (CMainMenu, CIntroScreen, etc) for each mode. I could then create a CMode pointer that points to the current game mode object and dynamically create game mode objects as they're needed. Then (assuming my CMode pointer is called pCurrentMode) in my main StylusDown function, I could just call pCurrentMode->StylusDown () to execute mode-specific code.
Solution 1 seems more intuitive and less likely to cause memory errors, but could make organizing my code difficult. I would need to have a separate StylusDown function for each mode. Extending this to the other input functions (StylusMove, ButtonDown, etc), there could be a real problem.
Solution 2 makes code organization fairly simple. I can put each mode class in its own source file. However, is the overhead of virtual functions something I need to worry about? Is this solution introducing more problems than it's fixing?
I guess I just need advice from someone wiser than I. What do the rest of you do in your games? If any of you can make sense of what I'm trying to ask, please help me.
Thanks.
I'm going to admit my serious lack of experience here, but I need some help. I'm trying to use the PocketFrog Game framework to write a simple game. Although this isn't my first project using PocketFrog, it is more complicated than any of my others and I'm having trouble figuring out how to organize my code.
I think I understand the basics: Most of my processing should be done in GameLoop and I write functions for ButtonDown, ButtonUP, StylusDown, etc that reacts to the various inputs. That's all well and good.
However - My game is going to have different modes. For instance: Main menu, Introduction screen, Map displays, Information displays, Next Turn prompts, etc. How do I keep track of what mode I'm in and what my game should be doing at any particular time? Let me try to explain myself with an example:
If the game is in the main menu mode and the stylus is pressed on the screen, the game will need to decide if it was pressed inside of a menu item and respond appropriately.
However, if the game is displaying the introduction and the stylus is pressed on the screen, the display will need to change to the next screen in the introduction.
How do I handle the different modes in this situation? For instance, how do I get my StylusDown function to act according to the current game mode? I have thought of two solutions.
Solution 1: Have a variable that keeps track of the current mode and put a switch statement in my StylusDown function. Have the switch statement call other functions (like MainMenuStylusDown, IntroScreenStylusDown, etc.) to execute mode-specific code.
Solution 2: Create a CMode class with a virtual StylusDown function. Then I could derive specialized child classes (CMainMenu, CIntroScreen, etc) for each mode. I could then create a CMode pointer that points to the current game mode object and dynamically create game mode objects as they're needed. Then (assuming my CMode pointer is called pCurrentMode) in my main StylusDown function, I could just call pCurrentMode->StylusDown () to execute mode-specific code.
Solution 1 seems more intuitive and less likely to cause memory errors, but could make organizing my code difficult. I would need to have a separate StylusDown function for each mode. Extending this to the other input functions (StylusMove, ButtonDown, etc), there could be a real problem.
Solution 2 makes code organization fairly simple. I can put each mode class in its own source file. However, is the overhead of virtual functions something I need to worry about? Is this solution introducing more problems than it's fixing?
I guess I just need advice from someone wiser than I. What do the rest of you do in your games? If any of you can make sense of what I'm trying to ask, please help me.
Thanks.