Ejemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Read the keypresses
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void UpdateInput(GameTime gameTime, Camera camera)
        {
            currentDirection = LevelLibrary.Directions.none;
            jumpKeyPressed = false;
            KeyboardState newState = Keyboard.GetState();

            camera.Update(gameTime, newState, oldState);

            // Is the Q key down?
            if (newState.IsKeyDown(jumpKeyMapping))
            {
                jumpKeyPressed = true;
            }
            else if (newState.IsKeyDown(leftKeyMapping))
            {
                currentDirection = LevelLibrary.Directions.left;
            }
            else if (newState.IsKeyDown(rightKeyMapping))
            {
                currentDirection = LevelLibrary.Directions.right;
            }
            else if (newState.IsKeyDown(exitKeyMapping))
            {
                exitKeyPressed = true;
            }
            else if (newState.IsKeyDown(fullKeyMapping))
            {
                fullScreenPressed = true;
            }

            // Update saved state.
            oldState = newState;
        }
Ejemplo n.º 2
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()
        {
            // TODO: Add your initialization logic here
            // Initialize the player class
            player = new Player();
            input = new Input();
            mainbg   = new ParallaxingBackground();
            bgLayer1 = new ParallaxingBackground();
            bgLayer2 = new ParallaxingBackground();
            levelRenderer = new LevelLibrary.LevelRenderer();

            // Camera that follows the player
            camera = new Camera(GraphicsDevice.Viewport, Vector2.Zero);
            camera.Follow(player, 0f);
            hud = new HUDisplay();

            base.Initialize();
        }