Example #1
0
        protected override void Initialize()
        {
            Window.Title             = "SkyBoxGame";
            Window.AllowUserResizing = true;
            IsMouseVisible           = true;

            base.Initialize();

            _keyboardState = _keyboard.GetState();
            _mouseState    = _mouse.GetState();
        }
Example #2
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // Get the current state of the keyboard
            keyboardState = keyboard.GetState();

            // Get the current state of the mouse
            mouseState = mouse.GetState();

            IsMouseVisible = true;

            // Check if Escape key has been pressed to exit
            if (keyboardState.IsKeyPressed(Keys.Escape))
            {
                Exit();
            }

            // Count total execution time in seconds
            time = (float)gameTime.TotalGameTime.TotalSeconds;

            // Game screens update
            switch (gameScreen)
            {
            case GameScreen.LOGO: logoScreen.Update(keyboardState); break;

            case GameScreen.TITLE: titleScreen.Update(keyboardState); break;

            case GameScreen.GAMEPLAY: gameplayScreen.Update(keyboardState); break;

            case GameScreen.ENDING: endingScreen.Update(keyboardState); break;

            default: break;
            }
        }
Example #3
0
        public void Update(GameTime gameTime)
        {
            //Mouse update
            MouseState mouseState = mouseManager.GetState();

            scaleFactor -= (mouseState.WheelDelta - prevDelta) / 1000.0f;
            prevDelta    = mouseState.WheelDelta;

            if (scaleFactor > 10)
            {
                scaleFactor = 10;
            }
            if (scaleFactor < 0.1)
            {
                scaleFactor = 0.1f;
            }

            Vector4 temp = new Vector4(distance, 1);

            temp         = Vector4.Transform(temp, Matrix.Scaling(scaleFactor) * Matrix.RotationY(-AngleH) * Matrix.RotationX(-AngleV));
            RealDistance = new Vector3(temp.X, temp.Y, temp.Z);
            RealPosition = game.ball.position + RealDistance;

            position = game.ball.position + distance * scaleFactor;
            View     = Matrix.Translation(-game.ball.position.X, -game.ball.position.Y, -game.ball.position.Z)
                       * Matrix.RotationY(AngleH)
                       * Matrix.RotationX(AngleV)
                       * Matrix.Translation(game.ball.position.X, game.ball.position.Y, game.ball.position.Z)
                       * Matrix.LookAtLH(position, game.ball.position, Vector3.UnitY);
        }
Example #4
0
        private void UpdateMouseState()
        {
            mouseState      = mouse.GetState();
            currentPosition = new Vector2(mouseState.X, mouseState.Y);

            CalculateDelta();
        }
Example #5
0
        protected override void Update(GameTime gameTime)
        {
            keyboardState = keyboardManager.GetState();
            mouseState    = mouseManager.GetState();

            // Handle base.Update
            base.Update(gameTime);

            //Update game objects
            lightsource.Update(gameTime);
            model.Update(gameTime, lightsource.getLightDirection());
            water.Update(gameTime, lightsource.getLightDirection());
            camera.Update(gameTime);

            //Enable/disable cursor control of the camera
            if (keyboardState.IsKeyPressed(Keys.Space))
            {
                if (enableCursor == true)
                {
                    enableCursor = false;
                }
                else
                {
                    enableCursor = true;
                }
            }

            //Exit the game
            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
                this.Dispose();
            }
        }
Example #6
0
        protected override void Update(GameTime gameTime)
        {
            // read the current mouse state
            mouseState = mouseManager.GetState();

            base.Update(gameTime);
        }
Example #7
0
        public static void update()
        {
            prevKeyboard = currKeyboard;
            currKeyboard = keyboard.GetState();

            prevMouse = currMouse;
            currMouse = mouse.GetState();
        }
