Exemplo n.º 1
0
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GameStateManagementGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            Components.Add(screenManager);

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen());
            screenManager.AddScreen(new MainMenuScreen());

            m_kFrameRate = new Utils.FrameRateCounter(this, new Vector2(700.0f, 600.0f));
            Components.Add(m_kFrameRate);

            // For testing purposes, let's disable fixed time step and vsync.
            // non-fixed timestep is damned irritating
            IsFixedTimeStep = true;
            graphics.SynchronizeWithVerticalRetrace = false;

            //For cel shading
            graphics.MinimumVertexShaderProfile = ShaderProfile.VS_2_0;
            graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(ScreenManager screenManager, bool loadingIsSlow,
            params GameScreen[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (GameScreen screen in screenManager.GetScreens())
                screen.ExitScreen();

            // Create and activate the loading screen.
            LoadingScreen loadingScreen = new LoadingScreen(screenManager,
                                                            loadingIsSlow,
                                                            screensToLoad);

            screenManager.AddScreen(loadingScreen);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000.0f);

            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (input.PauseGame)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            }


            m_kPlane.RotX = 0;
            m_kPlane.RotZ = 0;
            Vector3 m_kLookingDir = player.position - gameCamera.GetCameraPosition();

            m_kLookingDir.Y = 0f;
            m_kLookingDir.Normalize();
            //m_kLookingDir = new Vector3(-1f, 0, 0);

            //The axis are flipped from what would be expected
            //If you want to go forward/backwards, you need to switch Z and X
            //If you want to go Left/Right you keep Z and X consistent
            if (input.IsKeyHeld(Keys.Up))
            {
                m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.Z;
                m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.X;
            }
            if (input.IsKeyHeld(Keys.Down))
            {
                m_kPlane.RotX += -((float)Math.PI / 9) * m_kLookingDir.Z;
                m_kPlane.RotZ += ((float)Math.PI / 9) * m_kLookingDir.X;
            }
            if (input.IsKeyHeld(Keys.Left))
            {
                m_kPlane.RotX += -((float)Math.PI / 9) * m_kLookingDir.X;
                m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.Z;
            }
            if (input.IsKeyHeld(Keys.Right))
            {
                m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.X;
                m_kPlane.RotZ += ((float)Math.PI / 9) * m_kLookingDir.Z;
            }

            /*
             * //for gamepad input (untested!!)
             * //for forward/backward movement
             * GamePadState gamePadState = input.CurrentGamePadStates[0];
             * m_kPlane.RotX += ((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.Y;
             * m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.Y;
             *
             * //for Left/Right movement
             * m_kPlane.RotX += -((float)Math.PI / 9) * m_kLookingDir.X * gamePadState.ThumbSticks.Left.X;
             * m_kPlane.RotZ += -((float)Math.PI / 9) * m_kLookingDir.Z * gamePadState.ThumbSticks.Left.X;
             */

            m_kPlane.setRotationOffset(player.position);

            //Manually changing the camera rotation based on user input

            if (input.IsADown)
            {
                manualCameraRotation += (float)Math.PI / 4 * (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000;
            }
            if (input.IsDDown)
            {
                manualCameraRotation -= (float)Math.PI / 4 * (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000;
            }

            gameCamera.ManualCameraRotation(manualCameraRotation, player);

            /*
             * //OLD SHIP FUNCTIONS
             * player.rotationVelocity = 0;
             * if (input.ShipTurnLeft)
             * {
             *  player.rotationVelocity += 3;
             * }
             * if (input.ShipTurnRight)
             * {
             *  player.rotationVelocity += -3;
             * }
             * Vector3 thrust = Vector3.Zero;
             * if (input.ShipMove)
             * {
             *  thrust += 3500f * player.directionVec;
             * }
             * if (input.ReverseThrust)
             * {
             *  thrust += -3500f * player.directionVec;
             * }
             * player.netForce = thrust;
             */
        }
Exemplo n.º 4
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input, GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000.0f);

            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (input.PauseGame)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            }


            m_kPlane.RotX = 0;
            m_kPlane.RotZ = 0;
            if (input.IsKeyHeld(Keys.Up))
            {
                m_kPlane.RotX += -(float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Down))
            {
                m_kPlane.RotX += (float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Left))
            {
                m_kPlane.RotZ += (float)Math.PI / 9;
            }
            if (input.IsKeyHeld(Keys.Right))
            {
                m_kPlane.RotZ += -(float)Math.PI / 9;
            }


            m_kPlane.setRotationOffset(player.position);


            /*
             * //OLD SHIP FUNCTIONS
             * player.rotationVelocity = 0;
             * if (input.ShipTurnLeft)
             * {
             *  player.rotationVelocity += 3;
             * }
             * if (input.ShipTurnRight)
             * {
             *  player.rotationVelocity += -3;
             * }
             * Vector3 thrust = Vector3.Zero;
             * if (input.ShipMove)
             * {
             *  thrust += 3500f * player.directionVec;
             * }
             * if (input.ReverseThrust)
             * {
             *  thrust += -3500f * player.directionVec;
             * }
             * player.netForce = thrust;
             */
        }