Exemplo n.º 1
0
    public static void Main(string[] args)
    {
        bool fullScreen = false;

        SdlHardware.Init(960, 750, 24, fullScreen);

        WelcomeScreen w = new WelcomeScreen();

        do
        {
            w.Run();
            if (w.GetChosenOption() == 1)
            {
                Game g = new Game();
                g.Run();
            }
            else if (w.GetChosenOption() == 2)
            {
                HelpScreen help = new HelpScreen();
                help.Run();
            }
            else if (w.GetChosenOption() == 3)
            {
                CreditsScreen credits = new CreditsScreen();
                credits.Run();
            }
        } while (w.GetChosenOption() != 4);
    }
Exemplo n.º 2
0
    public static void Main()
    {
        bool fullScreen = false;

        SdlHardware.Init(1024, 720, 24, fullScreen);

        WelcomeScreen w = new WelcomeScreen();

        do
        {
            w.Run();
            if (w.GetChosenOption() == 1)
            {
                Game g = new Game();
                g.Run();
            }
            else if (w.GetChosenOption() == 2)
            {
                CreditsScreen credits = new CreditsScreen();
                credits.Run();
            }
            else if (w.GetChosenOption() == 3)
            {
                HelpScreen help = new HelpScreen();
                help.Run();
            }
            else if (w.GetChosenOption() == 4)
            {
                ScoreBoard sb = new ScoreBoard();
                sb.Run();
            }
        } while (w.GetChosenOption() != 5);
    }
Exemplo n.º 3
0
    static void Main()
    {
        bool fullScreen = false;

        SdlHardware.Init(1024, 768, 24, fullScreen);

        WelcomeScreen w = new WelcomeScreen();

        do
        {
            w.Run();
            if (w.GetChosenOption() == WelcomeScreen.OPTION_PLAY)
            {
                Game g = new Game();
                g.Run();
            }
            else if (w.GetChosenOption() == WelcomeScreen.OPTION_HELP)
            {
                HelpScreen help = new HelpScreen();
                help.Run();
            }
            else if (w.GetChosenOption() == WelcomeScreen.OPTION_CREDITS)
            {
                CreditsScreen credits = new CreditsScreen();
                credits.Run();
            }
        }while (w.GetChosenOption() != WelcomeScreen.OPTION_QUIT);
    }
Exemplo n.º 4
0
    public static void Main(string[] args)
    {
        SdlHardware.Init(1024, 768, 24, false);

        int xShip       = 500;
        int xEnemy      = 400;
        int xEnemy2     = 200;
        int enemySpeed  = 5;
        int enemySpeed2 = -3;
        int finished    = 0;

        Image ship   = new Image("data/ship.png");
        Image enemy1 = new Image("data/enemy1a.png");
        Image enemy2 = new Image("data/enemy2a.png");

        do
        {
            // Draw elements
            SdlHardware.ClearScreen();
            SdlHardware.DrawHiddenImage(enemy1, xEnemy, 200);
            SdlHardware.DrawHiddenImage(enemy2, xEnemy2, 250);
            SdlHardware.DrawHiddenImage(ship, xShip, 500);
            SdlHardware.ShowHiddenScreen();

            // Process user input
            if (SdlHardware.KeyPressed(SdlHardware.KEY_ESC))
            {
                finished = 1;
            }
            if (SdlHardware.KeyPressed(SdlHardware.KEY_RIGHT))
            {
                xShip += 10;
            }
            if (SdlHardware.KeyPressed(SdlHardware.KEY_LEFT))
            {
                xShip -= 10;
            }

            // Update world
            if ((xEnemy <= 50) || (xEnemy >= 950))
            {
                enemySpeed = -enemySpeed;
            }
            xEnemy += enemySpeed;

            if ((xEnemy2 <= 50) || (xEnemy2 >= 950))
            {
                enemySpeed2 = -enemySpeed2;
            }
            xEnemy2 += enemySpeed2;

            // Check game status
            // (Not yet)

            // Pause until next frame
            SdlHardware.Pause(20);
        }while (finished == 0);
    }
Exemplo n.º 5
0
    public static void Run()
    {
        bool fullScreen = false;

        SdlHardware.Init(1024, 768, 24, fullScreen);
        Bienvenida b = new Bienvenida();

        b.Run();
        Instrucciones i = new Instrucciones();

        i.Run();
        MenuPartidas m = new MenuPartidas();

        m.Run();
    }
Exemplo n.º 6
0
    static void Main(string[] args)
    {
        bool fullScreen = false;

        SdlHardware.Init(640, 400, 24, fullScreen);
        Font font;

        font = new Font("data/Joystix.ttf", 12);

        MainMenu main = new MainMenu();
        Controls c    = new Controls();

        Controls.LoadControls();

        do
        {
            main.Run();


            if (main.GetChosenOption() == 1)
            {
                SdlHardware.Pause(20);
                SaveMenu newGame = new SaveMenu(new Player("data/adol.png"), true);
                newGame.Run();
                Game ys = new Game();
                ys.Run();
                SdlHardware.Pause(100);
            }
            else if (main.GetChosenOption() == 2)
            {
                SdlHardware.ClearScreen();
                SdlHardware.WriteHiddenText("Work in progress...",
                                            100, 200,
                                            0xC0, 0xC0, 0xC0,
                                            font);
                SdlHardware.ShowHiddenScreen();
                SdlHardware.Pause(2000);
            }
            else if (main.GetChosenOption() == 3)
            {
                ChangeControlsMenu change = new ChangeControlsMenu();
                change.Run();
                SdlHardware.Pause(100);
            }
        } while (main.GetChosenOption() != 4);
        Controls.SaveControls();
    }
Exemplo n.º 7
0
    static void Main()
    {
        bool fullScreen = false;

        SdlHardware.Init(1024, 700, 24, fullScreen);

        ChooseLanguage l = new ChooseLanguage();
        WelcomeScreen  w = new WelcomeScreen();

        do
        {
            if (l.GetChosenOption() == 0)
            {
                l.Run();
            }
            if (l.GetChosenOption() != 0)
            {
                w.Run();
                if (w.GetChosenOption() == 1)
                {
                    Game g = new Game();
                    g.Run();
                }
                else if (w.GetChosenOption() == 2)
                {
                    Controls controls = new Controls();
                    controls.Run();
                }
                else if (w.GetChosenOption() == 3)
                {
                    CreditsScreen credits = new CreditsScreen();
                    credits.Run();
                }
                else if (w.GetChosenOption() == 5)
                {
                    Tricks tricks = new Tricks();
                    tricks.Run();
                }
            }
        }while (w.GetChosenOption() != 4);
    }
Exemplo n.º 8
0
    static void Main()
    {
        Inicialize();

        SdlHardware.Init(1200, 768, 24, FullScreen);
        WelcomeScreen w = new WelcomeScreen();

        os = new OptionsScreen();
        LoadGamesScreen lg = new LoadGamesScreen();
        HelpScreen      hs = new HelpScreen();

        int option;

        do
        {
            option = w.Run();
            switch (option)
            {
            case 0: break;

            case 1: g = new Game();  g.Run();
                break;

            case 2:
                if (lg.Run() == 0)
                {
                    g.Run();
                }
                break;

            case 3: os.Run();
                SaveOptions();
                SdlHardware.Init(1200, 768, 24, FullScreen);
                break;

            case 4: hs.Run();
                break;
            }
        } while (option != 5);
    }
Exemplo n.º 9
0
    public static void Main(string[] args)
    {
        SdlHardware.Init(1280, 720, 24, false);

        LoadingScreen ls = new LoadingScreen();

        ls.Run();

        WelcomeScreen welcome = new WelcomeScreen();

        do
        {
            welcome.Run();
            if (welcome.GetChosenOption() == WelcomeScreen.OPTION_PLAY)
            {
                Game g = new Game();
                g.Run();
                EndScreen end = new EndScreen();
                end.Run();
            }
            else if (welcome.GetChosenOption() == WelcomeScreen.OPTION_HELP)
            {
                HelpScreen help = new HelpScreen();
                help.Run();
            }
            else if (welcome.GetChosenOption() == WelcomeScreen.OPTION_CREDITS)
            {
                CreditsScreen credits = new CreditsScreen();
                credits.Run();
            }
            else if (welcome.GetChosenOption() == WelcomeScreen.OPTION_CONFIG)
            {
                ConfigScreen config = new ConfigScreen();
                config.Run();
            }
        }while (welcome.GetChosenOption() != WelcomeScreen.OPTION_QUIT);
    }
Exemplo n.º 10
0
    public Saboteur()
    {
        bool fullScreen = false;

        SdlHardware.Init(1024, 768, 24, fullScreen);
    }
Exemplo n.º 11
0
    public static void Init()
    {
        bool fullScreen = false;

        SdlHardware.Init(800, 600, 24, fullScreen);

        dotImage       = new Image("data/dot.png");
        bigDotImage    = new Image("data/bigDot.png");
        enemyImage     = new Image[4];
        enemyImage[0]  = new Image("data/ghostGreen.png");
        enemyImage[1]  = new Image("data/ghostBlue.png");
        enemyImage[2]  = new Image("data/ghostRed.png");
        enemyImage[3]  = new Image("data/ghostPurple.png");
        enemyGreyImage = new Image("data/ghostGrey.png");
        pacImage       = new Image("data/pac01r.png");
        wallImage      = new Image("data/wall.png");

        sans18 = new Font("data/Joystix.ttf", 18);

        // Data for the dots
        // First: count how many dots are there
        amountOfDots = 0;
        for (int row = 0; row < 15; row++)
        {
            for (int column = 0; column < 17; column++)
            {
                if ((map[row][column] == '.') || (map[row][column] == 'o'))
                {
                    amountOfDots++;
                }
            }
        }
        dots = new Dot[amountOfDots];

        // Now, assign their coordinates
        int currentDot = 0;

        for (int row = 0; row < 15; row++)
        {
            for (int column = 0; column < 17; column++)
            {
                if ((map[row][column] == '.') || (map[row][column] == 'o'))
                {
                    dots[currentDot].x = column * 32;
                    dots[currentDot].y = row * 32;
                    if (map[row][column] == '.')
                    {
                        dots[currentDot].isBig = false;
                    }
                    else
                    {
                        dots[currentDot].isBig = true;
                    }
                    currentDot++;
                }
            }
        }

        // And enemies
        amountOfEnemies = 4;
        enemies         = new Enemy[amountOfEnemies];

        randomGenerator = new Random();
    }
Exemplo n.º 12
0
    public static void Main()
    {
        bool fullScreen = false;

        SdlHardware.Init(800, 600, 24, fullScreen);
        Image player    = new Image("barra.bmp");
        Image ball1     = new Image("pokeballorigin.bmp");
        Image ball2     = new Image("superballorigin.bmp");
        Image ball3     = new Image("ultraballorigin.bmp");
        Image ball4     = new Image("masterballorigin.bmp");
        Image ball5     = new Image("voltorborigin.bmp");
        Image ball6     = new Image("angryvoltorborigin.bmp");
        Image divisory  = new Image("divisoria.bmp");
        Image divisory2 = new Image("divisoria2.bmp");
        Image fruit     = new Image("ultraball.bmp");

        const int xa = 12, ya = 120;    //sizes of player
        const int axe = 20, aye = 20;   //sizes of ball
        int       x = 50;
        int       y = 300 - ya / 2;
        int       x2 = 750 - xa;
        int       y2 = 300 - ya / 2;
        int       score1 = 5, score2 = 5;
        int       divisoryX  = 400;
        int       divisory2Y = 40;

        int[]  fruitPosX1      = new int[score1];
        int[]  fruitPosX2      = new int[score2];
        int    amountOfEnemies = 1;
        Random generator       = new Random();

        float[] ballX = new float[amountOfEnemies];
        float[] ballY = new float[amountOfEnemies];
        for (int i = 0; i < amountOfEnemies; i++)
        {
            ballX[i] = x + xa;
            ballY[i] = y + ya / 2 - aye / 2;
        }

        int   speed      = 18;
        float ballSpeedX = 10f;
        float ballSpeedY = 10f;
        bool  finished   = false;
        bool  pause      = false;
        byte  moveType   = 1;


        // Game Loop
        do
        {
            // Update screen
            SdlHardware.ClearScreen();
            for (int i = 0; i < amountOfEnemies; i++)
            {
                if (ballSpeedX >= 30)
                {
                    SdlHardware.DrawHiddenImage(ball6, (int)ballX[i], (int)ballY[i]);
                }
                else if (ballSpeedX >= 26)
                {
                    SdlHardware.DrawHiddenImage(ball5, (int)ballX[i], (int)ballY[i]);
                }
                else if (ballSpeedX >= 22)
                {
                    SdlHardware.DrawHiddenImage(ball4, (int)ballX[i], (int)ballY[i]);
                }
                else if (ballSpeedX >= 18)
                {
                    SdlHardware.DrawHiddenImage(ball3, (int)ballX[i], (int)ballY[i]);
                }
                else if (ballSpeedX >= 14)
                {
                    SdlHardware.DrawHiddenImage(ball2, (int)ballX[i], (int)ballY[i]);
                }
                else if (ballSpeedX >= 10)
                {
                    SdlHardware.DrawHiddenImage(ball1, (int)ballX[i], (int)ballY[i]);
                }
                if (ballSpeedX <= -30)
                {
                    SdlHardware.DrawHiddenImage(ball6, (int)ballX[i], (int)ballY[i]);
                }
                else if (ballSpeedX <= -26)
                {
                    SdlHardware.DrawHiddenImage(ball5, (int)ballX[i], (int)ballY[i]);
                }
                else if (ballSpeedX <= -22)
                {
                    SdlHardware.DrawHiddenImage(ball4, (int)ballX[i], (int)ballY[i]);
                }
                else if (ballSpeedX <= -18)
                {
                    SdlHardware.DrawHiddenImage(ball3, (int)ballX[i], (int)ballY[i]);
                }
                else if (ballSpeedX <= -14)
                {
                    SdlHardware.DrawHiddenImage(ball2, (int)ballX[i], (int)ballY[i]);
                }
                else if (ballSpeedX <= -10)
                {
                    SdlHardware.DrawHiddenImage(ball1, (int)ballX[i], (int)ballY[i]);
                }
            }
            SdlHardware.DrawHiddenImage(player, x, y);
            SdlHardware.DrawHiddenImage(player, x2, y2);
            SdlHardware.DrawHiddenImage(divisory, divisoryX, 0);
            SdlHardware.DrawHiddenImage(divisory2, 0, divisory2Y);

            for (int i = 0; i < score1; i++)
            {
                fruitPosX1[i] = 32 * i;
                SdlHardware.DrawHiddenImage(fruit, fruitPosX1[i], 0);
            }

            for (int i = 0; i < score2; i++)
            {
                fruitPosX2[i] = 415 + 32 * i;
                SdlHardware.DrawHiddenImage(fruit, fruitPosX2[i], 0);
            }
            SdlHardware.ShowHiddenScreen();


            // Check input by the user
            //player 1
            if (SdlHardware.KeyPressed(SdlHardware.KEY_DOWN) && y2 < 600 - ya)
            {
                y2 += speed;
            }
            if (SdlHardware.KeyPressed(SdlHardware.KEY_UP) && y2 > 0)
            {
                y2 -= speed;
            }
            //player 2
            if (SdlHardware.KeyPressed(SdlHardware.KEY_S) && y < 600 - ya)
            {
                y += speed;
            }
            if (SdlHardware.KeyPressed(SdlHardware.KEY_W) && y > 0)
            {
                y -= speed;
            }



            if (SdlHardware.KeyPressed(SdlHardware.KEY_ESC))
            {
                finished = true;
            }
            if (SdlHardware.KeyPressed(SdlHardware.KEY_D) && moveType == 1)
            {
                moveType = 0;
            }
            if (SdlHardware.KeyPressed(SdlHardware.KEY_LEFT) && moveType == 2)
            {
                moveType = 3;
            }


            // Move enemies, background, etc
            if (moveType == 0)
            {
                ballX[0] += ballSpeedX;
                ballY[0] += ballSpeedY;
            }
            if (moveType == 3)
            {
                ballX[0] -= ballSpeedX;
                ballY[0] -= ballSpeedY;
            }

            else if (moveType == 1)
            {
                ballX[0] = x + xa;
                ballY[0] = y + ya / 2 - aye / 2;
            }
            else if (moveType == 2)
            {
                ballX[0] = x2 - axe;
                ballY[0] = y2 + ya / 2 - aye / 2;
            }


            // Check collisions and apply game logic
            // collision with player
            for (int i = 0; i < amountOfEnemies; i++)
            {
                if ((x + xa > ballX[i]) && (x + xa < ballX[i] + axe) &&
                    (y + ya > ballY[i]) && (y + ya < ballY[i] + aye) ||

                    (x + xa > ballX[i]) && (x + xa < ballX[i] + axe) &&
                    (y > ballY[i]) && (y < ballY[i] + aye) ||

                    (x > ballX[i]) && (x < ballX[i] + axe) &&
                    (y + ya > ballY[i]) && (y + ya < ballY[i] + aye) ||

                    (x > ballX[i]) && (x < ballX[i] + axe) &&
                    (y > ballY[i]) && (y < ballY[i] + aye))
                {
                    ballSpeedX = -ballSpeedX;
                    ballSpeedY = -ballSpeedY;
                }
            }
            // collision with walls
            for (int i = 0; i < amountOfEnemies; i++)
            {
                // collision with top and bottom
                if ((ballY[i] < 40) || (ballY[i] + aye > 600))
                {
                    ballSpeedY = -ballSpeedY;
                }
                // collision with players
                if ((ballX[i] < x + xa) && (ballY[i] > y) && (ballY[i] < y + ya) ||
                    (ballX[i] + axe > x2) && (ballY[i] > y2) && (ballY[i] < y2 + ya))
                {
                    ballSpeedX = -ballSpeedX;
                    if (ballSpeedX > 0)
                    {
                        ballSpeedX += 1f;
                        ballSpeedY += 1f;
                    }
                    else
                    {
                        ballSpeedX -= 1f;
                        ballSpeedY -= 1f;
                    }
                }
                // collision with sides (points)
                if (ballX[i] < 0) //Player 2 gets point
                {
                    score1--;
                    moveType   = 1;
                    ballSpeedX = 10f;
                    ballSpeedY = 10f;
                }
                else if (ballX[i] > 800) //Player 1 gets point
                {
                    score2--;
                    moveType   = 2;
                    ballSpeedX = 10f;
                    ballSpeedY = 10f;
                }
            }

            //Game over
            if (score1 == 0 || score2 == 0)
            {
                SdlHardware.Pause(4000);
                finished = true;
            }

            // Pause till next frame (40 ms = 25 fps)
            SdlHardware.Pause(40);
        }while (!finished);
        //Console.ReadLine();
    }