Ejemplo n.º 1
0
        /// <summary>
        /// Processes game screen events.
        /// </summary>
        public override void ProvessEvents()
        {
            //Process user input.
            if (SwinGame.KeyTyped(Settings.DOWN))
            {
                if (Button("Unpause").Selected)
                {
                    Button("Quit").Select();
                    Button("Unpause").Deselect();
                }
            }

            if (SwinGame.KeyTyped(Settings.UP))
            {
                if (Button("Quit").Selected)
                {
                    Button("Unpause").Select();
                    Button("Quit").Deselect();
                }
            }

            if (SwinGame.KeyTyped(Settings.BOMB) || SwinGame.KeyTyped(Settings.PAUSE))
            {
                foreach (string btn in _buttonNames)
                {
                    Button(btn).Deselect();
                }
                Button("Quit").Select();
            }

            if (SwinGame.KeyTyped(Settings.SHOOT))
            {
                if (Button("Unpause").Selected)
                {
                    ScreenControler.SetScreen("TestLevel");
                    GameObjects.GameScreen("PauseMenu").Reset();
                }
                else if (Button("Quit").Selected)
                {
                    ScreenControler.SetScreen("StartupMenu");
                    GameObjects.GameScreen("PauseMenu").Reset();
                    GameObjects.GameScreen("TestLevel").Reset();
                    GameObjects.Initalise();
                }
            }
        }
Ejemplo n.º 2
0
        public override void Draw()
        {
            SwinGame.ClearScreen(Color.DarkSlateGray);

            GameObjects.DrawItems();
            GameObjects.DrawBullets();
            GameObjects.DrawPlayer();

            SwinGame.DrawBitmap(GameResources.GameImage("GameArea"), 0, 0);

            SwinGame.DrawText("Score: " + GameScores.SCORE, Color.Black, 540, 40);
            SwinGame.DrawText("Lives: " + GameScores.PLAYER, Color.Black, 540, 60);
            SwinGame.DrawText("Bombs: " + GameScores.BOMB, Color.Black, 540, 80);
            SwinGame.DrawText("Power: " + GameScores.POWER, Color.Black, 540, 120);
            SwinGame.DrawText("Graze: " + GameScores.GRAZE, Color.Black, 540, 140);
            SwinGame.DrawText("Bonus: " + GameScores.BONUS, Color.Black, 540, 160);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Main access point for the program.
        /// </summary>
        public static void Main()
        {
            //Open game window.
            SwinGame.OpenGraphicsWindow(_title + " v" + _version, 800, 600);

            //Load game assets.
            GameResources.LoadResources();
            GameObjects.LoadGameOjects();

            //Initaliase game assets.
            ScreenControler.SetScreen("StartupMenu");
            ScreenControler.Initalise();
            Settings.InitSettings();
            GameScores.InitForNewGame();

            //Show SwinGame splash screen.
            if (_splashFlag)
            {
                SwinGame.ToggleFullScreen();
                SwinGame.ShowSwinGameSplashScreen();
            }

            //Run game loop.
            while (!SwinGame.WindowCloseRequested() && !Settings.EXIT)
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();
                ScreenControler.Screen.ProvessEvents();

                //Draw Game
                ScreenControler.Screen.Draw();
                SwinGame.RefreshScreen(60);
            }

            //Free game assets.
            GameResources.FreeResources();
        }
