Esempio n. 1
0
void GameScene::Update(void * params, Game * game)
{
    game->keyboard.UpdateState();

    if(game->keyboard.IsKeyPressed(SDLK_y))
        character.NextAnimation();

    if(game->keyboard.IsKeyPressed(SDLK_w))
        character.SetCurrentDirection(0);
    
    if(game->keyboard.IsKeyPressed(SDLK_s))
        character.SetCurrentDirection(1);

    if(game->keyboard.IsKeyPressed(SDLK_a))
        character.SetCurrentDirection(2);

    if(game->keyboard.IsKeyPressed(SDLK_d))
        character.SetCurrentDirection(3);
   
    if(game->keyboard.IsKeyDown(SDLK_q))
        game->Kill();

    if(game->keyboard.IsKeyPressed(SDLK_ESCAPE))
    {
        MainMenu * menu = new MainMenu();
        menu->AddMenuItem("Quit");
        menu->AddMenuItem("Continue");
        game->PushScene(menu);
    }

    if(game->keyboard.IsKeyDown(SDLK_RIGHT))
    {
        currentBackground.Move(-1.0f,0.0f);
        character.SetCurrentDirection(3);
        character.StepAnimation();
    }
    if(game->keyboard.IsKeyDown(SDLK_LEFT))
    {
        currentBackground.Move(1.0f,0.0f);
        character.SetCurrentDirection(2);
        character.StepAnimation();
    }
    if(game->keyboard.IsKeyDown(SDLK_UP))
    {
        currentBackground.Move(0.0f,1.0f);
        character.SetCurrentDirection(0);
        character.StepAnimation();
    }
    if(game->keyboard.IsKeyDown(SDLK_DOWN))
    {
        currentBackground.Move(0.0f,-1.0f);
        character.SetCurrentDirection(1);
        character.StepAnimation();
    }
}