Example #8
0
        public void Update(GameTime gameTime, bool isActive)
        {
            float amount = (float)gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0f;

            // Handle mouse input
            MouseState currentMouseState = mouse.GetState();

            if (currentMouseState != originalMouseState)
            {
                float xDifference = (currentMouseState.X * BackBufferWidth) - (originalMouseState.X * BackBufferWidth);
                float yDifference = (currentMouseState.Y * BackBufferHeight) - (originalMouseState.Y * BackBufferHeight);
                horizontalRotation -= RotationSpeed * xDifference * amount;
                verticalRotation   -= RotationSpeed * yDifference * amount;

                if (isActive)
                {
                    mouse.SetPosition(new Vector2(0.5f, 0.5f));
                    UpdateViewMatrix();
                }
            }

            // Handle keyboard input
            Vector3       moveVector = new Vector3(0, 0, 0);
            KeyboardState keyState   = keyboard.GetState();

            if (keyState.IsKeyDown(Keys.Up) || keyState.IsKeyDown(Keys.W))
            {
                moveVector += new Vector3(0, 0, -1);
            }

            if (keyState.IsKeyDown(Keys.Down) || keyState.IsKeyDown(Keys.S))
            {
                moveVector += new Vector3(0, 0, 1);
            }

            if (keyState.IsKeyDown(Keys.Right) || keyState.IsKeyDown(Keys.D))
            {
                moveVector += new Vector3(1, 0, 0);
            }

            if (keyState.IsKeyDown(Keys.Left) || keyState.IsKeyDown(Keys.A))
            {
                moveVector += new Vector3(-1, 0, 0);
            }

            if (keyState.IsKeyDown(Keys.Q) || keyState.IsKeyDown(Keys.Space))
            {
                moveVector += new Vector3(0, 1, 0);
            }

            if (keyState.IsKeyDown(Keys.Y))
            {
                moveVector += new Vector3(0, -1, 0);
            }

            AddToCameraPosition(moveVector * amount);
        }
Example #9
0
        /// <summary>
        /// Reference page contains links to related conceptual articles.
        /// </summary>
        /// <param name="gameTime">Time passed since the last call to Update.</param>
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            gameCore.Update();
            keyboardState = keyboard.GetState();
            mouseState = mouse.GetState();
            camera.Update(gameTime, this.IsActive);
            grass.Update(gameTime);
        }
Example #10
0
        protected override void Update(GameTime gameTime)
        {
            keyboardState = keyboardManager.GetState();
            mouseState    = mouseManager.GetState();
            model.Update(gameTime);
            sun.Update(gameTime);

            // Handle base.Update
            base.Update(gameTime);
        }
Example #11
0
        public void Update()
        {
            var state = _mouse.GetState();
            var pos   = new Vector2(state.X, state.Y);

            Position = pos;

            Left.Update(state.LeftButton, pos);
            Right.Update(state.RightButton, pos);
            Middle.Update(state.MiddleButton, pos);
        }
Example #12
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);


            // Get the current state of the keyboard
            keyboardState = keyboard.GetState();

            // Get the current state of the mouse
            mouseState = mouse.GetState();
        }
Example #13
0
        public void Update(GameTime gameTime)
        {
            LastKeyboardState = CurrentKeyboardState;
            LastMouseState    = CurrentMouseState;

            CurrentKeyboardState = keyboard.GetState();
            CurrentMouseState    = mouse.GetState();

            var device = Game.GraphicsDevice;
            var pt     = new GsVector(CurrentMouseState.X, CurrentMouseState.Y);

            pt *= new GsVector(device.Viewport.Width, device.Viewport.Height);

            CursorPosition = pt;
            SelectPressed  = (CurrentMouseState.LeftButton.Down);
        }
Example #14
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);


            // Get the current state of the _keyboardManager
            _keyboardState = _keyboardManager.GetState();

            // Get the current state of the _mouse
            _mouseState = _mouse.GetState();

            _map.Update(gameTime);
            _player.Update(gameTime);
            _scene.Update(gameTime);
            _viewRenderer.Update(gameTime);
        }
Example #15
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // Calculates the world and the view based on the model size
            view       = Matrix.LookAtRH(new Vector3(0.0f, 0.0f, 7.0f), new Vector3(0, 0.0f, 0), Vector3.UnitY);
            projection = Matrix.PerspectiveFovRH(0.9f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f);

            // Update basic effect for rendering the Primitive
            basicEffect.View       = view;
            basicEffect.Projection = projection;

            // Get the current state of the keyboard
            keyboardState = keyboard.GetState();

            // Get the current state of the mouse
            mouseState = mouse.GetState();
        }
Example #16
0
        protected override void Update(GameTime gameTime)
        {
            // Getting input device states
            keyboardState = keyboardManager.GetState();
            mouseState    = mouseManager.GetState();

            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            model.Update(gameTime);
            camera.Update(gameTime);


            // Handle base.Update
            base.Update(gameTime);
        }
Example #17
0
        protected override void Update(GameTime gameTime)
        {
            keyboardState = keyboardManager.GetState();
            mouseState    = mouseManager.GetState();
            camera.Update(gameTime);
            model.Update(gameTime);

            // Resets mouse position so it can't go outside the window
            mouseManager.SetPosition(new Vector2(MOUSEX, MOUSEY));

            // Escape key will exit game
            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            // Handle base.Update
            base.Update(gameTime);
        }
Example #18
0
        public Camera(GraphicsDevice graphicsDevice, int backBufferWidth, int backBufferHeight, KeyboardManager keyboard, MouseManager mouse)
        {
            this.BackBufferWidth  = backBufferWidth;
            this.BackBufferHeight = backBufferHeight;

            this.keyboard = keyboard;
            this.mouse    = mouse;

            // Create default camera position
            this.Position = new Vector3(256, 0, 256);
            this.World    = Matrix.Identity;

            // Calculates the world and the view based on the model size
            this.View       = Matrix.LookAtRH(this.Position, new Vector3(0, 0, 0), Vector3.UnitY);
            this.Projection = Matrix.PerspectiveFovRH(0.9f, (float)graphicsDevice.BackBuffer.Width / graphicsDevice.BackBuffer.Height, 0.1f, 10000.0f);

            mouse.SetPosition(new Vector2(0.5f, 0.5f));
            originalMouseState = mouse.GetState();
        }
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // Calculates the world and the view based on the model size
            view       = Matrix.LookAtRH(new Vector3(0.0f, 0.0f, 7.0f), new Vector3(0, 0.0f, 0), Vector3.UnitY);
            projection = Matrix.PerspectiveFovRH(0.9f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f);

            // Update basic effect for rendering the Primitive
            basicEffect.View       = view;
            basicEffect.Projection = projection;

            // Get the current state of the mouse
            mouseState = mouse.GetState();

            if (mouseState.LeftButton.Pressed)
            {
                scenario = scenario == Scenario.SkipIfUnavailable ? Scenario.StallPipeline : ++scenario;
            }
        }
Example #20
0
File: Game.cs Project: mofr/SharpD2
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (loading)
            {
            }
            else
            {
                //if (!loaded || keyboardState.IsKeyPressed(Keys.Enter))
                //{
                //    browser.NavigateTo("http://www.google.co.uk");
                //    browser.Focus();
                //    loaded = true;
                //}



                // Get the current state of the keyboard
                keyboardState = keyboard.GetState();

                // Get the current state of the mouse
                mouseState = mouse.GetState();


                if (mouseState.WheelDelta != 0)
                {
                    if (zoom - mouseState.WheelDelta / 2000.0f > 0.001f)
                    {
                        zoom -= mouseState.WheelDelta / 2000.0f;
                        CalculateResize();
                    }
                }

                if (mouseState.LeftButton.Pressed)
                {
                    mousePressedPosition       = new Vector2(mouseState.X, mouseState.Y);
                    mousePressedCameraPosition = cameraPosition;
                }

                if (mouseState.LeftButton.Down)
                {
                    var diff = new Vector2(mouseState.X, mouseState.Y) - mousePressedPosition;

                    var absDiff = new Vector2(GraphicsDevice.BackBuffer.Width, GraphicsDevice.BackBuffer.Height);

                    float scale = 0.18f;

                    var transdiffX = Vector3.TransformCoordinate(new Vector3((diff * absDiff * zoom * scale).X, 0, (diff * absDiff * zoom * scale).X), basicEffect.World);
                    var transdiffY = Vector3.TransformCoordinate(new Vector3(0, (diff * absDiff * zoom * (0.45f)).Y, 0), basicEffect.World);


                    cameraPosition = mousePressedCameraPosition + transdiffY - transdiffX;
                }

                if (mouseState.RightButton.Pressed)
                {
                    mousePressedPosition     = new Vector2(mouseState.X, mouseState.Y);
                    mousePressedCameraOffset = cameraOffset;
                }

                if (mouseState.RightButton.Down)
                {
                    var diff = mouseState.X - mousePressedPosition.X;

                    var trans = Vector3.TransformCoordinate(cameraOffset, Matrix.RotationZ(diff));

                    cameraOffset = trans;

                    //cameraOffset.Z = mouseState.Y - mousePressedPosition.Y;
                }

                selectedTile = ScreenToWorld(new Vector2(mouseState.X, mouseState.Y));
            }
        }
Example #21
0
        void Update_Input()
        {
            keyboardState = keyboardManager.GetState();
            mouseState    = mouseManager.GetState();


            // if Esc is pressed - quit program
            if (keyboardState.IsKeyPressed(Keys.Escape))
            {
                Exit();
                return;
            }

            if (keyboardState.IsKeyPressed(Keys.K))
            {
                tiles[3].PlayDelegate();
            }


            if (keyboardState.IsKeyPressed(Keys.J))
            {
                tiles[3].StopDelegate();
            }

            if (keyboardState.IsKeyPressed(Keys.O))
            {
                tiles[4].PlayDelegate();
            }
            if (keyboardState.IsKeyPressed(Keys.P))
            {
                tiles[4].StopDelegate();
            }

            //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            int mouseWheelOffset = mouseState.WheelDelta - lastWheelDelta;

            if (mouseWheelOffset != 0)
            {
                int multiply = 10;
                if (keyboardState.IsKeyDown(Keys.Control))
                {
                    multiply = 1;
                }
                if (keyboardState.IsKeyDown(Keys.Shift))
                {
                    multiply = 100;
                }
                config.cameraControl.ExposureTime += multiply * mouseWheelOffset;
            }
            //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            // info tiles
            if (keyboardState.IsKeyPressed(Keys.F1))
            {
                config.hud.helpMenu ^= true;
                hmd.EnableHSWDisplaySDKRender(true);
                hmd.DismissHSWDisplay(); // not functional
            }
            if (keyboardState.IsKeyPressed(Keys.F2))
            {
                config.hud.toolStrip ^= true;
            }

            if (keyboardState.IsKeyPressed(Keys.F3))
            {
                config.hud.timeStrip ^= true;
            }


            if (keyboardState.IsKeyPressed(Keys.F5))
            {
                ra.angleType = e_valueType.wantedValue;
            }
            if (keyboardState.IsKeyPressed(Keys.F6))
            {
                ra.angleType = e_valueType.sentValue;
            }
            if (keyboardState.IsKeyPressed(Keys.F7))
            {
                ra.angleType = e_valueType.seenValue;
            }

            if (keyboardState.IsKeyPressed(Keys.F8))
            {
                config.roboticArmPostureOnCameraCapture ^= true;
            }


            if (keyboardState.IsKeyPressed(Keys.M) && keyboardState.IsKeyDown(Keys.Control))
            {
                //config.READ_dataFromMotors ^= true; // toggle
                config.player.ResetPositionAndBodyYaw();
                config.WRITE_dataToMotors ^= true;
            }
            else if (keyboardState.IsKeyPressed(Keys.M) && keyboardState.IsKeyDown(Keys.Shift))
            {
                //config.READ_dataFromMotors ^= true; // toggle
                config.READ_dataFromMotors ^= true;
            }
            else if (keyboardState.IsKeyPressed(Keys.M))
            {
                config.motorSpeedControl ^= true;
            }

            if (keyboardState.IsKeyPressed(Keys.R) && keyboardState.IsKeyDown(Keys.Control))
            {
                config.player.ResetPosition();
            }
            else if (keyboardState.IsKeyPressed(Keys.R) && keyboardState.IsKeyDown(Keys.Shift))
            {
                config.player.ResetBodyYaw();
            }
            else if (keyboardState.IsKeyPressed(Keys.R))
            {
                config.player.ResetPositionAndBodyYaw();
            }

            if (keyboardState.IsKeyPressed(Keys.F))
            {
                config.draw.RoboticArm ^= true;
                ra.draw = config.draw.RoboticArm;
            }

            if (keyboardState.IsKeyPressed(Keys.C) && keyboardState.IsKeyDown(Keys.Shift))
            {
                config.ReadCameraStream ^= true;
                if (config.ReadCameraStream)
                {
                    START_streaming();
                }
                else
                {
                    STOP_streaming();
                }
            }

            if (keyboardState.IsKeyPressed(Keys.U))
            {
                if (textureConversionAlgorithm == e_textureConversionAlgorithm.unsafeConversion_pointerForLoop)
                {
                    // last
                    textureConversionAlgorithm = 0;
                }
                else
                {
                    textureConversionAlgorithm++;
                }
            }


            if (keyboardState.IsKeyPressed(Keys.D1) && keyboardState.IsKeyDown(Keys.Shift))
            {
                config.player.PositionLock = e_positionLock.cameraSensor;
            }

            if (keyboardState.IsKeyPressed(Keys.D2) && keyboardState.IsKeyDown(Keys.Shift))
            {
                config.player.PositionLock = e_positionLock.desk;
            }
            if (keyboardState.IsKeyPressed(Keys.D3) && keyboardState.IsKeyDown(Keys.Shift))
            {
                config.player.PositionLock = e_positionLock.overDesk;
            }
            if (keyboardState.IsKeyPressed(Keys.Tab))
            {
                config.player.PositionLockActive ^= true;
            }

            if (keyboardState.IsKeyPressed(Keys.D1))
            {
                config.cameraArtificialDelay = false;
                lock (queuePixelData_locker)
                {
                    que.Clear();
                }
            }

            if (keyboardState.IsKeyPressed(Keys.D2))
            {
                config.cameraArtificialDelay = true;
                lock (queuePixelData_locker)
                {
                    que.Clear();
                }
                config.cameraFrameQueueLength = config.cameraFrameQueueLengthList[0];
            }

            if (keyboardState.IsKeyPressed(Keys.D3))
            {
                config.cameraArtificialDelay = true;
                lock (queuePixelData_locker)
                {
                    que.Clear();
                }
                config.cameraFrameQueueLength = config.cameraFrameQueueLengthList[1];
            }

            if (keyboardState.IsKeyPressed(Keys.D4))
            {
                config.cameraArtificialDelay = true; lock (queuePixelData_locker)
                {
                    que.Clear();
                }
                config.cameraFrameQueueLength = config.cameraFrameQueueLengthList[2];
            }

            if (keyboardState.IsKeyPressed(Keys.D5))
            {
                config.cameraArtificialDelay = true;
                lock (queuePixelData_locker)
                {
                    que.Clear();
                }
                config.cameraFrameQueueLength = config.cameraFrameQueueLengthList[3];
            }

            if (keyboardState.IsKeyPressed(Keys.D6))
            {
                config.cameraArtificialDelay = true;
                lock (queuePixelData_locker)
                {
                    que.Clear();
                }
                config.cameraFrameQueueLength = config.cameraFrameQueueLengthList[4];
            }


            if (keyboardState.IsKeyPressed(Keys.X))
            {
                measurementStart = DateTime.Now;
            }

            HUD.AppendLine(string.Format(
                               "W{0}|A{1}|S{2}",
                               keyboardState.IsKeyDown(Keys.W),
                               keyboardState.IsKeyDown(Keys.A),
                               keyboardState.IsKeyDown(Keys.S)
                               ));

            config.player.FrameTime = gameTime.ElapsedGameTime.Milliseconds;

            config.player.MoveForward(keyboardState.IsKeyDown(Keys.W));
            config.player.MoveSideStep(keyboardState.IsKeyDown(Keys.A), false);
            config.player.MoveBackward(keyboardState.IsKeyDown(Keys.S));
            config.player.MoveSideStep(keyboardState.IsKeyDown(Keys.D), true);
            config.player.MoveUpward(keyboardState.IsKeyDown(Keys.E));
            config.player.MoveDownward(keyboardState.IsKeyDown(Keys.Q));

            config.player.SetupSpeed(keyboardState.IsKeyDown(Keys.Shift), keyboardState.IsKeyDown(Keys.Control));


            if (keyboardState.IsKeyPressed(Keys.J) && keyboardState.IsKeyDown(Keys.Control))
            {
                config.draw.SkySurface ^= true;
            }


            List <Keys> keys = new List <Keys>();

            keyboardState.GetDownKeys(keys);
            //foreach (var key in keys)
            //    sb.AppendFormat("Key: {0}, Code: {1}\n", key, (int)key);

            // numer keys (NOT numpad ones) have name like D0, D1, etc...
            // associate available modes each with its key
            //for (int i = 0; i < availableModes.Count; i++)
            //{
            //    var key = (Keys)Enum.Parse(typeof(Keys), "D" + i);
            //    if (keyboardState.IsKeyPressed(key))
            //    {
            //        ApplyMode(availableModes[i]);
            //        return;
            //    }
            //}

            lastWheelDelta = mouseState.WheelDelta;
        }
