Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   How do I toggle a button and Bind code to it? (http://www.go4expert.com/forums/i-toggle-button-bind-code-t16813/)

Leon8046 6Apr2009 14:26

How do I toggle a button and Bind code to it?
 
Hello! I apologize if this is the wrong forum :embarasse I was a little confused by the layout, sorry!

I would like to know if someone could look at my code and hopefully suggest a solution. I have been trying to apply a keyboard movement system (Like W S A D) to my game for 2 days now and no success. It's a simple system (not the best either)...

Code:

    if( GTH_CanMove()    &&    g_pApp->m_myCharacter->isAlive)
    {
        if( g_input->KeyEvent( DIK_NUMPAD8 ) )
        {
            g_pApp->m_myCharacter->event = GTH_EV_CHAR_MOUSERUN;
        }
        else if( g_input->KeyEvent( DIK_NUMPAD5 ) )
        {
            g_pApp->m_myCharacter->event = GTH_EV_CHAR_MOUSEWALK;
        }
        else if( g_input->KeyEvent( DIK_NUMPAD6 ) )
        {
            g_pApp->m_myCharacter->event = GTH_EV_CHAR_RUNRIGHT;
        }
        else if( g_input->KeyEvent( DIK_NUMPAD4 ) )
        {
            g_pApp->m_myCharacter->event = GTH_EV_CHAR_RUNLEFT;
        }
        else if( g_input->KeyEvent( DIK_NUMPAD3 ) )
        {
            g_pApp->m_myCharacter->event = GTH_EV_CHAR_WALKRIGHT;
        }
        else if( g_input->KeyEvent( DIK_NUMPAD1 ) )
        {
            g_pApp->m_myCharacter->event = GTH_EV_CHAR_WALKLEFT;
        }
        else
        {
        g_pApp->m_myCharacter->event = GTH_EV_CHAR_IDLE;
        }
}

This is how I have it at the moment, but if I am not moving that character is always IDLE, which unfortunately disabled point and click movement. My question is, Can I bind this code to a toggle key? say if I press F11 it will enable keyboard movement and disable mouse. If I press F11 again it will disable keyboard movement and enable mouse. Is this possible? or are there any other work arounds for this?

Any help would be much appreciated. If you would like to look at the code in more detail then please do not hesitate to ask :nice: Thank you!


All times are GMT +5.5. The time now is 02:32.