Exemplo n.º 1
0
        /// <summary>
        /// Main Function, main acces point for the program
        /// </summary>
        public static void Main()
        {
            GameObjects.Polyhedra.Add(new A9(35));

            GameObjects.Polyhedra[0].Offset(new Vector(80, 80));
            //Open the game window
            SwinGame.OpenGraphicsWindow(Title + " v" + Version, 800, 600);

            //SwinGame.ToggleFullScreen();
            //SwinGame.ShowSwinGameSplashScreen();

            //Load the game assets
            GameResources.LoadResources();

            GameScores.Initalise();

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                InputController.ProcessMovement();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.Black);

                SwinGame.DrawFramerate(0, 0);

                if (SwinGame.KeyDown(KeyCode.vk_z))
                {
                    GameObjects.Polyhedra[0].Scale(1.01);
                }
                if (SwinGame.KeyDown(KeyCode.vk_x))
                {
                    GameObjects.Polyhedra[0].Scale(0.99);
                }


                //Update Game

                GameObjects.Draw(Color.Goldenrod, Color.DarkGoldenrod);

                tick++;

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }

            GameResources.FreeResources();
        }
        /// <summary>
        /// main
        /// the main entry point for the program
        /// </summary>
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow(Title + " v" + Version, 800, 600);

            GameResources.LoadResources();
            GameScores.Initalise();
            GameObjects.Player = new PlayerEntity(PlayerType.NarrowA);

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                RandomPlacementOfItems();

                SwinGame.ClearScreen(Color.Grey);
                SwinGame.DrawRectangle(Color.DarkGray, true, 40, 20, 460, 560);

                SwinGame.ProcessEvents();

                GameObjects.Player.ProcessEvents();

                foreach (ItemEntity item in GameObjects.Items)
                {
                    item.ProcessEvents();
                }

                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);

                SwinGame.DrawFramerate(0, 0);

                tick++;

                SwinGame.RefreshScreen(60);
            }
            GameResources.FreeResources();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Main Function, main acces point for the program
        /// </summary>
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow(Title + " v" + Version, 800, 600);

            //SwinGame.ToggleFullScreen();
            //SwinGame.ShowSwinGameSplashScreen();

            //Load the game assets
            GameResources.LoadResources();

            GameScores.Initalise();
            GameObjects.Initalise();

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested() && GameScores.Player != 0)
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.Grey);
                SwinGame.DrawRectangle(Color.DarkGray, true, 40, 20, 460, 560);


                SwinGame.DrawFramerate(0, 0);

                //Update Game
                GameObjects.ProcessEvents();

                RandomPlacementOfItems();

                tick++;
                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }

            GameResources.FreeResources();
        }
        /// <summary>
        /// ProcessEvents, overide method.
        /// </summary>
        public override void ProcessEvents()
        {
            //process item collisions
            if (GameObjects.Items != null)
            {
                for (int i = 0; i < GameObjects.Items.Count; ++i)
                {
                    if (GameObjects.Items[i].Colides(this))
                    {
                        switch (GameObjects.Items[i].ItemType.ToString())
                        {
                        case "BigPower":
                            for (int j = 0; j < 5; ++j)
                            {
                                GameScores.IncrementPower();
                            }
                            if (GameScores.Power < 128)
                            {
                                GameScores.Score += GameScores.Points[0];
                            }
                            else
                            {
                                GameScores.Score += GameScores.Points[GameScores.iterator];
                                for (int k = 0; k < 8; ++k)
                                {
                                    if (GameScores.iterator < 30)
                                    {
                                        GameScores.iterator++;
                                    }
                                }
                            }
                            break;

                        case "Bomb":
                            GameScores.Bomb++;
                            break;

                        case "FullPower":
                            for (int l = 0; l < 128; ++l)
                            {
                                GameScores.IncrementPower();
                            }
                            break;

                        case "Life":
                            GameScores.Player++;
                            break;

                        case "Point":
                            GameScores.Bonus++;
                            break;

                        case "Power":
                            GameScores.IncrementPower();
                            if (GameScores.Power < 128)
                            {
                                GameScores.Score += GameScores.Points[0];
                            }
                            else
                            {
                                GameScores.Score += GameScores.Points[GameScores.iterator];
                                if (GameScores.iterator < 30)
                                {
                                    GameScores.iterator++;
                                }
                            }
                            break;

                        case "Star":
                            GameScores.Score += 500 + (10 * (GameScores.Graze / 3));
                            break;
                        }
                        GameObjects.RemoveItem(GameObjects.Items[i]);
                    }
                }
            }

            PowerLevel();

            if (SwinGame.KeyDown(GameKeys.SHOOT))
            {
                MainCannon();
                AuxCannon();
            }

            ProcessMovement();

            foreach (BulletEntity bullet in _bullets)
            {
                bullet.ProcessEvents();
            }

            for (int i = 0; i < _bullets.Count; ++i)
            {
                if (_bullets[i].Y < 0)
                {
                    _bullets.Remove(_bullets[i]);
                }
            }

            DrawEntity();

            if (_auxLevel > 0)
            {
                SwinGame.DrawBitmap(GameResources.GameImage("YingYang" + (Tick % 64) / 8), (float)(X + 30) - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Width / 2), (float)Y - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Height / 2));
                SwinGame.DrawBitmap(GameResources.GameImage("YingYang" + (Tick % 64) / 8), (float)(X - 30) - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Width / 2), (float)Y - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Height / 2));
            }

            Tick++;
        }
