Ejemplo n.º 1
0
    void UpdateScreen()
    {
        SdlHardware.ClearScreen();
        Groom.DrawOnHiddenScreen();

        Mcharacter.DrawOnHiddenScreen();

        SdlHardware.ShowHiddenScreen();
    }
Ejemplo n.º 2
0
    void CheckInput()
    {
        if (SdlHardware.KeyPressed(SdlHardware.KEY_D) && Mcharacter.GetX()
            >= Groom.MaxRight)
        {
            Groom.ActualCol++;
            Groom.UpdateScreenMap(Groom.ActualCol, Groom.ActualRow);
            Mcharacter.MoveTo(0, Mcharacter.GetY());
            Steps--;
        }
        else if (SdlHardware.KeyPressed(SdlHardware.KEY_D))
        {
            if (Groom.CanMoveTo(Mcharacter.GetX() + Mcharacter.GetSpeedX(),
                                Mcharacter.GetY(),
                                Mcharacter.GetX() + Mcharacter.GetWidth() +
                                Mcharacter.GetSpeedX(),
                                Mcharacter.GetY() + Mcharacter.GetHeight()))
            {
                Mcharacter.MoveRight();
                Steps--;
            }
            else
            {
                Mcharacter.NextFrame();
            }
            Mcharacter.ChangeDirection(Sprite.RIGHT);
        }
        else if (SdlHardware.KeyPressed(SdlHardware.KEY_A) &&
                 Mcharacter.GetX() <= 0)
        {
            Groom.ActualCol--;
            Groom.UpdateScreenMap(Groom.ActualCol, Groom.ActualRow);
            Mcharacter.MoveTo(Groom.MaxRight, Mcharacter.GetY());
            Steps--;
        }
        else if (SdlHardware.KeyPressed(SdlHardware.KEY_A))
        {
            if (Groom.CanMoveTo(Mcharacter.GetX() - Mcharacter.GetSpeedX(),
                                Mcharacter.GetY(),
                                Mcharacter.GetX() + Mcharacter.GetWidth() -
                                Mcharacter.GetSpeedX(),
                                Mcharacter.GetY() + Mcharacter.GetHeight()))
            {
                Mcharacter.MoveLeft();
                Steps--;
            }
            else
            {
                Mcharacter.NextFrame();
            }
            Mcharacter.ChangeDirection(Sprite.LEFT);
        }
        else if (SdlHardware.KeyPressed(SdlHardware.KEY_W) &&
                 Mcharacter.GetY() <= Groom.GetTopMargin())
        {
            Groom.ActualRow--;
            Groom.UpdateScreenMap(Groom.ActualCol, Groom.ActualRow);
            Mcharacter.MoveTo(Mcharacter.GetX(), Groom.MaxDown);
            Steps--;
        }
        else if (SdlHardware.KeyPressed(SdlHardware.KEY_W))
        {
            if (Groom.CanMoveTo(Mcharacter.GetX(),
                                Mcharacter.GetY() - Mcharacter.GetSpeedY(),
                                Mcharacter.GetX() + Mcharacter.GetWidth(),
                                Mcharacter.GetY() + Mcharacter.GetHeight() -
                                Mcharacter.GetSpeedY()))
            {
                Mcharacter.MoveUp();
                Steps--;
            }
            else
            {
                Mcharacter.NextFrame();
            }
            Mcharacter.ChangeDirection(Sprite.UP);
        }
        else if (SdlHardware.KeyPressed(SdlHardware.KEY_S) &&
                 Mcharacter.GetY() >= Groom.MaxDown)
        {
            Groom.ActualRow++;
            Groom.UpdateScreenMap(Groom.ActualCol, Groom.ActualRow);
            Mcharacter.MoveTo(Mcharacter.GetX(), Groom.GetTopMargin());
            Steps--;
        }
        else if (SdlHardware.KeyPressed(SdlHardware.KEY_S))
        {
            if (Groom.CanMoveTo(Mcharacter.GetX(),
                                Mcharacter.GetY() + Mcharacter.GetSpeedY(),
                                Mcharacter.GetX() + Mcharacter.GetWidth(),
                                Mcharacter.GetY() + Mcharacter.GetHeight() +
                                Mcharacter.GetSpeedY()))
            {
                Mcharacter.MoveDown();
                Steps--;
            }
            else
            {
                Mcharacter.NextFrame();
            }
            Mcharacter.ChangeDirection(Sprite.DOWN);
        }
        else if (SdlHardware.KeyPressed(SdlHardware.KEY_RETURN))
        {
            SdlHardware.Pause(100);
            foreach (Chest c in Groom.chests)
            {
                if (c.canInteractue(Mcharacter))
                {
                    c.Interactue(Mcharacter);
                }
            }
        }

        if (SdlHardware.KeyPressed(SdlHardware.KEY_I))
        {
            if (gm.Run(Groom, Mcharacter) == 5)
            {
                finished = true;
            }
        }
    }