• Advertisement
Sign in to follow this  

Input System

This topic is 1850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently working on project using sdl which uses a gamestate system.  


Here's some psuedo code of how it works right now:

    //SDL event loop ...

    case SDLK_m:
        changeState(STATE_MENU); //Changes the state which updates in manageState()


    //Makes sure we can delete the state, if so - delete it
    delete currentState;

        case STATE_MENU:
            currentState = new Menu();




What I am looking to do is for each state, which is represented by a class that inherits from the abstract base class of GameState, is for it to have its own event loop.  I was going to do it this way because the menu could have a totally different use for a key than the game itself.


The problem I'm running into is that I can't make a call to change the state from within that event loop.  I need to be able to change the state and destroy the object in GameEngine and create it again so the GameEngine render and update functions can call the currentState->Render and update functions.


There may be a simple solution for this but its been driving me nuts lately.  It is kind of difficult to explain so if you need further clarification I would be happy to do so.  Thanks for the help smile.png

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement