Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (Statics.MANAGER_INPUT.IsKeyPressed(Keys.F12))
            {
                _graphics.ToggleFullScreen();
            }

            // Check the current game state
            switch (Statics.GAME_STATE)
            {
            case Statics.STATE.Exit:
            {
                Statics.GAME_CLOCK.Enabled = false;
                this.Exit();

                break;
            }

            case Statics.STATE.GameOver:
            {
                Statics.GAME_CLOCK.Enabled = false;
                SetBackgroundLayerScrolling(false);

                break;
            }

            case Statics.STATE.Loading:
            {
                Statics.GAME_CLOCK.Enabled = false;
                SetBackgroundLayerScrolling(true);

                break;
            }

            case Statics.STATE.Paused:
            {
                Statics.GAME_CLOCK.Enabled = false;
                SetBackgroundLayerScrolling(false);

                break;
            }

            case Statics.STATE.Playing:
            {
                if (!Statics.GAME_CLOCK.Enabled)
                {
                    Statics.GAME_CLOCK.Enabled = true;
                }

                Statics.GAME_GAMETIME = gameTime;
                SetBackgroundLayerScrolling(true);

                break;
            }
            }

            Statics.MANAGER_INPUT.Update();
            Statics.MANAGER_UI.Update();

            Statics.SCREEN_CURRENT.Update();

            Statics.MANAGER_SCREEN.Stack["Debug"].Update();

            Statics.GAME_BACKGROUND.Update();
            Statics.GAME_FOREGROUND.Update();

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        public void Update(GameTime gameTime, GraphicsDeviceManager graphics)
        {
            ctrl.setStates();

            if (ctrl.Select())
            {
                if (option == 0)
                {
                    BustinOutGame.setState(3, 1);
                    option   = 0;
                    position = arrowPosition;
                }
                else if (option == 1)
                {
                    if (isFullScreen == true)
                    {
                        isFullScreen = false;
                        screen       = graphicsScreen;
                        graphics.ToggleFullScreen();
                    }
                }
                else
                {
                    if (isFullScreen == false)
                    {
                        isFullScreen = true;
                        screen       = graphicsScreen2;
                        graphics.ToggleFullScreen();
                    }
                }
            }

            if (ctrl.Back())
            {
                BustinOutGame.setState(3, 1);
            }

            if (ctrl.Up())
            {
                if (option == 0)
                {
                    option = 1;
                }
                else
                {
                    option = 0;
                }

                setPosition();
            }

            if (ctrl.Down())
            {
                if (option == 1 || option == 2)
                {
                    option = 0;
                }
                else
                {
                    option = 1;
                }

                setPosition();
            }

            if (ctrl.Right() || ctrl.Left())
            {
                if (option == 1)
                {
                    option = 2;
                }
                else if (option == 2)
                {
                    option = 1;
                }

                setPosition();
            }
        }
Ejemplo n.º 3
0
        private void CheckInput()
        {
            if (GameState == GD327_Final_Project.GameState.Playing && _spaceship.IsVisible)
            {
                _movement = Vector2.Zero;

                if (_currentKeyboard.IsKeyDown(Keys.Left) && _spaceship.Position.X > 50)
                {
                    _movement -= Vector2.UnitX * .5f;
                }
                if (_currentKeyboard.IsKeyDown(Keys.Right) && _spaceship.Position.X < graphics.PreferredBackBufferWidth - 50)
                {
                    _movement += Vector2.UnitX * .5f;
                }
                if (_currentKeyboard.IsKeyDown(Keys.Up) && _spaceship.Position.Y > _halfScreenHeight + 100)
                {
                    _movement -= Vector2.UnitY * .5f;
                }
                if (_currentKeyboard.IsKeyDown(Keys.Down) && _spaceship.Position.Y < GraphicsDevice.Viewport.Height - _spaceship.Texture.Height / 2)
                {
                    _movement += Vector2.UnitY * .5f;
                }

                if (WasJustPressed(Keys.Space))
                {
                    Fire();
                }

                if (WasJustPressed(Keys.Escape))
                {
                    GameState = GD327_Final_Project.GameState.Title;
                }
            }
            else
            {
                if (WasJustPressed(Keys.Escape))
                {
                    Exit();
                }
            }
            if (WasJustPressed(Keys.F11))
            {
                graphics.ToggleFullScreen();
                graphics.ApplyChanges();
            }
            if (WasJustPressed(Keys.F10))
            {
                graphics.ToggleFullScreen();
                graphics.ApplyChanges();
            }
            if (WasJustPressed(Keys.Enter) && _allKeysReleased)
            {
                if (GameState == GameState.Playing)
                {
                    if (_currentKeyboard.IsKeyDown(Keys.RightShift))
                    {
                        _enemies.Clear();
                    }
                }
                else
                {
                    this.GameState = GD327_Final_Project.GameState.Playing;
                }
            }
        }
Ejemplo n.º 4
0
 public static void ToggleFullScreen(GraphicsDeviceManager graphics)
 {
     graphics.HardwareModeSwitch = false;
     graphics.ToggleFullScreen();
 }
Ejemplo n.º 5
0
        protected override void Update(GameTime gameTime)
        {
            // TODO: Add your update logic here

            // Save the previous state of the keyboard and game pad so we can determine single key/button presses
            previousGamePadState  = currentGamePadState;
            previousKeyboardState = currentKeyboardState;
            previousMouseState    = currentMouseState;

            // Read the current state of keyboard,gamepad,mouse
            currentKeyboardState = Keyboard.GetState();
            currentGamePadState  = GamePad.GetState(PlayerIndex.One);
            currentMouseState    = Mouse.GetState();

            // updates based on game state
            switch (currentstate)
            {
            case gamestate.MainMenu:
                break;

            case gamestate.Editor:
                editor.Update(currentMouseState);
                if (editor.testlevel)
                {
                    System.Diagnostics.Debug.Print("Testing started, editor fullscreen = " + editor.full + ", level fullscreen = " + level.full + ",editor.level fullscreen = " + editor.level.full);
                    editor.testlevel   = false;
                    currentstate       = gamestate.WaitingBall;
                    previousMouseState = currentMouseState;
                    level.number       = editor.level.number;
                    level.Load();
                }
                break;

            case gamestate.WaitingBall:
                UpdatePaddle(gameTime);
                UpdateBalls(gameTime);
                break;

            case gamestate.BallLaunched:
                UpdatePaddle(gameTime);
                UpdateBalls(gameTime);
                break;

            case gamestate.GameOver:
                break;
            }

            // Get keyboard input

            // fullscreen toggle
            // things to change
            // full variable in main, level, editor, editor.level
            // textures for background,blocks,paddle and balls in level and editor.level
            // positions for blocks, paddle and balls in level and editor.level
            // textures for cursor in level and editor.level

            if (currentKeyboardState.IsKeyDown(Keys.RightAlt) && currentKeyboardState.IsKeyDown(Keys.Enter) && previousKeyboardState.IsKeyUp(Keys.Enter))
            {
                //check the current screen mode
                if (graphics.IsFullScreen)
                {
                    //switch to windowed
                    // 16:9 ratio 960:540
                    // 4:3 ratio 640:512
                    full = false;
                    if (wide)
                    {
                        ChangeResolution(960, 540);
                    }
                    else
                    {
                        ChangeResolution(640, 512);
                    }
                }
                else
                {
                    //switch to fullscreen
                    // 16:9 ratio 1920:1080
                    // 4:3 ratio 1280:1024
                    full = true;
                    if (wide)
                    {
                        ChangeResolution(1920, 1080);
                    }
                    else
                    {
                        ChangeResolution(1280, 1024);
                    }
                }
                level.ChangeResolution(full, vwidth, vheight);
                editor.ChangeResolution(full, vwidth, vheight);
                graphics.ApplyChanges();
                graphics.ToggleFullScreen();
            }
            // Switch to Main Menu
            if (currentKeyboardState.IsKeyDown(Keys.F1) && previousKeyboardState.IsKeyUp(Keys.F1))
            {
                currentstate = gamestate.MainMenu;
            }
            // Switch to Level Editor
            if (currentKeyboardState.IsKeyDown(Keys.F2) && previousKeyboardState.IsKeyUp(Keys.F2))
            {
                currentstate = gamestate.Editor;
            }
            // Switch to Game
            if (currentKeyboardState.IsKeyDown(Keys.F3) && previousKeyboardState.IsKeyUp(Keys.F3))
            {
                currentstate = gamestate.WaitingBall;
            }
            // Exit Program
            if (currentKeyboardState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // Lock mouse to game window
            // if (currentMouseState.X < 0) Mouse.SetPosition(0, currentMouseState.Y);
            // if (currentMouseState.X > vwidth) Mouse.SetPosition(vwidth, currentMouseState.Y);
            // if (currentMouseState.Y < 0) Mouse.SetPosition(currentMouseState.X, 0);
            // if (currentMouseState.Y > vheight) Mouse.SetPosition(currentMouseState.X, vheight);

            // add ball on click
            if (currentMouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released)
            {
                if (currentstate == gamestate.WaitingBall)
                {
                    if (graphics.IsFullScreen)
                    {
                        newball = new GameObject(Color.Yellow, gamecontent.ball_lg,
                                                 new Vector2(r.Next(0, vwidth), vheight - gamecontent.ball_lg.Height * 5), new Vector2(r.Next(-7, 7), r.Next(-15, -10)));
                    }
                    else
                    {
                        newball = new GameObject(Color.Yellow, gamecontent.ball_sm,
                                                 new Vector2(r.Next(0, vwidth), vheight - gamecontent.ball_sm.Height * 5), new Vector2(r.Next(-7, 7), r.Next(-5, -3)));
                    }
                    newball.collide = true;
                    level.balls.Add(newball);
                    currentstate = gamestate.BallLaunched;
                }

                if (currentstate == gamestate.GameOver)
                {
                    ballsleft    = 5;
                    score        = 0;
                    currentstate = gamestate.WaitingBall;
                    level.Load();
                }
            }
            base.Update(gameTime);
        }
Ejemplo n.º 6
0
 public void FullScreen()
 {
     graphics.ToggleFullScreen();
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // TODO: Add your update logic here
            if (Graphics.FPS != FPS)
            {
                FPS = Graphics.FPS;
                this.TargetElapsedTime = new TimeSpan((long)Math.Pow(10, 7) / FPS);
            }

            // Fullscreen logic
            if (lastToggle < TOGGLE_TIME)
            {
                lastToggle += gameTime.ElapsedGameTime.Milliseconds;
            }
            if ((Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt) ||
                 Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightAlt)) &&
                Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter) &&
                lastToggle >= TOGGLE_TIME)
            {
                graphics.ToggleFullScreen();
                lastToggle = 0;
            }

            // Elmo
            sprite.X        += spriteXSpeed * (3 / 2);
            sprite.Y        += spriteYSpeed;
            sprite.Z         = viewport.Sprites.Count;
            sprite.Rotation += rotationSpeed * rotationDirection;
            if (sprite.X > Graphics.ScreenWidth)
            {
                spriteXSpeed *= -1;
            }
            if (spriteXSpeed < 0 && sprite.X < 1)
            {
                spriteXSpeed *= -1;
            }
            if (sprite.Y > Graphics.ScreenHeight)
            {
                spriteYSpeed *= -1;
            }
            if (spriteYSpeed < 0 && sprite.Y < 1)
            {
                spriteYSpeed *= -1;
            }

            if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt))
            {
                rotationSpeed += .0001;
            }
            if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl))
            {
                rotationSpeed -= .0001;
            }
            if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
            {
                spriteYSpeed -= 1;
            }
            if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
            {
                spriteYSpeed += 1;
            }
            if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left))
            {
                spriteXSpeed -= 1;
            }
            if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right))
            {
                spriteXSpeed += 1;
            }


            // Click detection
            lastMouseState    = currentMouseState;
            currentMouseState = Mouse.GetState();

            if (lastMouseState.LeftButton == ButtonState.Released && currentMouseState.LeftButton == ButtonState.Pressed)
            {
                //rotationDirection *= -1;
                // arrow keys to rotate, delete all sprites except elmo on click
                // viewport.Sprites.ForEach(sprite => sprite.ZoomX += 1);
                // viewport.Sprites.ForEach(WeirdBall => WeirdBall.Dispose());
                // viewport.Sprites.RemoveAll(is WeirdBall);
                // viewport.Sprites.RemoveAt(0);
                // if (viewport.Sprites.Count > 1) viewport.Sprites.RemoveRange(1, viewport.Sprites.Count - 1);
                // viewport.Sprites.Where(s => s is WeirdSprite).ForEach(s => s.Dispose())
                foreach (Sprite sprite in viewport.Sprites)
                {
                    if (sprite is WeirdBall)
                    {
                        sprite.Dispose();
                    }
                }
            }


            // Snake
            if (currentMouseState.LeftButton == ButtonState.Pressed)
            {
                WeirdBall ball = new WeirdBall(viewport);
                ball.X = Mouse.GetState().X;
                ball.Y = Mouse.GetState().Y;
                ball.Z = viewport.Sprites.Count;
            }

            viewport.Sprites.ForEach(sprite => sprite.Update());

            base.Update(gameTime);
        }
Ejemplo n.º 8
0
        protected override void Update(GameTime gameTime)
        {
            Window.Title = "The Sun Will Go Out";
            //Window.Title = "Pos x: " + player.position.X + " Pos y: " + player.position.Y;

            if (IsActive)
            {
                ControlManager.Update(gameTime);

                //Toggles fullscreen on/off
                if (ControlManager.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt) && ControlManager.CheckKeyPress(Keys.F))
                {
                    graphics.ToggleFullScreen();
                    graphics.ApplyChanges();
                }

                //Checks if the player should be used
                if (GameStateManager.currentState == "OverworldState" || GameStateManager.currentState == "System1State" ||
                    GameStateManager.currentState == "System2State" || GameStateManager.currentState == "System3State")
                {
                    player.IsUsed = true;
                }
                else
                {
                    player.IsUsed = false;
                }

                if (!Paused)
                {
                    if (player.IsUsed)
                    {
                        player.Update(gameTime);
                    }

                    stateManager.Update(gameTime);
                    missionManager.Update(gameTime);
                    tutorialManager.Update(gameTime);
                    shopManager.Update(gameTime);
                }

                else if (ZoomMap.IsMapOn)
                {
                    camera.CameraUpdate(gameTime, player);
                }

                soundEffectsManager.Update(gameTime);

                if (ControlManager.CheckPress(RebindableKeys.Map) &&
                    GameStateManager.currentState == "OverworldState" &&
                    !PopupHandler.IsMenuOpen)
                {
                    ZoomMap.ToggleMap();
                    soundEffectsManager.StopSoundEffect(SoundEffects.OverworldEngine);
                }

                if (ZoomMap.IsMapOn)
                {
                    ZoomMap.Update(gameTime, stateManager.overworldState.GetZoomObjects, camera);
                }

                popupHandler.Update(gameTime);
                helper.Update(gameTime);
                beaconMenu.Update(gameTime);

                fpsTimer -= gameTime.ElapsedGameTime.Milliseconds;
                if (fpsTimer <= 0)
                {
                    fps      = (float)Math.Round((1 / gameTime.ElapsedGameTime.TotalSeconds), 0);
                    fpsTimer = 250;
                }

                if (ControlManager.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt) &&
                    ControlManager.CheckKeyPress(Keys.M))
                {
                    musicManager.SwitchMusicMuted();
                }

                menuBGController.Update(gameTime);

                base.Update(gameTime);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
            lastState = state;
            state     = Keyboard.GetState();

            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (state.IsKeyDown(Keys.Q))
            {
                cursor.StartScale += 1.0f * elapsed;
            }
            if (state.IsKeyDown(Keys.A))
            {
                cursor.StartScale -= 1.0f * elapsed;
            }

            if (state.IsKeyDown(Keys.W))
            {
                cursor.EndScale += 1.0f * elapsed;
            }
            if (state.IsKeyDown(Keys.S))
            {
                cursor.EndScale -= 1.0f * elapsed;
            }

            if (state.IsKeyDown(Keys.E))
            {
                cursor.LerpExponent += 1.0f * elapsed;
            }
            if (state.IsKeyDown(Keys.D))
            {
                cursor.LerpExponent -= 1.0f * elapsed;
            }

            if (state.IsKeyDown(Keys.R))
            {
                cursor.BorderSize += 10.0f * elapsed;
            }
            if (state.IsKeyDown(Keys.F))
            {
                cursor.BorderSize -= 10.0f * elapsed;
            }

            if (state.IsKeyDown(Keys.T))
            {
                cursor.TrailStiffness += 1000.0f * elapsed;
            }
            if (state.IsKeyDown(Keys.G))
            {
                cursor.TrailStiffness -= 1000.0f * elapsed;
            }

            if (state.IsKeyDown(Keys.Y))
            {
                cursor.TrailDamping += 100.0f * elapsed;
            }
            if (state.IsKeyDown(Keys.H))
            {
                cursor.TrailDamping -= 100.0f * elapsed;
            }

            if (state.IsKeyDown(Keys.U))
            {
                cursor.TrailNodeMass += 1.0f * elapsed;
            }
            if (state.IsKeyDown(Keys.J))
            {
                cursor.TrailNodeMass -= 1.0f * elapsed;
            }

            if (state.IsKeyDown(Keys.F) && lastState.IsKeyUp(Keys.F))
            {
                graphics.ToggleFullScreen();
            }

            base.Update(gameTime);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            r        = new System.IO.StreamReader("exilania.ini");
            settings = new Settings(r);
            r.Close();
            // TODO: Add your initialization logic here
            if (!settings.use_custom_dimensions)
            {
                graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
                graphics.PreferredBackBufferWidth  = GraphicsDevice.DisplayMode.Width;
                screen_size = new Point(GraphicsDevice.DisplayMode.Width, GraphicsDevice.DisplayMode.Height);
            }
            else
            {
                try
                {
                    graphics.PreferredBackBufferHeight = settings.custom_height;
                    graphics.PreferredBackBufferWidth  = settings.custom_width;
                    screen_size = new Point(settings.custom_width, settings.custom_height);
                }
                catch
                {
                    graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
                    graphics.PreferredBackBufferWidth  = GraphicsDevice.DisplayMode.Width;
                    screen_size = new Point(GraphicsDevice.DisplayMode.Width, GraphicsDevice.DisplayMode.Height);
                }
            }
            graphics.ToggleFullScreen();
            GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
            graphics.ApplyChanges();
            screen_size = new Point(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
            try
            {
                System.IO.Directory.CreateDirectory(@"logs");
            }
            catch
            {
            }
            text_stream           = new System.IO.StreamWriter(@"logs/debug" + DateTime.Now.Ticks.ToString() + ".txt");
            text_stream.AutoFlush = true;
            text_stream.WriteLine("Open the document");

            block_types = new BlockManager();
            BlockData.enum_blocks();
            World.liquid_blocks = new int[] { 0, (int)block_types.get_block_by_name("Water") };
            //BlockData.export_block_data(block_types.blocks);
            item_manager             = new ItemManager();
            furniture_manager        = new FurnitureManager();
            plant_manager            = new PlantManager();
            material_manager         = new MaterialManager();
            crafting_manager         = new CraftManager();
            world_manager            = new WorldManager();
            world_definition_manager = new WorldCreator();
            particle_manager         = new ParticleManager();

            if (settings.use_seed)
            {
                rand = new Lidgren.Network.NetRandom(settings.seed_id);
            }
            else
            {
                rand = new Lidgren.Network.NetRandom((int)System.DateTime.Now.Ticks);
            }
            menu           = new MainMenu();
            body_templates = new List <BodyTemplate>();
            r = new System.IO.StreamReader("bodies.txt");
            while (!r.EndOfStream)
            {
                body_templates.Add(new BodyTemplate(r, body_templates.Count));
            }
            r.Close();
            saved_players = new SavedPlayers();
            draw_debug    = settings.debugging;
            seed_id       = (int)DateTime.Now.Ticks;
            if (settings.use_seed)
            {
                seed_id = settings.seed_id;
            }
            display.add_message(Display.color_code + "00Welcome to Exilania. Seed ID: " + seed_id.ToString());
            rand   = new Lidgren.Network.NetRandom(seed_id);
            sounds = new Sounds();

            //CubicSpline cs = new CubicSpline(new double[]{1,10,30,60,100},new double[]{1,2,5,9,13});
            CubicSpline cs         = new CubicSpline(new double[] { 0, 4, 10, 30, 100 }, new double[] { .05, .4, .7, 1, 1 });
            int         total_cost = 0;

            for (float i = 0; i < 100.1f; i += .5f)
            {
                total_cost += (int)cs.get_val_at(i);
                //Exilania.display.add_message("@05Cubic Spline[" + (i).ToString().PadLeft(3,'0') + "]:" + cs.get_val_at(i));
                //text_stream.WriteLine(Acc.sanitize_text_color(display.messages[display.messages.Count - 1]));
            }
            //Exilania.display.add_message("@06To get to level 100, you would need " + total_cost + " points.");

            base.Initialize();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            KeyboardState keyboard = Keyboard.GetState();

            if (keyboard.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // Fullscreen mode
            if (keyboard.IsKeyDown(Keys.F))
            {
                if (fPressed == false)
                {
                    fPressed = true;
                }

                // Change resolution depending on mode
                if (!graphics.IsFullScreen)
                {
                    graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                    graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                }
                else
                {
                    graphics.PreferredBackBufferWidth  = windowWidth;
                    graphics.PreferredBackBufferHeight = windowHeight;
                }

                graphics.ToggleFullScreen();
            }

            if (!gamePaused)
            {
                float milliseconds = gameTime.ElapsedGameTime.Milliseconds;

                // Camera Y rotation - A and D
                if (keyboard.IsKeyDown(Keys.A))
                {
                    cameraYaw -= cameraRotateSpeed * milliseconds;
                }
                else if (keyboard.IsKeyDown(Keys.D))
                {
                    cameraYaw += cameraRotateSpeed * milliseconds;
                }

                // Camera X rotation - W and S
                if (keyboard.IsKeyDown(Keys.W) && cameraPitch > minPitch)
                {
                    cameraPitch -= cameraRotateSpeed * milliseconds;
                }
                else if (keyboard.IsKeyDown(Keys.S) && cameraPitch < maxPitch)
                {
                    cameraPitch += cameraRotateSpeed * milliseconds;
                }

                Vector3 player1Velocity = Vector3.Zero;

                // Player 1 X movement - Right and Left arrow keys
                if (keyboard.IsKeyDown(Keys.Right) && player1.Position.X < boundingBoxScale.X - player1.Scale.X)
                {
                    player1Velocity.X = 1;
                }
                else if (keyboard.IsKeyDown(Keys.Left) && player1.Position.X > -boundingBoxScale.X + player1.Scale.X)
                {
                    player1Velocity.X = -1;
                }

                // Player 1 Y movement - Up and Down arrow keys
                if (keyboard.IsKeyDown(Keys.Up) && player1.Position.Y < boundingBoxScale.Y - player1.Scale.Y)
                {
                    player1Velocity.Y = 1;
                }
                else if (keyboard.IsKeyDown(Keys.Down) && player1.Position.Y > -boundingBoxScale.Y + player1.Scale.Y)
                {
                    player1Velocity.Y = -1;
                }

                float timePassed = milliseconds / 1000;

                if (player1Velocity != Vector3.Zero)
                {
                    player1Velocity = Vector3.Normalize(player1Velocity);
                }

                player1.Velocity = player1Velocity * humanSpeed;
                player1.Update(timePassed);

                bool hitPaddle = UpdateBall(timePassed);

                // Bounce ball off paddles
                if (hitPaddle)
                {
                    checkBallBounds();
                }

                // Move AI if ball moving towards it
                if (ball.Velocity.Z < 0)
                {
                    updateAI(timePassed);
                }

                // Crosshair follows ball
                crosshair.Position = ball.Position;
            }

            // To restart the game
            if (keyboard.IsKeyDown(Keys.Enter))
            {
                gamePaused   = false;
                player1Score = player2Score = 0;
                MediaPlayer.Stop();
                MediaPlayer.Play(backgroundSong);
            }

            base.Update(gameTime);
        }
Ejemplo n.º 12
0
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            MouseState mouse = Mouse.GetState();

            #region -Surbrillance & sélection-

            // Bouton Options
            if ((mouse.X >= boutonOptions.Position.X && mouse.X <= boutonOptions.Position.X + 200) &&
                (mouse.Y >= boutonOptions.Position.Y && mouse.Y <= boutonOptions.Position.Y + 100) && display)
            {
                survoloptions = true;
                if (mouse.LeftButton == ButtonState.Pressed)
                {
                    selectoptions = true;
                    survoloptions = false;                 // On désactive tous les boutons
                    display       = false;                 // et on affiche les nouveaux
                    displayopts   = true;
                    selectnouveau = false;
                    survolnouveau = false;
                    selectbonus   = false;
                    survolbonus   = false;
                    selectquitter = false;
                    survolquitter = false;
                    selectretour  = false;
                }
            }

            else
            {
                survoloptions = false;
            }



            // Bouton Nouveau Jeu
            if ((mouse.X >= boutonNouveauJeu.Position.X && mouse.X <= boutonNouveauJeu.Position.X + 200) &&
                (mouse.Y >= boutonNouveauJeu.Position.Y && mouse.Y <= boutonNouveauJeu.Position.Y + 100) && display) // sous-entendu display == true
            // si la souris rencontre le bouton, les booleens changent
            {                                                                                                        // ce qui draw les boutons dans la méthode Draw
                survolnouveau = true;
                if (mouse.LeftButton == ButtonState.Pressed)
                {
                    selectnouveau = true;
                    survolnouveau = false;
                }
                else
                {
                    selectnouveau = false;
                }
            }
            else
            {
                survolnouveau = false;
            }

            // Bouton Bonus
            if ((mouse.X >= boutonBonus.Position.X && mouse.X <= boutonBonus.Position.X + 200) &&
                (mouse.Y >= boutonBonus.Position.Y && mouse.Y <= boutonBonus.Position.Y + 100) && display)
            {
                survolbonus = true;
                if (mouse.LeftButton == ButtonState.Pressed)
                {
                    selectbonus = true;
                    survolbonus = false;
                }
                else
                {
                    selectbonus = false;
                }
            }

            else
            {
                survolbonus = false;
            }


            // Bouton Quitter
            if ((mouse.X >= boutonQuitter.Position.X && mouse.X <= boutonQuitter.Position.X + 200) &&
                (mouse.Y >= boutonQuitter.Position.Y && mouse.Y <= boutonQuitter.Position.Y + 100) && display)
            {
                survolquitter = true;
                if (mouse.LeftButton == ButtonState.Pressed)
                {
                    selectquitter = true;
                    survolquitter = false;
                }
                else
                {
                    selectquitter = false;
                }
            }

            else
            {
                survolquitter = false;
            }

            #endregion

            #region -Boutons des options-

            // Bouton Retour
            if ((mouse.X >= boutonRetour.Position.X && mouse.X <= boutonRetour.Position.X + 200) &&
                (mouse.Y >= boutonRetour.Position.Y && mouse.Y <= boutonRetour.Position.Y + 100) && displayopts)
            {
                survolretour = true;
                if (mouse.LeftButton == ButtonState.Pressed)
                {
                    selectoptions = false;
                    selectretour  = true;
                    survolretour  = false;
                    displayopts   = false;
                    display       = true;
                }
            }

            else
            {
                survolretour = false;
            }

            // Bouton Fenêtré
            if ((mouse.X >= boutonFenetre.Position.X && mouse.X <= boutonFenetre.Position.X + 200) &&
                (mouse.Y >= boutonFenetre.Position.Y && mouse.Y <= boutonFenetre.Position.Y + 100) && displayopts)
            {
                survolfenetre = true;
                if (mouse.LeftButton == ButtonState.Pressed)
                {
                    survolfenetre = false;
                    graphics.ToggleFullScreen();
                }
            }

            else
            {
                survolfenetre = false;
            }


            #endregion

            base.Update(gameTime);
        }
Ejemplo n.º 13
0
        } // LoadContent

        protected override void Update(GameTime gameTime)
        {
            keyboardstate = Keyboard.GetState();
            mousestate    = Mouse.GetState();

            // Allows the game to exit
            if (keyboardstate.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            if (keyboardstate.IsKeyDown(Keys.F5) && lastkeystate.IsKeyUp(Keys.F5))
            {
                graphics.ToggleFullScreen();
                graphics.ApplyChanges();
            }
            if (!mainThemePlaying && !nyancat.IsMoving())
            {
                mainTheme = soundbank.GetCue("mainTheme");
                mainTheme.Play();
                mainThemePlaying = true;
            }

            if (nyancat.IsMoving())
            {
                mainTheme.Stop(AudioStopOptions.AsAuthored);
                mainThemePlaying = false;
            }

            switch (gameState)
            {
            case GameState.Menu:
                menu.MoveOfforOnScreen(true);
                bow.update(gameTime, Content);
                HandleCollisions();
                nyancat.update(gameTime, soundbank);
                break;

            case GameState.Target:
                archeryTarget.update();
                menu.MoveOfforOnScreen(false);
                bow.update(gameTime, Content);
                HandleCollisions();
                nyancat.update(gameTime, soundbank);
                break;

            case GameState.Bear:
                menu.MoveOfforOnScreen(false);
                bearMode.update(gameTime, Content);
                bow.update(gameTime, Content);
                HandleCollisions();
                nyancat.update(gameTime, soundbank);
                break;

            case GameState.GameOver:

                if (firstGameOverpass)
                {
                    if (LoginForm.IsNewHighScore(username, bearMode.bearsKilled))
                    {
                        LoginForm.UpdateHighScore(username, bearMode.bearsKilled);
                        isHighScore = true;
                    }
                    firstGameOverpass = false;
                }
                if ((mousestate.LeftButton == ButtonState.Pressed) && (mousestate.X < 100 && mousestate.Y < 10))
                {
                    firstGameOverpass = true;
                    isHighScore       = false;
                    bearMode.reset();
                    gameState = GameState.Menu;
                    bow.resetArrows(Content);
                }
                break;

            case GameState.Login:
                loginForm.Update(gameTime.ElapsedGameTime.Ticks);
                LoggedIn = loginForm.Is_Logged_In();
                if (loginForm.IsDone())
                {
                    LoggedIn = loginForm.Is_Logged_In();
                    if (LoggedIn)
                    {
                        username = loginForm.GetUsername();
                    }
                    gameState = GameState.Menu;
                    loginForm = new LoginForm(Content);
                }
                break;
            }

            lastkeystate = keyboardstate;

            base.Update(gameTime);
        } // Update
Ejemplo n.º 14
0
        /** Controls:
         * Alt + Enter : Toggle full screen
         * Escape : Quit
         * Space : Generate noise
         * Tilde: clear
         * click: inject pixels (draw)
         * scroll: adjust draw size
         * 1: use game of life rules
         * 2: use high life rules
         * 3: use chaos seeds rules
         * 4: use day and night rules
         * 5: use rule 90
         */
        protected override void Update(GameTime gameTime)
        {
            keysl  = keysc; keysc = Keyboard.GetState();
            mousel = mousec; mousec = Mouse.GetState();

            if (keysc.IsKeyUp(Keys.Escape) && keysl.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            if ((keysc.IsKeyDown(Keys.LeftAlt) || keysc.IsKeyDown(Keys.RightAlt)) && (keysc.IsKeyDown(Keys.Enter) && keysl.IsKeyUp(Keys.Enter)))
            {
                if (graphics.IsFullScreen)
                {
                    graphics.PreferredBackBufferWidth  = defaultSize.X;
                    graphics.PreferredBackBufferHeight = defaultSize.Y;
                }
                else
                {
                    graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                    graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                }
                effect.Parameters["resolution"].SetValue(new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));
                resizeTextures();
                graphics.ToggleFullScreen();
            }

            if (keysc.IsKeyDown(Keys.Space) && keysl.IsKeyUp(Keys.Space))
            {
                DrawSplatter();
            }

            if (keysc.IsKeyDown(Keys.OemTilde) && keysl.IsKeyUp(Keys.OemTilde))
            {
                resizeTextures();
            }

            if (keysc.IsKeyDown(Keys.D1) && keysl.IsKeyUp(Keys.D1))
            {
                automation = Automation.gol;
            }

            if (keysc.IsKeyDown(Keys.D2) && keysl.IsKeyUp(Keys.D2))
            {
                automation = Automation.hl;
            }

            if (keysc.IsKeyDown(Keys.D3) && keysl.IsKeyUp(Keys.D3))
            {
                automation = Automation.cs;
            }

            if (keysc.IsKeyDown(Keys.D4) && keysl.IsKeyUp(Keys.D4))
            {
                automation = Automation.dan;
            }

            if (keysc.IsKeyDown(Keys.D5) && keysl.IsKeyUp(Keys.D5))
            {
                automation = Automation.r90;
            }

            int scrolldelta = mousec.ScrollWheelValue - mousel.ScrollWheelValue;

            if (scrolldelta != 0)
            {
                // dumb hack because .Net wont let a uint be incremented by an int.
                if (mousesize < 10)
                {
                    if (scrolldelta > 0)
                    {
                        mousesize++;
                    }
                    else
                    {
                        mousesize--;
                    }
                }
                else
                {
                    if (scrolldelta > 0)
                    {
                        mousesize = (uint)(((double)mousesize) * 1.2);
                    }
                    else
                    {
                        mousesize = (uint)(((double)mousesize) * 0.8);
                    }
                }

                mousesize = Math.Max(1, mousesize);
                mousesize = Math.Min(1000, mousesize);
            }

            base.Update(gameTime);
        }
Ejemplo n.º 15
0
        protected override void Update(GameTime gameTime)
        {
            kState = Keyboard.GetState();
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }


            if (kState.IsKeyDown(Keys.Left))
            {
                cam.Move(new Vector2(-2, 0));
            }
            if (kState.IsKeyDown(Keys.Right))
            {
                cam.Move(new Vector2(2, 0));
            }
            if (kState.IsKeyDown(Keys.Up))
            {
                cam.Move(new Vector2(0, -2));
            }
            if (kState.IsKeyDown(Keys.Down))
            {
                cam.Move(new Vector2(0, 2));
            }

            if (kState.IsKeyDown(Keys.D))
            {
                block.Move(1, 0);
            }
            if (kState.IsKeyDown(Keys.A))
            {
                block.Move(-1, 0);
            }
            if (kState.IsKeyDown(Keys.W))
            {
                block.Move(0, -1);
            }
            if (kState.IsKeyDown(Keys.S))
            {
                block.Move(0, 1);
            }

            if (kState.IsKeyDown(Keys.Enter))
            {
                graphics.ToggleFullScreen();
                AdjustResolution();
                graphics.ApplyChanges();
            }

            if (kState.IsKeyDown(Keys.NumPad8))
            {
                cam.ZoomIn();
            }
            if (kState.IsKeyDown(Keys.NumPad2))
            {
                cam.ZoomOut();
            }

            cam.Update(gameTime, Mouse.GetState());
            base.Update(gameTime);
        }
Ejemplo n.º 16
0
        //nothing much to see here, typical XNA initialization code
        public FlxFactory()
        {
            //Read the GAMESETTINGS.txt file

            /*
             * string gameSettings = File.ReadAllText("GAMESETTINGS.txt");
             * string[] splitter = gameSettings.Split('\n');
             * //Console.WriteLine(splitter[0]);
             *
             * FlxG.resolutionWidth = Convert.ToInt32(splitter[0].Substring(2));
             * FlxG.resolutionHeight = Convert.ToInt32(splitter[1].Substring(2));
             * if (splitter[2].Substring(11).StartsWith("1"))
             *  FlxG.fullscreen = true;
             * FlxG.zoom = Convert.ToInt32(splitter[3].Substring(5));
             */
            int div = 3;

            FlxG.zoom = 1;

#if !DEBUG
            FlxG.zoom       = 3;
            div             = 1;
            FlxG.fullscreen = true;
#endif
            FlxG.resolutionWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width / div;
            FlxG.resolutionHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / div;



            //set up the graphics device and the content manager
            _graphics             = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            if (FlxG.fullscreen)
            {
                //resX = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                //resY = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                if (GraphicsAdapter.DefaultAdapter.IsWideScreen)
                {
                    //if user has it set to widescreen, let's make sure this
                    //is ACTUALLY a widescreen resolution.
                    if (((FlxG.resolutionWidth / 16) * 9) != FlxG.resolutionHeight)
                    {
                        FlxG.resolutionWidth = (FlxG.resolutionHeight / 9) * 16;
                    }
                }
            }

            //we don't need no new-fangled pixel processing
            //in our retro engine!
            _graphics.PreferMultiSampling = false;
            //set preferred screen resolution. This is NOT
            //the same thing as the game's actual resolution.
            _graphics.PreferredBackBufferWidth  = FlxG.resolutionWidth;
            _graphics.PreferredBackBufferHeight = FlxG.resolutionHeight;
            //make sure we're actually running fullscreen if
            //fullscreen preference is set.
            if (FlxG.fullscreen && _graphics.IsFullScreen == false)
            {
                _graphics.ToggleFullScreen();
            }
            _graphics.ApplyChanges();

            Console.WriteLine("Running Game at Settings: {0}x{1}\nFullscreen?: {2}\nPreferrred: {3}x{4}", FlxG.resolutionWidth, FlxG.resolutionHeight, FlxG.fullscreen, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);

            FlxG.Game = this;
#if !WINDOWS_PHONE
            //Components.Add(new GamerServicesComponent(this));
#endif
        }
Ejemplo n.º 17
0
        public void ToggleFullScreen()
        {
            if (IsFullScreen && GameState == Enums.EGameState.HotButtonEditMode)
            {
                TextCue.AddClientInfoTextCue("Please exit Hot Button Edit Mode before switching from full screen.",
                                             TextCue.TextCueTag.None, Color.Red, Color.Black, 255, 2000, false, false, true);
                return;
            }

            PresentationParameters presentation = m_graphics.GraphicsDevice.PresentationParameters;

            presentation.HardwareModeSwitch = true;

            m_prevClientBounds = Window.ClientBounds;

            if (presentation.IsFullScreen)
            {
                m_graphics.PreferredBackBufferWidth  = m_preferredWindowWidth;
                m_graphics.PreferredBackBufferHeight = m_preferredWindowHeight;

                m_isFullScreen = false;

                //try { Window.IsBorderless = true; }
                //catch (NotImplementedException) { }
            }
            else
            {
                // going fullscreen, use desktop resolution to minimize display mode changes
                // this also has the nice effect of working around some displays that lie about
                // supporting 1280x720
                GraphicsAdapter adapter = m_graphics.GraphicsDevice.Adapter;//CreationParameters.Adapter;

                m_graphics.PreferredBackBufferWidth  = adapter.CurrentDisplayMode.Width;
                m_graphics.PreferredBackBufferHeight = adapter.CurrentDisplayMode.Height;

                m_prevClientPosition = Window.Position;

                m_isFullScreen = true;

                //try { Window.IsBorderless = false; }
                //catch (NotImplementedException) { }
            }

            m_graphics.ToggleFullScreen();

            if (!m_isFullScreen && m_prevClientPosition != null) // not working properly
            {
                Window.Position = m_prevClientPosition;
            }

            UserSettings.FullScreen = m_graphics.IsFullScreen;

            m_nowClientBounds = Window.ClientBounds;

            OnClientResize();

            // to correct issue with top 20 pixels inaccessible after first full screen toggle
            if (m_graphics.IsFullScreen && m_firstFullScreen)
            {
                m_noDraw          = true;
                m_firstFullScreen = false;
                ToggleFullScreen();
                ToggleFullScreen();
                m_noDraw = false;
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Handles input for quitting the game.
        /// </summary>
        private void HandleInput(GameTime gameTime)
        {
            // Handle input
            float         elapsedTime   = (float)gameTime.ElapsedGameTime.TotalSeconds;
            KeyboardState keyboardState = Keyboard.GetState();
            GamePadState  gamePadState  = GamePad.GetState(PlayerIndex.One);

            // Allows the default game to exit on Xbox 360 and Windows
            if (gamePadState.Buttons.Back == ButtonState.Pressed ||
                keyboardState.IsKeyDown(Keys.Escape))
            {
                iWearInterface.IWRSetStereoEnabled(stereoHandle, false);
                this.Exit();
            }
            if (keyboardState.IsKeyDown(Keys.Left) ||
                gamePadState.Buttons.LeftShoulder == ButtonState.Pressed)
            {
                g_EyeSeparation -= 0.1f;
                if (g_EyeSeparation < 0.0f)
                {
                    g_EyeSeparation = 0.0f;
                }
            }
            // Pressing the Right or the right button on controller will increase Eye separation.
            if (keyboardState.IsKeyDown(Keys.Right) ||
                gamePadState.Buttons.RightShoulder == ButtonState.Pressed)
            {
                g_EyeSeparation += 0.1f;
            }
            // Focal length changes.
            if (keyboardState.IsKeyDown(Keys.Up))
            {
                g_FocalLength += 1.0f;
            }
            if (keyboardState.IsKeyDown(Keys.Down))
            {
                g_FocalLength -= 1.0f;
                if (g_FocalLength < 6.0f)
                {
                    g_FocalLength = 6.0f;
                }
            }
            // Increase decrease Number of objects.
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.Insert))
            {
                WaitingForKeyrelease = true;
                ModelsToDraw        += MODEL_PER_ROW;
            }
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.Delete))
            {
                WaitingForKeyrelease = true;
                ModelsToDraw        -= MODEL_PER_ROW;
                if (ModelsToDraw < MODEL_PER_ROW)
                {
                    ModelsToDraw = MODEL_PER_ROW;
                }
            }
            // Turn tracking on / off.
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.T))
            {
                WaitingForKeyrelease = true;
                g_tracking           = !g_tracking;
            }
            // Turn Filtering on / off.
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.F))
            {
                WaitingForKeyrelease = true;
                g_filtering          = !g_filtering;
                try
                {
                    iWearInterface.IWRSetFilterState(g_filtering);
                }
                catch
                {
                    // Filtering not available, could be pre 2.4 driver install.
                    g_filtering = false;
                }
            }
            // Pause animations.
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.P))
            {
                WaitingForKeyrelease = true;
                g_Pause = !g_Pause;
            }
            //Pressing Enter will toggle stereo on/off
            if (!WaitingForKeyrelease && (keyboardState.IsKeyDown(Keys.Enter) ||
                                          gamePadState.Buttons.RightStick == ButtonState.Pressed))
            {
                WaitingForKeyrelease = true;
                //Pressing Alt-Enter will toggle fullscreen/windowed
                if (keyboardState.IsKeyDown(Keys.LeftAlt) || keyboardState.IsKeyDown(Keys.RightAlt))
                {
                    // iWear: These presentation options MUST be set to remove tearing when operating in Windowed mode.
                    // iWear: Force Update and draw sequentially, to asist in maintaining stereoscopy frame syncronization.
                    IsFixedTimeStep = true;
                    if (graphics.IsFullScreen && !usingWrap)
                    {
                        // If we are in fullscreen, prepare to enter windowed mode.
                        graphics.PreferredBackBufferHeight      = 480;
                        graphics.PreferredBackBufferWidth       = 640;
                        graphics.SynchronizeWithVerticalRetrace = false;
                    }
                    else
                    {
                        // If we are in windowed mode, prepare to enter fullscreen mode.
                        graphics.PreferredBackBufferHeight      = 768;
                        graphics.PreferredBackBufferWidth       = 1024;
                        graphics.SynchronizeWithVerticalRetrace = true;
                    }

                    if (!usingWrap)
                    {
                        graphics.ToggleFullScreen();
                    }
                }
                else
                {
                    // iWear: Do not reference an invalid handle.
                    if (stereoHandle != ((IntPtr)(-1)))
                    {
                        stereoEnabled = !stereoEnabled;
                        iWearInterface.IWRSetStereoEnabled(stereoHandle, stereoEnabled);
                    }
                }
            }
            // Toggle status output.
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.F1))
            {
                WaitingForKeyrelease = true;
                g_ShowStatus         = !g_ShowStatus;
            }
            // Change camera positions.
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.F2))
            { // Default position here.
                WaitingForKeyrelease = true;
                g_CameraXPosition    = 30.0f; g_CameraYPosition = 50.0f; g_CameraZPosition = -100.0f;
            }
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.F3))
            {
                WaitingForKeyrelease = true;
                g_CameraXPosition    = 150; g_CameraYPosition = -200.0f; g_CameraZPosition = -100.0f;
            }
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.F4))
            {
                WaitingForKeyrelease = true;
                g_CameraXPosition    = 0; g_CameraYPosition = 300.0f; g_CameraZPosition = -200.0f;
            }
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.F5))
            {
                WaitingForKeyrelease = true;
                g_CameraXPosition    = -100; g_CameraYPosition = 400.0f; g_CameraZPosition = -0.0f;
            }
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.F6))
            {
                WaitingForKeyrelease = true;
                g_CameraXPosition    = 0; g_CameraYPosition = -100.0f; g_CameraZPosition = -0.0f;
            }
            if (!WaitingForKeyrelease && keyboardState.IsKeyDown(Keys.Space))
            {
                WaitingForKeyrelease = true;
                g_CameraXPosition    = 30; g_CameraYPosition = 50.0f; g_CameraZPosition = 0.0f;
                g_EyeSeparation      = 3.0f;   // Intraocular Distance: aka, Distance between left and right cameras.
                g_FocalLength        = 150.0f; // Screen projection plane: aka, focal length(distance to front of virtual screen).
                g_ShowStatus         = true;
                g_Pause      = false;
                ModelsToDraw = 3 * 3;
            }
            // Release flag on key up presses.
            if ((keyboardState.IsKeyUp(Keys.Enter)) &&
                (keyboardState.IsKeyUp(Keys.P)) &&
                (keyboardState.IsKeyUp(Keys.T)) &&
                (keyboardState.IsKeyUp(Keys.F)) &&
                (keyboardState.IsKeyUp(Keys.Delete)) &&
                (keyboardState.IsKeyUp(Keys.Insert)) &&
                (keyboardState.IsKeyUp(Keys.F1)) &&
                (keyboardState.IsKeyUp(Keys.F2)) &&
                (keyboardState.IsKeyUp(Keys.F3)) &&
                (keyboardState.IsKeyUp(Keys.F4)) &&
                (keyboardState.IsKeyUp(Keys.F5)) &&
                (keyboardState.IsKeyUp(Keys.F6)) &&
                (keyboardState.IsKeyUp(Keys.Space)) &&
                (keyboardState.IsKeyUp(Keys.LeftAlt)) &&
                (keyboardState.IsKeyUp(Keys.RightAlt)))
            {
                WaitingForKeyrelease = false;
            }
            base.Update(gameTime);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            graphics.ToggleFullScreen();

            base.Initialize();
        }
Ejemplo n.º 20
0
        protected override void Update(GameTime gameTime)
        {
            currentState = Keyboard.GetState();
            switch (currentGameState)
            {
            case GameStates.INGAME:
                if (!Entities.FindAll(x => x.Name == "enemy").Any())
                {
                    changeGameState(Game1.GameStates.WIN);
                }
                foreach (IEntity c in Entities.ToList())
                {
                    if (!paused)
                    {
                        c.Update(this, currentState, lastState, gameTime);
                        collisionSystem.Update(Entities.ToList(), gameTime);
                    }
                }
                if (currentState.IsKeyDown(Keys.Escape) && paused)
                {
                    changeGameState(GameStates.MENU);
                }
                if (currentState.IsKeyDown(Keys.P) && !lastState.IsKeyDown(Keys.P))
                {
                    paused = !paused;
                }
                if (mathNum1 > mathTarget || mathNum1 + mathNum2 > mathTarget || mathNum1 + mathNum2 + mathNum3 > mathTarget)
                {
                    ResetMaths();
                }
                if (mathNum1 + mathNum2 + mathNum3 + mathNum4 == mathTarget)
                {
                    score += (100 * difficulty);
                    ResetMaths();
                }
                if (mathNum1 > 0 && mathNum2 > 0 && mathNum3 > 0 && mathNum4 > 0)
                {
                    ResetMaths();
                }
                break;

            case GameStates.MENU:
                if (currentState.IsKeyDown(Keys.Enter) && currentState.IsKeyUp(Keys.LeftAlt) && currentState.IsKeyUp(Keys.LeftAlt))
                {
                    changeGameState(GameStates.INGAME);
                }
                else if (currentState.IsKeyDown(Keys.Escape) && !lastState.IsKeyDown(Keys.Escape))
                {
                    Exit();
                }
                break;

            case GameStates.GAMEOVER:
                if (currentState.IsKeyDown(Keys.Escape))
                {
                    changeGameState(GameStates.MENU);
                }
                else if (currentState.IsKeyDown(Keys.Enter) && currentState.IsKeyUp(Keys.LeftAlt) && currentState.IsKeyUp(Keys.LeftAlt))
                {
                    changeGameState(GameStates.INGAME);
                }
                break;

            case GameStates.WIN:
                if (currentState.IsKeyDown(Keys.Escape))
                {
                    changeGameState(GameStates.MENU);
                }
                else if (currentState.IsKeyDown(Keys.Enter) && currentState.IsKeyUp(Keys.LeftAlt) && currentState.IsKeyUp(Keys.LeftAlt))
                {
                    changeGameState(GameStates.INGAME);
                }
                break;
            }
            if (currentState.IsKeyDown(Keys.LeftAlt) || currentState.IsKeyDown(Keys.RightAlt))
            {
                if (currentState.IsKeyDown(Keys.Enter) && lastState.IsKeyUp(Keys.Enter))
                {
                    graphics.ToggleFullScreen();
                }
            }
            lastState = Keyboard.GetState();

            base.Update(gameTime);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            stageManager.Update(gameTime);

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                if (stageManager.SelectedStage == -2)
                {
                    Exit();
                }
                else
                {
                    stageManager.SelectedStage = -1;
                }
            }

            if (stageManager.SelectedStage == -2)
            {
                Exit();
            }

            //Implement in stagemanager
            if (stageManager.SelectedStage > -1)
            {
                collisionManager.DetectCollisions(stageManager.GetStage());
            }

            stageManager.ResolveCollisions();

            // TODO: Add your update logic here
            KeyboardState stateKey = Keyboard.GetState();



            //if (stateKey.IsKeyDown(Keys.F1))
            //{
            //    camPos.X -= 1;
            //}
            //if (stateKey.IsKeyDown(Keys.F2))
            //{
            //    camPos.X += 1;
            //}
            //if (stateKey.IsKeyDown(Keys.F3))
            //{
            //    rotation += .1f;
            //}
            //if (stateKey.IsKeyDown(Keys.F4))
            //{
            //    rotation -= .1f;
            //}
            //if (stateKey.IsKeyDown(Keys.F5))
            //{
            //    zoom += .1f;
            //}
            //if (stateKey.IsKeyDown(Keys.F6))
            //{
            //    zoom -= .1f;
            //};

            if (stateKey.IsKeyDown(Keys.F5))
            {
                graphics.ToggleFullScreen();
            }

            //if (hero.IsMoving)
            //{
            //    camPos.X = hero.Position.X - GraphicsDevice.Viewport.Width / 2;
            //    //camPos.Y = hero.Position.Y - GraphicsDevice.Viewport.Height / 2;
            //}

            base.Update(gameTime);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            //FullScreen
            if (Keyboard.GetState().IsKeyDown(Keys.F))
            {
                graphics.ToggleFullScreen();
            }

            switch (cameraState)
            {
            case cameraStates.FreeCamera:
                //Updates the freecamera method
                freeCameraUpdate(gameTime);

                //Changing the cameratate to the corresponding class
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad2))
                {
                    cameraState = cameraStates.ArcBallCamera;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad3))
                {
                    cameraState = cameraStates.ChaseCamera;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad4))
                {
                    cameraState = cameraStates.ChaseRotationCamera;
                }


                break;

            case cameraStates.ArcBallCamera:

                //Updates the arcballCamera method
                arcBallCameraUpdate(gameTime);

                //Changing the camerastate to the corresponding class
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad1))
                {
                    cameraState = cameraStates.FreeCamera;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad3))
                {
                    cameraState = cameraStates.ChaseCamera;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad4))
                {
                    cameraState = cameraStates.ChaseRotationCamera;
                }


                break;

            case cameraStates.ChaseCamera:

                //Updates the chaseCamera method
                ChaseCamera(gameTime);

                //Updates the camera method
                UpdateCamera(gameTime);

                //Changing the cameratate to the corresponding class
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad1))
                {
                    cameraState = cameraStates.FreeCamera;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad2))
                {
                    cameraState = cameraStates.ArcBallCamera;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad4))
                {
                    cameraState = cameraStates.ChaseRotationCamera;
                }


                break;

            case cameraStates.ChaseRotationCamera:
                //Updates the ChaseRotationCamera method
                ChaseRotationCamera(gameTime);

                //Updates the camera method
                UpdateCamera(gameTime);

                //Changing the camerastate to the corresponding class
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad1))
                {
                    cameraState = cameraStates.FreeCamera;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad2))
                {
                    cameraState = cameraStates.ArcBallCamera;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.NumPad3))
                {
                    cameraState = cameraStates.ChaseCamera;
                }
                break;
            }


            base.Update(gameTime);
        }
Ejemplo n.º 23
0
 public Game1()
 {
     graphics = new GraphicsDeviceManager(this);
     graphics.ToggleFullScreen();
     Content.RootDirectory = "Content";
 }
Ejemplo n.º 24
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (Keyboard.GetState().IsKeyDown(Keys.RightShift) &&
                Keyboard.GetState().IsKeyDown(Keys.Enter))
            {
                if (_graphics.IsFullScreen)
                {
                    _graphics.PreferredBackBufferWidth  = 800;
                    _graphics.PreferredBackBufferHeight = 600;
                }
                else
                {
                    _graphics.PreferredBackBufferWidth  = 1920;
                    _graphics.PreferredBackBufferHeight = 1080;
                }
                _graphics.ToggleFullScreen();
                Initialize();
            }

            // TODO: Add your update logic here

            if (telemetryData == null)
            {
                try
                {
                    telemetryData     = new PCARS2_SharedMemoryData();
                    StatusBar.Message = "Connected! Version: " + telemetryData.Version;
                    StatusBar.Status  = true;
                }
                catch (Exception e)
                {
                    telemetryData     = null;
                    StatusBar.Message = e.Message;
                }
            }
            else
            {
                StatusBar.Message = "Connected! Version: " + telemetryData.Version;

                if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    try
                    {
                        StatusBar.Message = telemetryData.Participants[0].Name;
                    }
                    catch (Exception e)
                    {
                        telemetryData.Dispose();
                        telemetryData = null;
                    }
                }

                tacho.Value    = telemetryData.Rpm;
                tacho.MaxValue = telemetryData.MaxRPM;
                gear.Value     = telemetryData.Gear.ToString();
                clutch.Value   = telemetryData.Clutch;
                brake.Value    = telemetryData.Brake;
                throtle.Value  = telemetryData.Throttle;

                speedometer.Value    = 18 * telemetryData.Speed / 5;
                speedometer.MaxValue = 320;

                airTemp.Value       = telemetryData.AmbientTemperature.ToString("N0");
                trackTemp.Value     = telemetryData.TrackTemperature.ToString("N0");
                waterTemp.Value     = telemetryData.WaterTempCelsius.ToString("N0");
                waterPressure.Value = telemetryData.WaterPressureKPa.ToString("N0");
                oilTemp.Value       = telemetryData.OilTempCelsius.ToString("N0");
                oilPressure.Value   = telemetryData.OilPressureKPa.ToString("N0");
                fuelLevel.Value     = (telemetryData.FuelLevel * telemetryData.FuelCapacity).ToString("N2") + "l";

                switch (telemetryData.HighestFlagColour)
                {
                case (uint)PCARS2_SharedMemoryData.FlagColours.Black:
                    flag.setColor(Color.Black);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.BlackOrangeCircle:
                    flag.setColor(Color.Orange);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.BlackWhite:
                    flag.setColor(Color.LightGray);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.Blue:
                    flag.setColor(Color.Blue);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.Chequered:
                    flag.setColor(Color.DarkGray);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.DoubleYellow:
                    flag.setColor(Color.LightYellow);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.Green:
                    flag.setColor(Color.Green);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.None:
                    flag.setColor(Color.Transparent);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.Red:
                    flag.setColor(Color.Red);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.White_FinalLap:
                    flag.setColor(Color.White);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.White_SlowCar:
                    flag.setColor(Color.White);
                    break;

                case (uint)PCARS2_SharedMemoryData.FlagColours.Yellow:
                    flag.setColor(Color.Yellow);
                    break;

                default:
                    flag.setColor(Color.Transparent);
                    break;
                }
            }

            fps = 1 / gameTime.ElapsedGameTime.TotalSeconds;
            StatusBar.Message += " FPS: " + fps.ToString("N2");

            RTC.Value = DateTime.Now.ToLocalTime().ToString("HH:mm:ss");

            foreach (Component component in components)
            {
                component.Update(gameTime);
            }


            base.Update(gameTime);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Allows each screen to run logic.
        /// </summary>
        protected override void Update(GameTime gameTime)
        {
            // Read the keyboard and gamepad.
            _input.Update(gameTime);

            // Update the framerate counter
#if WINDOWS
            _counter.Update(gameTime);
#endif
            if ((_input.IsNewButtonPress(Buttons.Y) || _input.IsNewKeyPress(Keys.F5)) && !(_screens[_screens.Count - 1] is OptionsScreen))
            {
                AddScreen(new OptionsScreen());
            }
#if WINDOWS
            if (_input.IsNewKeyPress(Keys.F11))
            {
                _showFPS = !_showFPS;
            }

            if (_input.IsNewKeyPress(Keys.F12))
            {
                _graphics.ToggleFullScreen();
            }
#endif

            // Make a copy of the master screen list, to avoid confusion if
            // the process of updating one screen adds or removes others.
            _screensToUpdate.Clear();
            _screensToUpdate.AddRange(_screens);

            bool otherScreenHasFocus  = !IsActive;
            bool coveredByOtherScreen = false;

            // Loop as long as there are screens waiting to be updated.
            while (_screensToUpdate.Count > 0)
            {
                // Pop the topmost screen off the waiting list.
                GameScreen screen = _screensToUpdate[_screensToUpdate.Count - 1];

                _screensToUpdate.RemoveAt(_screensToUpdate.Count - 1);

                // Update the screen.
                screen.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

                if (screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.Active)
                {
                    // If this is the first active screen we came across,
                    // give it a chance to handle input.
                    if (!otherScreenHasFocus && !_isExiting)
                    {
                        _input.ShowCursor = screen.HasCursor;
                        screen.HandleInput(_input, gameTime);
                        otherScreenHasFocus = true;
                    }

                    // If this is an active non-popup, inform any subsequent
                    // screens that they are covered by it.
                    if (!screen.IsPopup)
                    {
                        coveredByOtherScreen = true;
                    }
                }
            }

            if (_isExiting && _screens.Count == 0)
            {
                Exit();
            }

            base.Update(gameTime);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Update physics engine
            float timeStep = (float)gameTime.ElapsedGameTime.Ticks / TimeSpan.TicksPerSecond;

            if (timeStep < 1.0f / 60.0f)
            {
                physics.Integrate(timeStep);
            }
            else
            {
                physics.Integrate(1.0f / 60.0f);
            }

            // Update towers based on new physical state
            foreach (var tower in towers)
            {
                tower.Update(gameTime);
            }

            player.Update(gameTime);

            camera.Position = player.Position + new Vector3(0, player.Size.Y * 0.5f, 0);

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            float f = 200;

            if (gameTime.ElapsedGameTime.Milliseconds > 0)
            {
                f *= (gameTime.ElapsedGameTime.Milliseconds / 1000.0f);
            }
            else
            {
                f = 0;
            }

#if WINDOWS
            KeyboardState keyboard = Keyboard.GetState();

            if (keyboard.IsKeyDown(Keys.LeftControl))
            {
                f *= 10;
            }

            if (keyboard.IsKeyDown(Keys.LeftAlt) && keyboard.IsKeyDown(Keys.Enter))
            {
                graphics.ToggleFullScreen();
            }

            if (keyboard.IsKeyDown(Keys.OemPlus))
            {
                numInstances += f;
            }
            else if (keyboard.IsKeyDown(Keys.OemMinus))
            {
                numInstances -= f;
            }
#endif
#if XBOX || true
            GamePadState gamepad = GamePad.GetState(PlayerIndex.One);

            if (gamepad.IsButtonDown(Buttons.RightTrigger))
            {
                numInstances += f;
            }
            else if (gamepad.IsButtonDown(Buttons.LeftTrigger))
            {
                numInstances -= f;
            }
#endif

            SyncNumInstances();

            base.Update(gameTime);
        }
Ejemplo n.º 27
0
 private void Button_OnClickFullScreenMode(object sender, EventArgs e)
 {
     m_GrapicDIvice_ = this.Game.Services.GetService(typeof(GraphicsDeviceManager)) as GraphicsDeviceManager;
     m_GrapicDIvice_.ToggleFullScreen();
 }
        private void ProcessDebugKeys()
        {
            KeyboardState keyState = Keyboard.GetState();

            //toggle fullscreen
            if (_oldKeyboardState.IsKeyUp(Keys.F11) && keyState.IsKeyDown(Keys.F11))
            {
                graphics.ToggleFullScreen();
            }

            //freelook mode
            if (_oldKeyboardState.IsKeyUp(Keys.F1) && keyState.IsKeyDown(Keys.F1))
            {
                player1Renderer.freeCam = !player1Renderer.freeCam;
            }

            //minimap mode
            if (_oldKeyboardState.IsKeyUp(Keys.M) && keyState.IsKeyDown(Keys.M))
            {
                hud.showMinimap = !hud.showMinimap;
            }

            //wireframe mode
            if (_oldKeyboardState.IsKeyUp(Keys.F7) && keyState.IsKeyDown(Keys.F7))
            {
                world.ToggleRasterMode();
            }

            //diagnose mode
            if (_oldKeyboardState.IsKeyUp(Keys.F8) && keyState.IsKeyDown(Keys.F8))
            {
                _diagnosticMode = !_diagnosticMode;
            }

            //day cycle/dayMode
            if (_oldKeyboardState.IsKeyUp(Keys.F9) && keyState.IsKeyDown(Keys.F9))
            {
                world.dayMode = !world.dayMode;
                //Debug.WriteLine("Day Mode is " + world.dayMode);
            }

            //day cycle/nightMode
            if (_oldKeyboardState.IsKeyUp(Keys.F10) && keyState.IsKeyDown(Keys.F10))
            {
                world.nightMode = !world.nightMode;
                //Debug.WriteLine("Day/Night Mode is " + world.nightMode);
            }

            // Allows the game to exit
            if (keyState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            // Release the mouse pointer
            if (_oldKeyboardState.IsKeyUp(Keys.F) && keyState.IsKeyDown(Keys.F))
            {
                this.releaseMouse   = !this.releaseMouse;
                this.IsMouseVisible = !this.IsMouseVisible;
            }

            // fixed time step
            if (_oldKeyboardState.IsKeyUp(Keys.F3) && keyState.IsKeyDown(Keys.F3))
            {
                graphics.SynchronizeWithVerticalRetrace = !graphics.SynchronizeWithVerticalRetrace;
                this.IsFixedTimeStep = !this.IsFixedTimeStep;
                Debug.WriteLine("FixedTimeStep and vsync are " + this.IsFixedTimeStep);
                graphics.ApplyChanges();
            }

            // stealth mode / keep screen space for profilers
            if (_oldKeyboardState.IsKeyUp(Keys.F4) && keyState.IsKeyDown(Keys.F4))
            {
                if (graphics.PreferredBackBufferHeight == preferredBackBufferHeight)
                {
                    graphics.PreferredBackBufferHeight = 100;
                    graphics.PreferredBackBufferWidth  = 160;
                }
                else
                {
                    graphics.PreferredBackBufferHeight = preferredBackBufferHeight;
                    graphics.PreferredBackBufferWidth  = preferredBackBufferWidth;
                }
                graphics.ApplyChanges();
            }

            this._oldKeyboardState = keyState;
        }
Ejemplo n.º 29
0
 public static void toggleFullScreen()
 {
     graphics.ToggleFullScreen();
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            KeyboardState keyboard = Keyboard.GetState();
            GamePadState  gamepad  = GamePad.GetState(PlayerIndex.One);


            elapsedTime += gameTime.ElapsedGameTime;


            // Allows the game to exit
            if (gamepad.Buttons.Back == ButtonState.Pressed || keyboard.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            // Enter fullscreen
            else if (keyboard.IsKeyDown(Keys.RightAlt) && keyboard.IsKeyDown(Keys.Enter))
            {
                graphics.ToggleFullScreen();
            }


            // TODO: Add your update logic here



            if (elapsedTime > TimeSpan.FromSeconds(1))
            {
                explosions.Add(
                    new ParticleExplosion(GraphicsDevice, new Vector3(-10, -20, -200),
                                          ParticleExplosion.rnd.Next(
                                              particleExplosionSettings.minLife,
                                              particleExplosionSettings.maxLife),
                                          ParticleExplosion.rnd.Next(
                                              particleExplosionSettings.minRoundTime,
                                              particleExplosionSettings.maxRoundTime),
                                          ParticleExplosion.rnd.Next(
                                              particleExplosionSettings.minParticlesPerRound,
                                              particleExplosionSettings.maxParticlesPerRound),
                                          ParticleExplosion.rnd.Next(
                                              particleExplosionSettings.minParticles,
                                              particleExplosionSettings.maxParticles),
                                          explosionColorsTexture, particleSettings,
                                          explosionEffect));

                elapsedTime = TimeSpan.Zero;
            }

            // Loop through and update explosions
            for (int i = 0; i < explosions.Count; ++i)
            {
                explosions[i].Update(gameTime);
                // If explosion is finished, remove it
                if (explosions[i].IsDead)
                {
                    explosions.RemoveAt(i);
                    --i;
                }
            }



            base.Update(gameTime);
        }