Exemplo n.º 5
0
        public override void ProcessEvents()
        {
            //process item collisions
            if (GameObjects.Items != null)
            {
                for (int i = 0; i < GameObjects.Items.Count; ++i)
                {
                    if (GameObjects.Items[i].Colides(this))
                    {
                        switch (GameObjects.Items[i].ItemType.ToString())
                        {
                        case "BigPower":
                            for (int j = 0; j < 5; ++j)
                            {
                                GameScores.IncrementPower();
                            }
                            if (GameScores.Power < 128)
                            {
                                GameScores.Score += GameScores.Points[0];
                            }
                            else
                            {
                                GameScores.Score += GameScores.Points[GameScores.iterator];
                                for (int k = 0; k < 8; ++k)
                                {
                                    if (GameScores.iterator < 30)
                                    {
                                        GameScores.iterator++;
                                    }
                                }
                            }
                            break;

                        case "Bomb":
                            GameScores.Bomb++;
                            break;

                        case "FullPower":
                            for (int l = 0; l < 128; ++l)
                            {
                                GameScores.IncrementPower();
                            }
                            break;

                        case "Life":
                            GameScores.Player++;
                            break;

                        case "Point":
                            GameScores.Bonus++;
                            break;

                        case "Power":
                            GameScores.IncrementPower();
                            if (GameScores.Power < 128)
                            {
                                GameScores.Score += GameScores.Points[0];
                            }
                            else
                            {
                                GameScores.Score += GameScores.Points[GameScores.iterator];
                                if (GameScores.iterator < 30)
                                {
                                    GameScores.iterator++;
                                }
                            }
                            break;

                        case "Star":
                            GameScores.Score += 500 + (10 * (GameScores.Graze / 3));
                            break;
                        }
                        GameObjects.Items[i].Hitpoints = 0;
                    }
                }
            }

            foreach (BulletEntity bullet in GameObjects.Bullets)
            {
                if (bullet.Owner != this && bullet.Colides(this))
                {
                    Hitpoints       -= bullet.Hitpoints;
                    bullet.Hitpoints = 0;
                }
            }

            Level();

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

            if (SwinGame.KeyDown(GameKeys.BOMB) && GameScores.Bomb > 0 && _coolDown == 0)
            {
                foreach (BulletEntity bullet in GameObjects.Bullets)
                {
                    if (bullet.Owner != this)
                    {
                        GameObjects.AddItem(new ItemEntity(bullet.Position, ItemType.Star));
                        bullet.Hitpoints = 0;
                    }
                }

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

                GameScores.Bomb--;
                _coolDown = 60;
            }

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

            ProcessMovement();

            DrawEntity();

            if (_cannonAux > 0)
            {
                SwinGame.DrawBitmap(GameResources.GameImage("YingYang" + (Tick % 64) / 8), (float)(X + 30) - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Width / 2), (float)Y - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Height / 2));
                SwinGame.DrawBitmap(GameResources.GameImage("YingYang" + (Tick % 64) / 8), (float)(X - 30) - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Width / 2), (float)Y - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Height / 2));
            }

            Tick++;

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