Beispiel #1
0
        public void RigidUpdate(GameTime gt)
        {
            //Update inputs.
            Input.Update();

            if (StaticValues.Close)
            {
                StaticValues.SaveHighscores();

                Exit();
            }

            //Update stars.
            stars.Update(cam);

            AnimationManager.Update(gt);

            //Update menus.
            mm.Update(cam, gt);

            if (StaticValues.Gamestate == 1)
            {
                cam.SetPos(0, 0);
            }

            if (TargetElapsedTime == TimeSpan.FromSeconds(1f / 240))
            {
                cam.SetPos(0, 0);
            }

            //Update old inputs.
            Input.OldUpdate();
        }
Beispiel #2
0
        public override void Function()
        {
            if (_text == "Start Game")
            {
                StaticValues.Gamestate = 1;
            }
            else if (_text == "High Scores")
            {
                StaticValues.Gamestate = 6;
                StaticValues.LoadHighscores();
            }
            else if (_text == "Options")
            {
                StaticValues.Gamestate = 5;
            }
            else if (_text == "Back to Main Menu")
            {
                StaticValues.Gamestate = 0;
            }
            else if (_text == "Unpause")
            {
                StaticValues.Gamestate = 1;
            }
            else if (_text == "Quit")
            {
                StaticValues.Close = true;
            }
            else if (_text == "Switch FPS Limit:")
            {
                StaticValues.fpsLimit++;
                if (StaticValues.fpsLimit > (StaticValues.fpsOptions.Length - 1))
                {
                    StaticValues.fpsLimit = 0;
                }
            }
            else if (_text == "Switch Resolution:")
            {
                StaticValues.currentRes++;
                if (StaticValues.currentRes > (StaticValues.res.Count - 1))
                {
                    StaticValues.currentRes = 0;
                }
            }
            else if (_text == "Restart")
            {
                StaticValues.reinit = true;
            }

            base.Function();
        }
Beispiel #3
0
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth  = 1280;
            graphics.PreferredBackBufferHeight = 720;
            graphics.IsFullScreen = false;

            IsFixedTimeStep = false;
            graphics.SynchronizeWithVerticalRetrace = true;
            graphics.ApplyChanges();

            StaticValues.LoadResolutions();
            StaticValues.LoadHighscores();

            IsMouseVisible = true;

            Content.RootDirectory = "Content";
        }
Beispiel #4
0
        public void Update(GameTime gt, ref Ship ship, ref List <Highscore> scores)
        {
            int num = 180 - (int)health;

            phase = (int)Math.Floor(num / 60.0) + 1;

            if (ai)
            {
                AI(gt, ref ship);
            }
            else if (intro)
            {
                Intro();
            }

            foreach (Missile missile in missiles)
            {
                missile.Update(ref ship);
            }

            for (int i = bullets.Count - 1; i >= 0; i--)
            {
                bullets[i].Update();

                if (bullets[i].hitbox.Intersects(ship.hitbox))
                {
                    ship.Damage(1);

                    bullets.RemoveAt(i);
                }
            }

            for (int i = ship.bullets.Count - 1; i >= 0; i--)
            {
                if (ship.bullets[i].hitbox.Intersects(hitbox))
                {
                    Damage(1);
                    ship.bullets.Remove(ship.bullets[i]);
                }
            }

            if (health <= 0)
            {
                AnimationManager.Play(hitbox.X, hitbox.Y + 64, "bigExplode");
                SoundManager.PlaySound("bigExplode");
                dead = true;

                scores.Add(new Highscore(10000000, (int)pos.X + 200, (int)pos.Y + 300));

                StaticValues.highscore += 10000000;

                StaticValues.SaveHighscores();
            }

            if (bbullet != null && bbullet.ready)
            {
                hole.Update(ref ship, gt);
            }

            base.Update();
        }