Пример #1
0
int getToken(char *s)
{
	if (isGameTitle(s)) return TOK_GAME_TITLE;

	if (isCheatCode(s)) return TOK_CHEAT_CODE;

	return TOK_CHEAT_DESC;
}
Пример #2
0
void InputEngine::controllerButtonDown(SDL_Event e, GameState state)
{
    if (state == GameState::PLAY || state == GameState::END)
    {
        if (inputs[e.cdevice.which] == nullptr || cameras[e.cdevice.which] == nullptr) return;

        if (e.cbutton.button == SDL_CONTROLLER_BUTTON_X)
        {
            inputs[e.cdevice.which]->shootPizza = true;
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_A)
        {
            inputs[e.cdevice.which]->handBrake = true;
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_B)
        {
            cameras[e.cdevice.which]->setReverseCam(true);
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK)
        {
            //unFucker();
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_Y)
        {
            inputs[e.cdevice.which]->jump = true;
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_START)
        {
            if (isCheatCode(e.cdevice.which))
            {
                space();
            }
            (state == GameState::PLAY) ? setGameState(GameState::PAUSE) : setGameState(GameState::BACK_TO_MENU);
        }

        pastInputs[e.cdevice.which][pastInputsIndex[e.cdevice.which]] = e.cbutton.button;
        pastInputsIndex[e.cdevice.which] = (pastInputsIndex[e.cdevice.which] + 1) % BUFFER_SIZE;
    }
    else if (state == GameState::MENU)
    {
        if (e.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
        {
            menuInput(InputType::UP);
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
        {
            menuInput(InputType::DOWN);
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
        {
            menuInput(InputType::LEFT);
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
        {
            menuInput(InputType::RIGHT);
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_A)
        {
            menuInput(InputType::ENTER);
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_B)
        {
            menuInput(InputType::BACK);
        }
    }
    else if (state == GameState::PAUSE)
    {
        if (e.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
        {
            pauseInput(InputType::UP);
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
        {
            pauseInput(InputType::DOWN);
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_A)
        {
            pauseInput(InputType::ENTER);
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_B)
        {
            pauseInput(InputType::BACK);
        }
        else if (e.cbutton.button == SDL_CONTROLLER_BUTTON_START)
        {
            pauseInput(InputType::BACK);
        }
    }
}