Ejemplo n.º 4
0
        public override void ProvessEvents()
        {
            if (SwinGame.KeyTyped(Settings.PAUSE))
            {
                ScreenControler.SetScreen("PauseMenu");
            }

            for (int i = 0; i < 7; ++i)
            {
                if (Tick % (_triggers[i]) == 0)
                {
                    GameObjects.AddItem(new ItemEntity(new Point(_rand.Next() % (460 - GameResources.GameImage("Item" + _itemTypes[i].ToString()).Width) + 40, 50), _itemTypes[i]));
                }
            }

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 13; j++)
                {
                    if (Tick % (_rand.Next() % 50000 + 30) == 0 && Tick > 0)
                    {
                        Point position = new Point(_rand.Next() % 460 + 40, _rand.Next() % 460 + 40);
                        for (int k = 0; k < 12; k++)
                        {
                            GameObjects.AddBullet(new BulletEntity(_bulletColours[i], _bulletTypes[j], null, position, _trajectories[k]));
                        }
                    }
                }
            }

            GameObjects.ProcessItemEvents();
            GameObjects.ProcessBulletEvents();
            GameObjects.Player.ProcessEvents();

            NextTick();
        }
        private void Cannon()
        {
            switch (_playerType)
            {
            case PlayerType.NarrowA:
                switch (_cannonMain)
                {
                case 0:
                    if (Tick % 6 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Blue, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-90)) * 6, Math.Sin(BasicMath.ToRad(-90)) * 6)));
                    }
                    break;

                case 1:
                    if (Tick % 6 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Blue, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-92)) * 6, Math.Sin(BasicMath.ToRad(-92)) * 6)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Blue, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-88)) * 6, Math.Sin(BasicMath.ToRad(-88)) * 6)));
                    }
                    break;

                case 2:
                    if (Tick % 6 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Turquoise, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-94)) * 6, Math.Sin(BasicMath.ToRad(-94)) * 6)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Blue, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-90)) * 6, Math.Sin(BasicMath.ToRad(-90)) * 6)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Turquoise, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-86)) * 6, Math.Sin(BasicMath.ToRad(-86)) * 6)));
                    }
                    break;

                case 3:
                    if (Tick % 6 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Green, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-98)) * 6, Math.Sin(BasicMath.ToRad(-98)) * 6)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Turquoise, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-94)) * 6, Math.Sin(BasicMath.ToRad(-94)) * 6)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Blue, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-90)) * 6, Math.Sin(BasicMath.ToRad(-90)) * 6)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Turquoise, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-86)) * 6, Math.Sin(BasicMath.ToRad(-86)) * 6)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Green, BulletType.Seed, this, Hitbox.Middle, new Vector(Math.Cos(BasicMath.ToRad(-82)) * 6, Math.Sin(BasicMath.ToRad(-82)) * 6)));
                    }
                    break;
                }
                switch (_cannonAux)
                {
                case 1:
                    if (Tick % 24 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Purple, BulletType.Star, this, new Point(Hitbox.Middle.X + 32, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-90)) * 4, Math.Sin(BasicMath.ToRad(-90)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Purple, BulletType.Star, this, new Point(Hitbox.Middle.X - 32, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-90)) * 4, Math.Sin(BasicMath.ToRad(-90)) * 4)));
                    }
                    break;

                case 2:
                    if (Tick % 36 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Purple, BulletType.Star, this, new Point(Hitbox.Middle.X + 32, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-90)) * 4, Math.Sin(BasicMath.ToRad(-90)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Purple, BulletType.Star, this, new Point(Hitbox.Middle.X - 32, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-90)) * 4, Math.Sin(BasicMath.ToRad(-90)) * 4)));
                    }
                    if ((Tick + 18) % 36 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Red, BulletType.Star, this, new Point(Hitbox.Middle.X + 28, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-90)) * 4, Math.Sin(BasicMath.ToRad(-90)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Red, BulletType.Star, this, new Point(Hitbox.Middle.X - 28, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-90)) * 4, Math.Sin(BasicMath.ToRad(-90)) * 4)));
                    }
                    break;

                case 3:
                    if (Tick % 24 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Purple, BulletType.Star, this, new Point(Hitbox.Middle.X + 32, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-90)) * 4, Math.Sin(BasicMath.ToRad(-90)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Purple, BulletType.Star, this, new Point(Hitbox.Middle.X - 32, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-90)) * 4, Math.Sin(BasicMath.ToRad(-90)) * 4)));
                    }
                    if ((Tick + 12) % 24 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Red, BulletType.Star, this, new Point(Hitbox.Middle.X + 28, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-90)) * 4, Math.Sin(BasicMath.ToRad(-90)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Red, BulletType.Star, this, new Point(Hitbox.Middle.X - 28, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-90)) * 4, Math.Sin(BasicMath.ToRad(-90)) * 4)));
                    }
                    break;

                case 4:
                    if (Tick % 24 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Purple, BulletType.Star, this, new Point(Hitbox.Middle.X - 32, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-92)) * 4, Math.Sin(BasicMath.ToRad(-92)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Purple, BulletType.Star, this, new Point(Hitbox.Middle.X + 32, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-88)) * 4, Math.Sin(BasicMath.ToRad(-88)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Red, BulletType.Star, this, new Point(Hitbox.Middle.X + 32, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-92)) * 4, Math.Sin(BasicMath.ToRad(-92)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Red, BulletType.Star, this, new Point(Hitbox.Middle.X - 32, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-88)) * 4, Math.Sin(BasicMath.ToRad(-88)) * 4)));
                    }
                    if ((Tick + 12) % 24 == 0)
                    {
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Red, BulletType.Star, this, new Point(Hitbox.Middle.X - 28, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-92)) * 4, Math.Sin(BasicMath.ToRad(-92)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Red, BulletType.Star, this, new Point(Hitbox.Middle.X + 28, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-88)) * 4, Math.Sin(BasicMath.ToRad(-88)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Purple, BulletType.Star, this, new Point(Hitbox.Middle.X + 28, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-92)) * 4, Math.Sin(BasicMath.ToRad(-92)) * 4)));
                        GameObjects.AddBullet(new BulletEntity(BulletColour.Purple, BulletType.Star, this, new Point(Hitbox.Middle.X - 28, Hitbox.Middle.Y), new Vector(Math.Cos(BasicMath.ToRad(-88)) * 4, Math.Sin(BasicMath.ToRad(-88)) * 4)));
                    }
                    break;
                }
                break;

            case PlayerType.NarrowB:
                switch (_cannonMain)
                {
                case 0:
                    break;

                case 1:
                    break;

                case 2:
                    break;

                case 3:
                    break;
                }
                switch (_cannonAux)
                {
                case 1:
                    break;

                case 2:
                    break;

                case 3:
                    break;

                case 4:
                    break;
                }
                break;

            case PlayerType.WideA:
                switch (_cannonMain)
                {
                case 0:
                    break;

                case 1:
                    break;

                case 2:
                    break;

                case 3:
                    break;
                }
                switch (_cannonAux)
                {
                case 1:
                    break;

                case 2:
                    break;

                case 3:
                    break;

                case 4:
                    break;
                }
                break;

            case PlayerType.WideB:
                switch (_cannonMain)
                {
                case 0:
                    break;

                case 1:
                    break;

                case 2:
                    break;

                case 3:
                    break;
                }
                switch (_cannonAux)
                {
                case 1:
                    break;

                case 2:
                    break;

                case 3:
                    break;

                case 4:
                    break;
                }
                break;
            }
        }
        public override void ProcessEvents()
        {
            ProcessMovement();

            Level();

            if (SwinGame.KeyDown(Settings.SHOOT))
            {
                Cannon();
            }

            foreach (BulletEntity bullet in GameObjects.Bullets)
            {
                if (bullet.Owner != this)
                {
                    if (PolygonCollisions.Collides(_grazebox, bullet.Hitbox))
                    {
                        if (PolygonCollisions.Collides(Hitbox, bullet.Hitbox))
                        {
                            Hitpoints    -= bullet.Hitpoints;
                            bullet.Remove = true;
                            break;
                        }
                        if (!bullet.Grazed)
                        {
                            GameScores.GRAZE++;
                            bullet.Grazed = true;
                            break;
                        }
                    }
                }
            }

            if (SwinGame.KeyDown(Settings.BOMB) && GameScores.BOMB > 0 && _cooldown == 0)
            {
                foreach (BulletEntity bullet in GameObjects.Bullets)
                {
                    if (bullet.Owner != this)
                    {
                        GameObjects.AddItem(new ItemEntity(bullet.Hitbox.Middle, ItemType.Star));
                        bullet.Remove = true;
                    }
                }

                foreach (ItemEntity item in GameObjects.Items)
                {
                    item.Flag = true;
                }

                GameScores.BOMB--;
                _cooldown = 60;
            }

            if (Hitbox.Middle.Y < 160)
            {
                foreach (ItemEntity item in GameObjects.Items)
                {
                    item.Flag = true;
                }
            }

            if (_cooldown > 0)
            {
                _cooldown--;
            }

            Tick++;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Processes screen events.
        /// </summary>
        public override void ProvessEvents()
        {
            //Process user input.
            if (SwinGame.KeyTyped(Settings.DOWN))
            {
                if (Button("Shoot").Selected)
                {
                    Button("Bomb").Select();
                    Button("Shoot").Deselect();
                }
                else if (Button("Bomb").Selected)
                {
                    Button("Focus").Select();
                    Button("Bomb").Deselect();
                }
                else if (Button("Focus").Selected)
                {
                    Button("Pause").Select();
                    Button("Focus").Deselect();
                }
                else if (Button("Pause").Selected)
                {
                    Button("Up").Select();
                    Button("Pause").Deselect();
                }
                else if (Button("Up").Selected)
                {
                    Button("Down").Select();
                    Button("Up").Deselect();
                }
                else if (Button("Down").Selected)
                {
                    Button("Left").Select();
                    Button("Down").Deselect();
                }
                else if (Button("Left").Selected)
                {
                    Button("Right").Select();
                    Button("Left").Deselect();
                }
                else if (Button("Right").Selected)
                {
                    Button("Skip").Select();
                    Button("Right").Deselect();
                }
                else if (Button("Skip").Selected)
                {
                    Button("Quit").Select();
                    Button("Skip").Deselect();
                }
            }

            if (SwinGame.KeyTyped(Settings.UP))
            {
                if (Button("Bomb").Selected)
                {
                    Button("Shoot").Select();
                    Button("Bomb").Deselect();
                }
                else if (Button("Focus").Selected)
                {
                    Button("Bomb").Select();
                    Button("Focus").Deselect();
                }
                else if (Button("Pause").Selected)
                {
                    Button("Focus").Select();
                    Button("Pause").Deselect();
                }
                else if (Button("Up").Selected)
                {
                    Button("Pause").Select();
                    Button("Up").Deselect();
                }
                else if (Button("Down").Selected)
                {
                    Button("Up").Select();
                    Button("Down").Deselect();
                }
                else if (Button("Left").Selected)
                {
                    Button("Down").Select();
                    Button("Left").Deselect();
                }
                else if (Button("Right").Selected)
                {
                    Button("Left").Select();
                    Button("Right").Deselect();
                }
                else if (Button("Skip").Selected)
                {
                    Button("Right").Select();
                    Button("Skip").Deselect();
                }
                else if (Button("Quit").Selected)
                {
                    Button("Skip").Select();
                    Button("Quit").Deselect();
                }
            }

            if (SwinGame.KeyTyped(Settings.BOMB) || SwinGame.KeyTyped(Settings.PAUSE))
            {
                foreach (string btn in _buttonNames)
                {
                    Button(btn).Deselect();
                }
                Button("Quit").Select();
            }

            if (SwinGame.KeyTyped(Settings.SHOOT))
            {
                if (Button("Shoot").Selected)
                {
                }
                else if (Button("Bomb").Selected)
                {
                }
                else if (Button("Focus").Selected)
                {
                }
                else if (Button("Pause").Selected)
                {
                }
                else if (Button("Up").Selected)
                {
                }
                else if (Button("Down").Selected)
                {
                }
                else if (Button("Left").Selected)
                {
                }
                else if (Button("Right").Selected)
                {
                }
                else if (Button("Skip").Selected)
                {
                }
                else if (Button("Quit").Selected)
                {
                    ScreenControler.SetScreen("StartupMenu");
                    GameObjects.GameScreen("OptionsMenu").Reset();
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Processes game screen events.
        /// </summary>
        public override void ProvessEvents()
        {
            //Process user input.
            if (SwinGame.KeyTyped(Settings.DOWN))
            {
                if (Button("Demo").Selected)
                {
                    Button("Easy").Select();
                    Button("Demo").Deselect();
                }
                else if (Button("Easy").Selected)
                {
                    Button("Normal").Select();
                    Button("Easy").Deselect();
                }
                else if (Button("Normal").Selected)
                {
                    Button("Hard").Select();
                    Button("Normal").Deselect();
                }
                else if (Button("Hard").Selected)
                {
                    Button("Lunatic").Select();
                    Button("Hard").Deselect();
                }
                else if (Button("Lunatic").Selected)
                {
                    Button("Quit").Select();
                    Button("Lunatic").Deselect();
                }
            }

            if (SwinGame.KeyTyped(Settings.UP))
            {
                if (Button("Easy").Selected)
                {
                    Button("Demo").Select();
                    Button("Easy").Deselect();
                }
                else if (Button("Normal").Selected)
                {
                    Button("Easy").Select();
                    Button("Normal").Deselect();
                }
                else if (Button("Hard").Selected)
                {
                    Button("Normal").Select();
                    Button("Hard").Deselect();
                }
                else if (Button("Lunatic").Selected)
                {
                    Button("Hard").Select();
                    Button("Lunatic").Deselect();
                }
                else if (Button("Quit").Selected)
                {
                    Button("Lunatic").Select();
                    Button("Quit").Deselect();
                }
            }

            if (SwinGame.KeyTyped(Settings.BOMB) || SwinGame.KeyTyped(Settings.PAUSE))
            {
                foreach (string btn in _buttonNames)
                {
                    Button(btn).Deselect();
                }
                Button("Quit").Select();
            }

            if (SwinGame.KeyTyped(Settings.SHOOT))
            {
                if (Button("Demo").Selected)
                {
                    Settings.GAMEMODE = 0;
                    ScreenControler.SetScreen("TestLevel");
                    GameObjects.GameScreen("ModeSelect").Reset();
                }
                else if (Button("Easy").Selected)
                {
                    Settings.GAMEMODE = 1;
                    ScreenControler.SetScreen("PlayerSelect");
                    GameObjects.GameScreen("ModeSelect").Reset();
                }
                else if (Button("Normal").Selected)
                {
                    Settings.GAMEMODE = 2;
                    ScreenControler.SetScreen("PlayerSelect");
                    GameObjects.GameScreen("ModeSelect").Reset();
                }
                else if (Button("Hard").Selected)
                {
                    Settings.GAMEMODE = 3;
                    ScreenControler.SetScreen("PlayerSelect");
                    GameObjects.GameScreen("ModeSelect").Reset();
                }
                else if (Button("Lunatic").Selected)
                {
                    Settings.GAMEMODE = 4;
                    ScreenControler.SetScreen("PlayerSelect");
                    GameObjects.GameScreen("ModeSelect").Reset();
                }
                else if (Button("Quit").Selected)
                {
                    ScreenControler.SetScreen("StartupMenu");
                    GameObjects.GameScreen("ModeSelect").Reset();
                }
            }
        }