Example #22
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // Get the current state of the keyboard
            keyboardState = keyboard.GetState();

            // Get the current state of the mouse
            mouseState = mouse.GetState();

            // Check if Escape key has been pressed to exit
            if (keyboardState.IsKeyPressed(Keys.Escape))
            {
                Exit();
            }

            // Count total execution time in seconds
            time = (float)gameTime.TotalGameTime.TotalSeconds;

            switch (screen)
            {
            case GameScreen.LOGO:
            {
                // Update LOGO screen data here!

                // TODO: Logo fadeIn and fadeOut logic...............(0.5p)
                framesCounter++;

                if (framesCounter <= 90)
                {
                    LogoColor.A++;
                }
                if (framesCounter > 90 && framesCounter <= 210)
                {
                    LogoColor.A = LogoColor.A;
                }
                if (framesCounter > 210 && framesCounter <= 300)
                {
                    LogoColor.A--;
                }
                if (framesCounter > 300)
                {
                    screen = GameScreen.TITLE;
                }
            } break;

            case GameScreen.TITLE:
            {
                // Update TITLE screen data here!

                // TODO: Title animation logic.......................(0.5p)

                if (TitleColor.A != 255)
                {
                    TitleColor.A++;
                }

                // TODO: "PRESS ENTER" logic.........................(0.5p)
                framesCounter++;

                if ((parpadeo == false) && (framesCounter >= 30))
                {
                    framesCounter = 0;
                    EnterColor.A  = 0;
                    parpadeo      = !parpadeo;
                }
                if ((parpadeo == true) && (framesCounter >= 30))
                {
                    framesCounter = 0;
                    EnterColor.A  = 255;
                    parpadeo      = !parpadeo;
                }
                if (keyboardState.IsKeyPressed(Keys.Enter))
                {
                    screen = GameScreen.GAMEPLAY;
                }
            } break;

            case GameScreen.GAMEPLAY:
            {
                // Update GAMEPLAY screen data here!

                // TODO: Player movement logic.......................(0.2p)

                if (!pause)
                {
                    if (keyboardState.IsKeyDown(Keys.Up))
                    {
                        playerPosY -= playerSpeedY;
                    }
                    if (keyboardState.IsKeyDown(Keys.Down))
                    {
                        playerPosY += playerSpeedY;
                    }
                }
                // TODO: Enemy movement logic (IA)...................(1p)

                if (!pause)
                {
                    if (ballSpeedY < 0)
                    {
                        enemySpeedY = rand.Next(-5, 0);
                    }
                    if (ballSpeedY > 0)
                    {
                        enemySpeedY = rand.Next(1, 6);
                    }

                    enemyPosY += enemySpeedY;
                }

                // TODO: Collision detection (ball-player) logic.....(0.5p) [*Cada vez que choca, la bola aumenta su velocidad (quería hacerlo añadiendo ballSpeedY++ y ballSpeedX++,
                //pero al alcanzar una velocidad muy alta, la bola escapa de los limites de la ventana)]

                if (((ballPosX - ballRadius) <= 20) && ((ballPosY + ballRadius) >= playerPosY) && ((ballPosY - ballRadius) <= (playerPosY + height)))
                {
                    ballSpeedX = -ballSpeedX;
                }
                // TODO: Collision detection (ball-enemy) logic......(0.5p)

                if (((ballPosX + ballRadius) >= (screenWidth - 20)) && ((ballPosY + ballRadius) >= enemyPosY) && ((ballPosY - ballRadius) <= (enemyPosY + height)))
                {
                    ballSpeedX = -ballSpeedX;
                }
                // TODO: Collision detection (ball-limits) logic.....(1p)

                if (((ballPosY - ballRadius) <= 0) || ((ballPosY + ballRadius) >= screenHeight))
                {
                    ballSpeedY = -ballSpeedY;
                }
                if (((ballPosX - ballRadius) <= 0) || ((ballPosX + ballRadius) >= screenWidth))
                {
                    ballSpeedX = -ballSpeedX;
                }

                // TODO: Collision detection (bars-limits) logic.....(??p)

                if (playerPosY <= 0)
                {
                    playerPosY = 0;
                }
                if ((playerPosY + height) >= screenHeight)
                {
                    playerPosY = screenHeight - height;
                }

                if (enemyPosY <= 0)
                {
                    enemyPosY = 0;
                }
                if ((enemyPosY + height) >= screenHeight)
                {
                    enemyPosY = screenHeight - height;
                }
                // TODO: Life bars decrease logic....................(1p)

                if ((ballPosX - ballRadius) <= 0)
                {
                    playerLife -= 20;
                }
                if ((ballPosX + ballRadius) >= screenWidth)
                {
                    enemyLife -= 20;
                }

                // TODO: Time counter logic..........................(0.2p)

                if (!pause)
                {
                    framesCounter++;
                    if ((framesCounter >= 60) && (secondsCounter != 0))
                    {
                        framesCounter = 0;
                        secondsCounter--;
                    }
                }
                // TODO: Game ending logic...........................(0.2p)

                if ((enemyLife == 0) || (playerLife == 0) || (secondsCounter == 0))
                {
                    screen = GameScreen.ENDING;
                }

                // TODO: Pause button logic..........................(0.2p)

                if (keyboardState.IsKeyPressed(Keys.P))
                {
                    pause = !pause;
                }

                // TODO: Ball movement logic.........................(0.2p)

                if (!pause)
                {
                    ballPosX += ballSpeedX;
                    ballPosY += ballSpeedY;
                }

                //El color del mensaje cambiará según el mensaje que salga, WIN = GREEN, LOSE = RED, DRAW = YELLOW [ ** P.]

                if ((playerLife == 0) || ((enemyLife > playerLife) && (secondsCounter == 0)))
                {
                    endingColor = Color.Red;
                }
                if ((playerLife == enemyLife) && (secondsCounter == 0))
                {
                    endingColor = Color.Yellow;
                }
            } break;

            case GameScreen.ENDING:
            {
                // Update END screen data here!

                // TODO: Replay / Exit game logic....................(0.5p)

                if (keyboardState.IsKeyPressed(Keys.R))
                {
                    secondsCounter = 99;
                    framesCounter  = 0;
                    playerLife     = 200;
                    enemyLife      = 200;
                    ballPosX       = screenWidth / 2;
                    ballPosY       = screenHeight / 2;
                    playerPosY     = (screenHeight / 2) - (height / 2);
                    enemyPosY      = (screenHeight / 2) - (height / 2);
                    screen         = GameScreen.GAMEPLAY;
                }
                //Exit game logic se contiene en la funcion WindowShouldClose.
                //Para que el mensaje de WIN, LOSE y DRAW vaya desapareciendo a partir de los 4 segundos hasta que el canal alfa del color llegue a 0. [** P.]

                framesCounter++;
                if ((framesCounter >= 240) && (endingColor.A > 0))
                {
                    endingColor.A--;
                }
            } break;

            default: break;
            }
        }