Beispiel #1
0
void keyPressed (unsigned char key, int x, int y)
{  
    x = y;
    y = x;

    keyStates[key] = true; // Set the state of the current key to pressed  


    // Handle keyboard input
    if(key == 27)//ESC
    {
        cleanUp();
        exit(0);
    }
    else if(key == 61)//=
    {
        //increase time rate
        simConfig.timeRate *= 2;
        if(simConfig.timeRate > 65792)
            simConfig.timeRate = 65792;
    }
    else if(key == 45)//-
    {
        //decrease time rate
        simConfig.timeRate /= 2.0;
        if(simConfig.timeRate < 1)
            simConfig.timeRate = 1;
    }
    else if(key == 'r')//reset the puck position (CHEATING)
    {
        simConfig.gameData.resetPuck();
    }
    else if(key == '1')//cameras
    {
        simConfig.switchCamera(2);
    }
    else if(key == '2')//cameras
    {
        simConfig.switchCamera(0);
    }
    else if(key == '3')//cameras
    {
        simConfig.switchCamera(1);
    }
    else if(key == '5')//themes
    {
        simConfig.gameData.switchTheme(1);
    }
    else if(key == '6')//themes
    {
        simConfig.gameData.switchTheme(2);
    }
    else if(key == '7')//themes
    {
        simConfig.gameData.switchTheme(3);
    }
    else if(key == '8')//themes
    {
        simConfig.gameData.switchTheme(4);
    }
    else if(key == 'c')
    {
        simConfig.lightPerVertex = !simConfig.lightPerVertex;
    }
    else if(key == 'h')
    {
        simConfig.showDetails = !simConfig.showDetails;
    }
    else if(key == 'y')//lights
    {
        simConfig.worldLights->toggle(0);
    }
    else if(key == 'u')//lights
    {
        simConfig.worldLights->toggle(1);
    }
    else if(key == 'i')//lights
    {
        simConfig.worldLights->toggle(2);
    }
    else if(key == 'o')//lights
    {
        simConfig.worldLights->toggle(3);
    }
    else if(key == 'p')//lights
    {
        simConfig.worldLights->toggle(4);
    }
    //ai toggle
    else if(key == '[')
    {
        simConfig.gameData.enableAI(1);
    }
    //ai toggle
    else if(key == ']')
    {
        simConfig.gameData.enableAI(2);
    }
    else if(key == ' ')//space
    {
        //toggle pause
        if(recentlyPaused)
        {
           recentlyPaused = false;
        }
        else
        {
            recentlyPaused = true;
        }
    }
    else if(key == 13)
    {
        //start a new game
        simConfig.gameData.startGame();
    }
}  
Beispiel #2
0
void keyboard(unsigned char key, int x_pos, int y_pos)
{
    x_pos = y_pos;
    y_pos = x_pos;
    // Handle keyboard input
    if(key == 27)//ESC
    {
        cleanUp();
        exit(0);
    }
    else if(key == 61)//=
    {
        //increase time rate
        timeRate *= 2;
        if(timeRate > 65792)
            timeRate = 65792;
    }
    else if(key == 45)//-
    {
        //decrease time rate
        timeRate /= 2;
        if(timeRate < 1)
            timeRate = 1;
    }
    else if(key == 'h')
    {
        simConfig.showDetails = !simConfig.showDetails;
    }
    else if(key == '1')
    {
        simConfig.switchCamera(1);
    }
    else if(key == '2')
    {
        simConfig.switchCamera(2);
    }
    else if(key == '3')
    {
        simConfig.switchCamera(3);
    }
    else if(key == '4')
    {
        simConfig.switchCamera(4);
    }
    else if(key == '5')
    {
        simConfig.switchCamera(5);
    }
    else if(key == '6')
    {
        simConfig.switchCamera(6);
    }
    else if(key == '7')
    {
        simConfig.switchCamera(7);
    }
    else if(key == '8')
    {
        simConfig.switchCamera(8);
    }
    else if(key == '9')
    {
        simConfig.switchCamera(9);
    }
    else if(key == '0')
    {
        simConfig.switchCamera(0);
    }
    else if(key == ' ')//space
    {
        //toggle pause
        if(recentlyPaused)
           glutIdleFunc(update);
        else
        {
            recentlyPaused = true;
            glutIdleFunc(NULL);
        }
    }
}