Ejemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            CurrentKeyboardState = Keyboard.GetState();

            if (CurrentKeyboardState.IsKeyUp(Keys.T) &&
                PreviousKeyboardState.IsKeyDown(Keys.T))
            {
                index++;
            }

            if (CurrentKeyboardState.IsKeyUp(Keys.G) &&
                PreviousKeyboardState.IsKeyDown(Keys.G))
            {
                index--;
            }

            if (CurrentKeyboardState.IsKeyDown(Keys.Space))
            {
                int p = 0;
            }

            BezList[index].Update(gameTime);


            PreviousKeyboardState = CurrentKeyboardState;
            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        public void Update(GameEngine engine)
        {
            //Console.WriteLine(DeltaScrollWheel);
            //DeltaScrollWheel = 0; //we only want the difference for each frame, the total value is irrelevant

            PreviousKeyboardState.Clear();
            PreviousMouseState.Clear();
            PreviousMousePosition = MousePosition;

            MousePosition = Mouse.GetPosition(engine.Window);
            foreach (KeyValuePair <Keyboard.Key, bool> valuePair in KeyboardState)
            {
                PreviousKeyboardState.Add(valuePair.Key, valuePair.Value);
            }
            foreach (KeyValuePair <Mouse.Button, bool> valuePair in MouseState)
            {
                PreviousMouseState.Add(valuePair.Key, valuePair.Value);
            }

            KeyboardState.Clear();
            MouseState.Clear();
            foreach (Keyboard.Key key in keysEnum)
            {
                KeyboardState.Add(key, CheckKey(key));
            }
            foreach (Mouse.Button button in buttonsEnum)
            {
                MouseState.Add(button, CheckButton(button));
            }
        }
Ejemplo n.º 3
0
        // Any update code which is generic for all Objects of a type.
        public virtual void Update(MouseState mouseState)
        {
            // Button Management
            UpdateMouse(mouseState);

            CurrentKeyboardState = Keyboard.GetState();
            if ((CurrentKeyboardState.IsKeyUp(Keys.Down) && PreviousKeyboardState.IsKeyDown(Keys.Down)) || (CurrentKeyboardState.IsKeyUp(Keys.S) && PreviousKeyboardState.IsKeyDown(Keys.S)))
            {
                if (ButtonIndex < GuiButtonCount - 1)
                {
                    ButtonIndex++;
                }

                ButtonIndexUpdate(ButtonIndex);
            }

            if ((CurrentKeyboardState.IsKeyUp(Keys.Up) && PreviousKeyboardState.IsKeyDown(Keys.Up)) || (CurrentKeyboardState.IsKeyUp(Keys.W) && PreviousKeyboardState.IsKeyDown(Keys.W)))
            {
                if (ButtonIndex > 0)
                {
                    ButtonIndex--;
                }

                ButtonIndexUpdate(ButtonIndex);
            }
            PreviousKeyboardState = CurrentKeyboardState;
        }
Ejemplo n.º 4
0
        public Keys[] GetKeysPressed()
        {
            var         keys        = CurrentKeyboardState.GetPressedKeys();
            var         pkeys       = PreviousKeyboardState.GetPressedKeys();
            List <Keys> pressedKeys = new List <Keys>();

            if (active)
            {
                foreach (var key in keys)
                {
                    bool pressed = true;
                    foreach (var pkey in pkeys)
                    {
                        if (pkey == key)
                        {
                            pressed = false;
                        }
                    }
                    if (pressed)
                    {
                        pressedKeys.Add(key);
                    }
                }
            }

            return(pressedKeys.ToArray());
        }
Ejemplo n.º 5
0
        // Manage the GUI here, all the buttons and player input.
        public void Update(GameTime gameTime)
        {
            backgroundManager.Update();

            CurrentKeyboardState = Keyboard.GetState();
            // Button actions go here
            if ((CurrentKeyboardState.IsKeyUp(Keys.Enter) && PreviousKeyboardState.IsKeyDown(Keys.Enter)) || (CurrentKeyboardState.IsKeyUp(Keys.E) &&
                                                                                                              PreviousKeyboardState.IsKeyDown(Keys.E)))
            {
                if (btnNewGame.IsSelected)
                {
                    Game1.gameState = GameState.Playing;
                }

                //if (btnOptions.IsSelected)
                //Game1.gameState = Game1.GameState.OptionsMenu;

                if (btnExit.IsSelected)
                {
                    Game1.gameState = GameState.Exiting;
                }
            }
            PreviousKeyboardState = Keyboard.GetState();
            guiSystem.Update();
        }
Ejemplo n.º 6
0
 public bool KeyPressed(Keys key)
 {
     if (CurrentKeyboardState.IsKeyDown(key) && PreviousKeyboardState.IsKeyUp(key))
     {
         if (active)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Wurde die aktuelle Taste losgelassen und war sie im letzten Frame noch gedrückt?
 /// </summary>
 public bool KeyReleased(Keys key)
 {
     // Is the key up?
     if (!CurrentKeyboardState.IsKeyDown(key))
     {
         // If down last update, key has just been released.
         if (PreviousKeyboardState.IsKeyDown(key))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Wurde die aktuelle Taste gedrückt und war sie im letzten Frame nicht gedrückt?
 /// </summary>
 public bool KeyPressed(Keys key)
 {
     // Is the key down?
     if (CurrentKeyboardState.IsKeyDown(key))
     {
         // If not down last update, key has just been pressed.
         if (!PreviousKeyboardState.IsKeyDown(key))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 9
0
        internal bool IsKeyReleased(Keys key)
        {
            if (key == Keys.None)
            {
                return(true);
            }

            if (CurrentKeyboardState == null || PreviousKeyboardState == null)
            {
                return(false);
            }

            return((!CurrentKeyboardState.IsKeyDown(key)) && (PreviousKeyboardState.IsKeyDown(key)));
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Given a previous key state of up determine if its been pressed.
 /// </summary>
 /// <param name="name">The name of the keybind.</param>
 /// <returns></returns>
 public bool KeyHit(string name)
 {
     if (!keybinds.ContainsKey(name))
     {
         return(false);
     }
     foreach (var key in keybinds[name])
     {
         if (KeyboardState.IsKeyDown(key) && PreviousKeyboardState.IsKeyUp(key))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets the current number key pressed, returns -1 if none
        /// </summary>
        public int GetDigitPressed()
        {
            var pressedDigitKeys = CurrentKeyboardState.GetPressedKeys()
                                   // Select those that are within D0 and D9
                                   .Where(x => x >= Keys.D0 && x <= Keys.D9)
                                   // Select those that weren't pressed last time
                                   .Where(x => !PreviousKeyboardState.GetPressedKeys().Contains(x)).ToArray();

            if (pressedDigitKeys.Length == 0)
            {
                return(-1);
            }

            // D0 is 9, D1 is 0, D2 is 1, and so on...
            return(pressedDigitKeys[0] == Keys.D0 ? 0 : ((int)pressedDigitKeys[0]) - 48);
        }
Ejemplo n.º 12
0
 public void Update(GameTime gameTime)
 {
     guiSystem.Update();
     CurrentKeyboardState = Keyboard.GetState();
     if ((CurrentKeyboardState.IsKeyUp(Keys.Enter) && PreviousKeyboardState.IsKeyDown(Keys.Enter)) || (CurrentKeyboardState.IsKeyUp(Keys.E) && PreviousKeyboardState.IsKeyDown(Keys.E)))
     {
         if (btnControlUp.IsSelected)
         {
             if (btnReturn.IsSelected)
             {
                 Game1.gameState = GameState.StartMenu;
             }
         }
     }
     PreviousKeyboardState = Keyboard.GetState();
 }
Ejemplo n.º 13
0
        public void Update(GameTime gameTime, GraphicsDevice graphicsDevice)
        {
            backgroundManager.Update();
            CurrentKeyboardState = Keyboard.GetState();
            // Button actions go here
            if ((CurrentKeyboardState.IsKeyUp(Keys.Enter) && PreviousKeyboardState.IsKeyDown(Keys.Enter)) || (CurrentKeyboardState.IsKeyUp(Keys.E) &&
                                                                                                              PreviousKeyboardState.IsKeyDown(Keys.E)))
            {
                if (btnBack.IsSelected)
                {
                    Game1.gameState = GameState.StartMenu;
                }
            }
            PreviousKeyboardState = Keyboard.GetState();

            guiSystem.Update();
        }
Ejemplo n.º 14
0
        public void Update()
        {
            PreviousKeyboardState = CurrentKeyboardState;
            CurrentKeyboardState  = Keyboard.GetState();

            DownKeys.Clear();
            PressedKeys.Clear();
            Keys[] keys = CurrentKeyboardState.GetPressedKeys(); // TODO: per frame heap allocs
            foreach (Keys key in keys)
            {
                if (PreviousKeyboardState.IsKeyUp(key) && IsKeyDown(key))
                {
                    PressedKeys.Add(key);
                }
                //else //if (_previousKeyState.IsKeyDown(key) && _currentKeyState.IsKeyDown(key))
                //    DownKeys.Add(key);
                if (IsKeyDown(key))
                {
                    DownKeys.Add(key);
                }
            }
        }
Ejemplo n.º 15
0
 public static bool IsKeyReleased(Keys key)
 {
     return(PreviousKeyboardState.IsKeyDown(key) &&
            CurrentKeyboardState.IsKeyUp(key));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Checks if all of the keys specified were up last frame
 /// </summary>
 public bool WasAllKeysUp(params Keys[] keys)
 {
     return(keys.All(k => PreviousKeyboardState.IsKeyUp(k)));
 }
Ejemplo n.º 17
0
        protected override void Update(GameTime gameTime)
        {
            CurrentMouseState    = Mouse.GetState();
            CurrentKeyboardState = Keyboard.GetState();

            CollisionsToggle.Update();
            CollisionMaskVisible = CollisionsToggle.Selected;

            TilesToggle.Update();
            TilesVisible = TilesToggle.Selected;

            ObjectsToggle.Update();
            ObjectsVisible = ObjectsToggle.Selected;

            ForegoundToggle.Update();
            ForegroundVisible = ForegoundToggle.Selected;

            BackgroundToggle.Update();
            BackgroundVisible = BackgroundToggle.Selected;

            xSizeSelect.Update();
            ySizeSelect.Update();
            PlaceTileSize = new Vector2(xSizeSelect.CurrentSize, ySizeSelect.CurrentSize);

            #region Update the current mode
            ModeTabs.Update(gameTime);
            CurrentMode = (PlacementMode)(ModeTabs.SelectedIndex);
            #endregion

            #region Load level
            if (PreviousKeyboardState.IsKeyDown(Keys.Enter) &&
                CurrentKeyboardState.IsKeyUp(Keys.Enter))
            {
                //Level.MainTileList.Clear();
                Level = LoadLevel();
                Level.LoadContent(Content);
            }
            #endregion

            #region Save level
            if (PreviousKeyboardState.IsKeyDown(Keys.Space) &&
                CurrentKeyboardState.IsKeyUp(Keys.Space))
            {
                List <Level> LevelList = new List <Level>();
                LevelList.Add(Level);

                SaveLevel(Level);
            }
            #endregion

            switch (CurrentMode)
            {
                #region Tiles Mode
            case PlacementMode.Tiles:
                CurrentTileSelection.Texture = TilesCollection;
                CurrentTileSelection.Update();

                #region Place a new tile
                if (LevelTemplateSprite.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    newTilePosition.X = (CurrentMouseState.X - CurrentMouseState.X % xSizeSelect.CurrentSize);
                }

                if (CurrentMouseState.LeftButton == ButtonState.Pressed &&
                    CurrentMouseState.Y < LevelSizeTemplate.Height &&
                    CurrentMouseState.Y > 0 &&
                    CurrentMouseState.X < LevelSizeTemplate.Width &&
                    CurrentMouseState.X > 0)
                {
                    Vector2 tileXY = newTilePosition / 16;

                    for (int x = 0; x < xSizeSelect.CurrentSize / 16; x++)
                    {
                        for (int y = 0; y < ySizeSelect.CurrentSize / 16; y++)
                        {
                            Tile newTile = new Tile();
                            newTile.Size     = new Vector2(16, 16);
                            newTile.TileChar = new Vector2(SelectedTileIndex.X + x, SelectedTileIndex.Y + y);
                            newTile.Position = new Vector2((tileXY.X + x) * 16, (tileXY.Y + y) * 16);
                            newTile.LoadContent(Content);

                            Level.MainTileList[(int)tileXY.Y + y][(int)tileXY.X + x] = newTile;
                        }
                    }
                }

                #region Fill
                if (CurrentKeyboardState.IsKeyUp(Keys.F) == true &&
                    PreviousKeyboardState.IsKeyDown(Keys.F) == true)
                {
                }
                #endregion
                #endregion

                #region Select another tile
                if (CurrentMouseState.LeftButton == ButtonState.Released &&
                    PreviousMouseState.LeftButton == ButtonState.Pressed &&
                    CurrentTileSelection.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    if (CurrentMouseState.Y >= LevelSizeTemplate.Height + 32)
                    {
                        SelectedTilePosition = new Vector2(CurrentMouseState.X - CurrentMouseState.X % 16, CurrentMouseState.Y - CurrentMouseState.Y % 16);
                        SelectedTileIndex.X  = (int)(SelectedTilePosition.X / 16);
                        SelectedTileIndex.Y  = (int)(SelectedTilePosition.Y - LevelSizeTemplate.Height - 32) / 16;
                    }
                }
                #endregion

                #region Remove tile by right clicking
                if (LevelTemplateSprite.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    newTilePosition = new Vector2((CurrentMouseState.X - CurrentMouseState.X % xSizeSelect.CurrentSize), (CurrentMouseState.Y - CurrentMouseState.Y % ySizeSelect.CurrentSize));
                }

                if (CurrentMouseState.RightButton == ButtonState.Pressed &&
                    CurrentMouseState.Y < LevelSizeTemplate.Height &&
                    CurrentMouseState.Y > 0 &&
                    CurrentMouseState.X < LevelSizeTemplate.Width &&
                    CurrentMouseState.X > 0)
                {
                    Vector2 tileXY = newTilePosition / 16;

                    for (int x = 0; x < xSizeSelect.CurrentSize / 16; x++)
                    {
                        for (int y = 0; y < ySizeSelect.CurrentSize / 16; y++)
                        {
                            Tile newTile = new Tile();
                            newTile.TileChar = new Vector2(0, 0);
                            newTile.LoadContent(Content);

                            Level.MainTileList[(int)tileXY.Y + y][(int)tileXY.X + x] = newTile;
                        }
                    }
                }
                #endregion

                break;
                #endregion

                #region Collisions Mode
            case PlacementMode.Collision:
                CurrentTileSelection.Texture = CollisionTiles;
                CurrentTileSelection.Update();

                #region Place a new collision tile
                if (LevelTemplateSprite.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    newTilePosition = new Vector2((CurrentMouseState.X - CurrentMouseState.X % xSizeSelect.CurrentSize), (CurrentMouseState.Y - CurrentMouseState.Y % ySizeSelect.CurrentSize));
                }

                if (CurrentMouseState.LeftButton == ButtonState.Pressed &&
                    CurrentMouseState.Y < LevelSizeTemplate.Height &&
                    CurrentMouseState.Y > 0 &&
                    CurrentMouseState.X < LevelSizeTemplate.Width &&
                    CurrentMouseState.X > 0)
                {
                    Vector2 tileXY = newTilePosition / 16;

                    CollisionTile newCollision = new CollisionTile();
                    newCollision.Position = new Vector2(tileXY.X * 16, tileXY.Y * 16);
                    newCollision.Size     = new Vector2(xSizeSelect.CurrentSize, ySizeSelect.CurrentSize);
                    newCollision.TileChar = SelectedTileIndex;
                    newCollision.LoadContent(Content);

                    //Stops the ability to place multiple collision tiles on top of one another
                    if (Level.CollisionTileList.Find(Tile => Tile.Position == new Vector2(tileXY.X * 16, tileXY.Y * 16)) == null)
                    {
                        Level.CollisionTileList.Add(newCollision);
                    }
                    else
                    {
                        Level.CollisionTileList.RemoveAt(Level.CollisionTileList.FindIndex(Tile => Tile.Position == new Vector2(tileXY.X * 16, tileXY.Y * 16)));
                        Level.CollisionTileList.Add(newCollision);
                    }
                }
                #endregion

                #region Select another tile
                if (CurrentMouseState.LeftButton == ButtonState.Released &&
                    PreviousMouseState.LeftButton == ButtonState.Pressed &&
                    CurrentTileSelection.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    if (CurrentMouseState.Y >= LevelSizeTemplate.Height)
                    {
                        SelectedTilePosition = new Vector2(CurrentMouseState.X - CurrentMouseState.X % 16, CurrentMouseState.Y - CurrentMouseState.Y % 16);
                        SelectedTileIndex.X  = (int)(SelectedTilePosition.X / 16);
                        SelectedTileIndex.Y  = (int)(SelectedTilePosition.Y - LevelSizeTemplate.Height - 16) / 16;
                    }
                }
                #endregion

                if (CurrentMouseState.RightButton == ButtonState.Pressed &&
                    CurrentMouseState.Y < LevelSizeTemplate.Height &&
                    CurrentMouseState.Y > 0 &&
                    CurrentMouseState.X < LevelSizeTemplate.Width &&
                    CurrentMouseState.X > 0)
                {
                    if (Level.CollisionTileList.Exists(Tile => Tile.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y))))
                    {
                        int removeIndex = Level.CollisionTileList.FindIndex(Tile => Tile.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)));
                        Level.CollisionTileList.RemoveAt(removeIndex);
                    }
                }
                break;
                #endregion

                #region Foreground
            case PlacementMode.Foreground:
                CurrentTileSelection.Texture = TilesCollection;
                CurrentTileSelection.Update();

                #region Place a new tile
                if (LevelTemplateSprite.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    newTilePosition = new Vector2((CurrentMouseState.X - CurrentMouseState.X % xSizeSelect.CurrentSize), (CurrentMouseState.Y - CurrentMouseState.Y % ySizeSelect.CurrentSize));
                }

                if (CurrentMouseState.LeftButton == ButtonState.Pressed &&
                    CurrentMouseState.Y < LevelSizeTemplate.Height &&
                    CurrentMouseState.Y > 0 &&
                    CurrentMouseState.X < LevelSizeTemplate.Width &&
                    CurrentMouseState.X > 0)
                {
                    Vector2 tileXY = newTilePosition / 16;

                    for (int x = 0; x < xSizeSelect.CurrentSize / 16; x++)
                    {
                        for (int y = 0; y < ySizeSelect.CurrentSize / 16; y++)
                        {
                            Tile newTile = new Tile();
                            newTile.Size     = new Vector2(16, 16);
                            newTile.TileChar = new Vector2(SelectedTileIndex.X + x, SelectedTileIndex.Y + y);
                            newTile.Position = new Vector2((tileXY.X + x) * 16, (tileXY.Y + y) * 16);
                            newTile.LoadContent(Content);

                            Level.ForegroundTileList[(int)tileXY.Y + y][(int)tileXY.X + x] = newTile;
                        }
                    }
                }
                #endregion

                #region Select another tile
                if (CurrentMouseState.LeftButton == ButtonState.Released &&
                    PreviousMouseState.LeftButton == ButtonState.Pressed &&
                    CurrentTileSelection.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    if (CurrentMouseState.Y >= LevelSizeTemplate.Height + 32)
                    {
                        SelectedTilePosition = new Vector2(CurrentMouseState.X - CurrentMouseState.X % 16, CurrentMouseState.Y - CurrentMouseState.Y % 16);
                        SelectedTileIndex.X  = (int)(SelectedTilePosition.X / 16);
                        SelectedTileIndex.Y  = (int)(SelectedTilePosition.Y - LevelSizeTemplate.Height - 32) / 16;
                    }
                }
                #endregion

                #region Remove tile by right clicking
                if (LevelTemplateSprite.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    newTilePosition = new Vector2((CurrentMouseState.X - CurrentMouseState.X % xSizeSelect.CurrentSize), (CurrentMouseState.Y - CurrentMouseState.Y % ySizeSelect.CurrentSize));
                }

                if (CurrentMouseState.RightButton == ButtonState.Pressed &&
                    CurrentMouseState.Y < LevelSizeTemplate.Height &&
                    CurrentMouseState.Y > 0 &&
                    CurrentMouseState.X < LevelSizeTemplate.Width &&
                    CurrentMouseState.X > 0)
                {
                    Vector2 tileXY = newTilePosition / 16;

                    for (int x = 0; x < xSizeSelect.CurrentSize / 16; x++)
                    {
                        for (int y = 0; y < ySizeSelect.CurrentSize / 16; y++)
                        {
                            Tile newTile = new Tile();
                            newTile.TileChar = new Vector2(0, 0);
                            newTile.LoadContent(Content);

                            Level.ForegroundTileList[(int)tileXY.Y + y][(int)tileXY.X + x] = newTile;
                        }
                    }
                }
                #endregion
                break;
                #endregion

                #region Background
            case PlacementMode.Background:
                CurrentTileSelection.Texture = TilesCollection;
                CurrentTileSelection.Update();

                #region Place a new tile
                if (LevelTemplateSprite.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    newTilePosition = new Vector2((CurrentMouseState.X - CurrentMouseState.X % xSizeSelect.CurrentSize), (CurrentMouseState.Y - CurrentMouseState.Y % ySizeSelect.CurrentSize));
                }

                if (CurrentMouseState.LeftButton == ButtonState.Pressed &&
                    CurrentMouseState.Y < LevelSizeTemplate.Height &&
                    CurrentMouseState.Y > 0 &&
                    CurrentMouseState.X < LevelSizeTemplate.Width &&
                    CurrentMouseState.X > 0)
                {
                    Vector2 tileXY = newTilePosition / 16;

                    for (int x = 0; x < xSizeSelect.CurrentSize / 16; x++)
                    {
                        for (int y = 0; y < ySizeSelect.CurrentSize / 16; y++)
                        {
                            Tile newTile = new Tile();
                            newTile.Size     = new Vector2(16, 16);
                            newTile.TileChar = new Vector2(SelectedTileIndex.X + x, SelectedTileIndex.Y + y);
                            newTile.Position = new Vector2((tileXY.X + x) * 16, (tileXY.Y + y) * 16);
                            newTile.LoadContent(Content);

                            Level.BackgroundTileList[(int)tileXY.Y + y][(int)tileXY.X + x] = newTile;
                        }
                    }
                }
                #endregion

                #region Select another tile
                if (CurrentMouseState.LeftButton == ButtonState.Released &&
                    PreviousMouseState.LeftButton == ButtonState.Pressed &&
                    CurrentTileSelection.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    if (CurrentMouseState.Y >= LevelSizeTemplate.Height + 32)
                    {
                        SelectedTilePosition = new Vector2(CurrentMouseState.X - CurrentMouseState.X % 16, CurrentMouseState.Y - CurrentMouseState.Y % 16);
                        SelectedTileIndex.X  = (int)(SelectedTilePosition.X / 16);
                        SelectedTileIndex.Y  = (int)(SelectedTilePosition.Y - LevelSizeTemplate.Height - 32) / 16;
                    }
                }
                #endregion

                #region Remove tile by right clicking
                if (LevelTemplateSprite.DestinationRectangle.Contains(new Point(CurrentMouseState.X, CurrentMouseState.Y)))
                {
                    newTilePosition = new Vector2((CurrentMouseState.X - CurrentMouseState.X % xSizeSelect.CurrentSize), (CurrentMouseState.Y - CurrentMouseState.Y % ySizeSelect.CurrentSize));
                }

                if (CurrentMouseState.RightButton == ButtonState.Pressed &&
                    CurrentMouseState.Y < LevelSizeTemplate.Height &&
                    CurrentMouseState.Y > 0 &&
                    CurrentMouseState.X < LevelSizeTemplate.Width &&
                    CurrentMouseState.X > 0)
                {
                    Vector2 tileXY = newTilePosition / 16;

                    for (int x = 0; x < xSizeSelect.CurrentSize / 16; x++)
                    {
                        for (int y = 0; y < ySizeSelect.CurrentSize / 16; y++)
                        {
                            Tile newTile = new Tile();
                            newTile.TileChar = new Vector2(0, 0);
                            newTile.LoadContent(Content);

                            Level.BackgroundTileList[(int)tileXY.Y + y][(int)tileXY.X + x] = newTile;
                        }
                    }
                }
                #endregion
                break;
                #endregion
            }

            PreviousKeyboardState = CurrentKeyboardState;
            PreviousMouseState    = CurrentMouseState;
            base.Update(gameTime);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Update method
        /// </summary>
        /// <param name="gameTime"></param>
        protected override void Update(GameTime gameTime)
        {
            if (this.Name == "OptionsSelectionFrame")
            {
                string currentPosition = null;

                foreach (KeyValuePair <string, Vector2> keyValuePair in optionMenuDictionary)
                {
                    if ((
                            (keyValuePair.Value.X - 20 == this.DrawLocation.X)
                            ) && (
                            (keyValuePair.Value.Y - 15 == this.DrawLocation.Y)
                            ) && (
                            (keyValuePair.Key != "OptionSelectionFrame")
                            ))
                    {
                        currentPosition = keyValuePair.Key;                                 // Find the current index of the selection bar
                    }
                }
                // Move the selection bar based on key pressed
                if (CurrentKeyboardState.IsKeyDown(Keys.Down) && PreviousKeyboardState.IsKeyUp(Keys.Down))
                {
                    SoundEffectInstances["MenuMove"].Play();

                    switch (currentPosition)
                    {
                    case "Music":
                        base.CreateRectangle(
                            (int)(optionMenuDictionary["SFX"].X - 20),
                            (int)(optionMenuDictionary["SFX"].Y - 15)
                            );

                        break;
                    }
                }
                else if (CurrentKeyboardState.IsKeyDown(Keys.Up) && PreviousKeyboardState.IsKeyUp(Keys.Up))
                {
                    SoundEffectInstances["MenuMove"].Play();

                    switch (currentPosition)
                    {
                    case "SFX":
                        base.CreateRectangle(
                            (int)(optionMenuDictionary["Music"].X - 20),
                            (int)(optionMenuDictionary["Music"].Y - 15)
                            );

                        break;
                    }
                }
                else if (CurrentKeyboardState.IsKeyDown(Keys.Right) && PreviousKeyboardState.IsKeyUp(Keys.Right))
                {
                    switch (currentPosition)
                    {
                    case "Music":
                        if (SoundEffectInstances["BackgroundMusic"].Volume < 0.9f)          // Move the side scrolling volume controls

                        {
                            SoundEffectInstances["BackgroundMusic"].Volume += 0.1f;

                            foreach (Option menuOption in OptionElements)
                            {
                                if (menuOption.Name == "MusicSlider")
                                {
                                    menuOption.CreateRectangle(                             // Adjust the volume
                                        (int)(optionMenuDictionary["MusicSlider"].X + 10),
                                        (int)(optionMenuDictionary["MusicSlider"].Y)
                                        );

                                    optionMenuDictionary["MusicSlider"] = new Vector2(
                                        (int)(optionMenuDictionary["MusicSlider"].X + 10),
                                        (int)(optionMenuDictionary["MusicSlider"].Y)
                                        );

                                    SoundEffectInstances["MenuMove"].Play();
                                }
                            }
                        }
                        else
                        {
                            SoundEffectInstances["Error"].Play();
                        }

                        break;

                    case "SFX":
                        bool movedSlider = false;

                        foreach (KeyValuePair <string, SoundEffectInstance> keyValuePair in SoundEffectInstances)
                        {
                            if (keyValuePair.Key != "BackgroundMusic")
                            {
                                if (keyValuePair.Value.Volume < 0.9f)                       // Move the side scrolling volume controls
                                {
                                    keyValuePair.Value.Volume += 0.1f;

                                    if (!movedSlider)
                                    {
                                        foreach (Option menuOption in OptionElements)
                                        {
                                            if (menuOption.Name == "SFXSlider")
                                            {
                                                menuOption.CreateRectangle(                 // Adjust the volume
                                                    (int)(optionMenuDictionary["SFXSlider"].X + 10),
                                                    (int)(optionMenuDictionary["SFXSlider"].Y)
                                                    );

                                                optionMenuDictionary["SFXSlider"] = new Vector2(
                                                    (int)(optionMenuDictionary["SFXSlider"].X + 10),
                                                    (int)(optionMenuDictionary["SFXSlider"].Y)
                                                    );

                                                SoundEffectInstances["MenuMove"].Play();
                                            }
                                        }

                                        movedSlider = true;
                                    }
                                }
                                else
                                {
                                    SoundEffectInstances["Error"].Play();
                                }
                            }
                        }

                        break;

                    case "Difficulty":
                        break;
                    }
                }
                else if (CurrentKeyboardState.IsKeyDown(Keys.Left) && PreviousKeyboardState.IsKeyUp(Keys.Left))
                {
                    switch (currentPosition)
                    {
                    case "Music":
                        if (SoundEffectInstances["BackgroundMusic"].Volume > 0.1f)          // Move the side scrolling volume controls
                        {
                            SoundEffectInstances["BackgroundMusic"].Volume -= 0.1f;

                            foreach (Option menuOption in OptionElements)
                            {
                                if (menuOption.Name == "MusicSlider")
                                {
                                    menuOption.CreateRectangle(                             // Adjust the volume
                                        (int)(optionMenuDictionary["MusicSlider"].X - 10),
                                        (int)(optionMenuDictionary["MusicSlider"].Y)
                                        );

                                    optionMenuDictionary["MusicSlider"] = new Vector2(
                                        (int)(optionMenuDictionary["MusicSlider"].X - 10),
                                        (int)(optionMenuDictionary["MusicSlider"].Y)
                                        );

                                    SoundEffectInstances["MenuMove"].Play();
                                }
                            }
                        }
                        else
                        {
                            SoundEffectInstances["Error"].Play();
                        }

                        break;

                    case "SFX":
                        bool movedSlider = false;

                        foreach (KeyValuePair <string, SoundEffectInstance> keyValuePair in SoundEffectInstances)
                        {
                            if (keyValuePair.Key != "BackgroundMusic")
                            {
                                if (keyValuePair.Value.Volume > 0.1f)                       // Move the side scrolling volume controls
                                {
                                    keyValuePair.Value.Volume -= 0.1f;

                                    if (!movedSlider)
                                    {
                                        foreach (Option menuOption in OptionElements)
                                        {
                                            if (menuOption.Name == "SFXSlider")
                                            {
                                                menuOption.CreateRectangle(                 // Adjust the volume
                                                    (int)(optionMenuDictionary["SFXSlider"].X - 10),
                                                    (int)(optionMenuDictionary["SFXSlider"].Y)
                                                    );

                                                optionMenuDictionary["SFXSlider"] = new Vector2(
                                                    (int)(optionMenuDictionary["SFXSlider"].X - 10),
                                                    (int)(optionMenuDictionary["SFXSlider"].Y)
                                                    );

                                                SoundEffectInstances["MenuMove"].Play();
                                            }
                                        }

                                        movedSlider = true;
                                    }
                                }
                                else
                                {
                                    SoundEffectInstances["Error"].Play();
                                }
                            }
                        }

                        break;
                    }
                }
            }
        }
Ejemplo n.º 19
0
 public bool IsNewKeyRelease(Keys key)
 {
     return(PreviousKeyboardState.IsKeyDown(key) && KeyboardState.IsKeyUp(key));
 }
Ejemplo n.º 20
0
 /// <summary>
 ///   Helper for checking if a key was newly pressed during this update.
 /// </summary>
 public bool IsNewKeyPress(Keys key)
 {
     return(KeyboardState.IsKeyDown(key) && PreviousKeyboardState.IsKeyUp(key));
 }
Ejemplo n.º 21
0
 public static bool WasKeyJustPressed(Keys key)
 {
     return(PreviousKeyboardState.IsKeyUp(key) && CurrentKeyboardState.IsKeyDown(key));
 }
 public bool PressedKey(Keys key)
 {
     return(PreviousKeyboardState.IsKeyUp(key) && CurrentKeyboardState.IsKeyDown(key));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Update method
        /// </summary>
        /// <param name="gameTime"></param>
        protected override void Update(GameTime gameTime)
        {
            if (this.Name == "TitleSelectionFrame")
            {
                string currentPosition = null;

                foreach (KeyValuePair <string, Vector2> keyValuePair in titleMenuDictionary) // Find the current position of the menu selection image
                {
                    if ((
                            (keyValuePair.Value.X == this.DrawLocation.X)
                            ) && (
                            (keyValuePair.Value.Y == this.DrawLocation.Y)
                            ) && (
                            (keyValuePair.Key != "TitleSelectionFrame")
                            ))
                    {
                        currentPosition = keyValuePair.Key;
                    }
                }

                // Move the image down if the down key is pressed
                if (CurrentKeyboardState.IsKeyDown(Keys.Down) && PreviousKeyboardState.IsKeyUp(Keys.Down))
                {
                    SoundEffectInstances["MenuMove"].Play();

                    switch (currentPosition)
                    {
                    case "NewGame":
                        base.CreateRectangle(titleMenuDictionary["LevelEditor"]);

                        break;

                    case "LevelEditor":
                        base.CreateRectangle(titleMenuDictionary["Options"]);

                        break;
                    }
                }// Move the image up if the up key is pressed
                else if (CurrentKeyboardState.IsKeyDown(Keys.Up) && PreviousKeyboardState.IsKeyUp(Keys.Up))
                {
                    SoundEffectInstances["MenuMove"].Play();

                    switch (currentPosition)
                    {
                    case "LevelEditor":
                        base.CreateRectangle(titleMenuDictionary["NewGame"]);

                        break;

                    case "Options":
                        base.CreateRectangle(titleMenuDictionary["LevelEditor"]);

                        break;
                    }
                }// Go into the menu if the enter key is pressed
                else if (CurrentKeyboardState.IsKeyDown(Keys.Enter) && PreviousKeyboardState.IsKeyUp(Keys.Enter))
                {
                    switch (currentPosition)
                    {
                    case "NewGame":
                        gameState = GameState.InGame;

                        break;

                    case "LevelEditor":
                        gameState = GameState.LevelEditor;

                        break;

                    case "Options":
                        gameState = GameState.Options;

                        break;
                    }
                }
            }
        }
Ejemplo n.º 24
0
 public static bool KeyPressed(Keys key)
 {
     return(KeyboardState.IsKeyDown(key) && PreviousKeyboardState.IsKeyUp(key));
 }
Ejemplo n.º 25
0
        protected override void Update(GameTime gameTime)
        {
            MouseState    m = Mouse.GetState();
            KeyboardState k = Keyboard.GetState();

            if (k.GetPressedKeys().Contains(Keys.Space) && !PreviousKeyboardState.GetPressedKeys().Contains(Keys.Space))
            {
                playing = (!playing) ? true : false;
            }

            PreviousKeyboardState = k;

            if (m.LeftButton == ButtonState.Pressed)
            {
                if (!playing && !clickOccured)
                {
                    int x = m.X / gridSize;
                    int y = m.Y / gridSize;

                    if (x > 0 && x < (rows / gridSize) - 1 && y > 0 && y < (cols / gridSize) - 1)
                    {
                        if (LifeMatrix[x, y] != 1)
                        {
                            LifeMatrix[x, y] = 1;
                        }
                        else
                        {
                            LifeMatrix[x, y] = 0;
                        }
                    }

                    clickOccured = true;
                }
            }
            else if (m.LeftButton == ButtonState.Released)
            {
                clickOccured = false;
            }


            if (playing)
            {
                int[,] GenMatrix = new int[cols / gridSize, rows / gridSize];

                for (uint x = 0; x < cols / gridSize; x++)
                {
                    for (uint y = 0; y < rows / gridSize; y++)
                    {
                        int topLeft     = (x != 0 && y != 0) ? LifeMatrix[x - 1, y - 1] : 0;
                        int topRight    = (x != (cols / gridSize) - 1 && y != 0) ? LifeMatrix[x + 1, y - 1] : 0;
                        int bottomLeft  = (x != 0 && y != (rows / gridSize) - 1) ? LifeMatrix[x - 1, y + 1] : 0;
                        int bottomRight = (x != (cols / gridSize) - 1 && y != (rows / gridSize) - 1) ? LifeMatrix[x + 1, y + 1] : 0;

                        int bottom = (y != (rows / gridSize) - 1) ? LifeMatrix[x, y + 1] : 0;
                        int right  = (x != (cols / gridSize) - 1) ? LifeMatrix[x + 1, y] : 0;
                        int top    = (y != 0) ? LifeMatrix[x, y - 1] : 0;
                        int left   = (x != 0) ? LifeMatrix[x - 1, y] : 0;

                        int sum = topLeft + topRight + bottomLeft + bottomRight + bottom + top + left + right;

                        if ((sum == 2 || sum == 3) && LifeMatrix[x, y] == 1) //if alive and surrounded by at least 2 living ones, stay alive
                        {
                            GenMatrix[x, y] = 1;
                        }

                        if (sum == 3 && LifeMatrix[x, y] == 0) //if surrounded by 3 living ones and is dead:
                        {
                            //this one is now alive
                            GenMatrix[x, y] = 1;
                        }

                        if (sum > 3) //more than 4 around it, overpopulation so:
                        {
                            //this one dies
                            GenMatrix[x, y] = 0;
                        }
                    }
                }

                LifeMatrix = GenMatrix; //set it to new generation
            }

            base.Update(gameTime);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Returns all the keys which were not down last frame, but are up now
        /// </summary>
        /// <returns></returns>
        public Keys[] GetPressedKeys()
        {
            if (!calculatedPressedKeys)
            {
                // Get all the keys in thisFrame that weren't in last frame
                PressedKeys           = Array.FindAll(CurrentKeyboardState.GetPressedKeys(), x => Array.IndexOf(PreviousKeyboardState.GetPressedKeys(), x) == -1);
                calculatedPressedKeys = true;
            }

            return(PressedKeys);
        }
Ejemplo n.º 27
0
        public bool IsInputPressed(Keys key)
        {
            KeyboardState keyboardState = Keyboard.GetState();
            GamePadState  gamePadState  = GamePad.GetState(PlayerIndex.One);

            //Enter/Accept/Debug has the same logic for UI and in game.
            if (key == Keys.Enter && ((keyboardState.IsKeyDown(Keys.Space) && !PreviousKeyboardState.IsKeyDown(Keys.Space)) ||
                                      (keyboardState.IsKeyDown(Keys.Enter) && !PreviousKeyboardState.IsKeyDown(Keys.Enter)) ||
                                      (gamePadState.IsButtonDown(Buttons.A) && !PreviousGamePadState.IsButtonDown(Buttons.A)) ||
                                      (gamePadState.IsButtonDown(Buttons.Start) && !PreviousGamePadState.IsButtonDown(Buttons.Start))))
            {
                return(true);
            }
            else if (key == Keys.Home && ((keyboardState.IsKeyDown(Keys.Home) && !PreviousKeyboardState.IsKeyDown(Keys.Home) ||
                                           (gamePadState.IsButtonDown(Buttons.Back) && !PreviousGamePadState.IsButtonDown(Buttons.Back)))))
            {
                return(true);
            }
            else if (TheLastSliceGame.Instance.GameState == GameState.Menu)
            {
                //For menus we need to check the previous state of the input.
                if (key == Keys.Up && ((keyboardState.IsKeyDown(Keys.Up) && !PreviousKeyboardState.IsKeyDown(Keys.Up)) ||
                                       (keyboardState.IsKeyDown(Keys.W) && !PreviousKeyboardState.IsKeyDown(Keys.W)) ||
                                       (gamePadState.IsButtonDown(Buttons.DPadUp) && !PreviousGamePadState.IsButtonDown(Buttons.DPadUp)) ||
                                       (gamePadState.ThumbSticks.Left.Y > 0.2 && PreviousGamePadState.ThumbSticks.Left.Y < 0.2)))
                {
                    return(true);
                }
                else if (key == Keys.Down && ((keyboardState.IsKeyDown(Keys.Down) && !PreviousKeyboardState.IsKeyDown(Keys.Down)) ||
                                              (keyboardState.IsKeyDown(Keys.S) && !PreviousKeyboardState.IsKeyDown(Keys.S)) ||
                                              (gamePadState.IsButtonDown(Buttons.DPadDown) && !PreviousGamePadState.IsButtonDown(Buttons.DPadDown)) ||
                                              (gamePadState.ThumbSticks.Left.Y < -0.2 && PreviousGamePadState.ThumbSticks.Left.Y > -0.2)))
                {
                    return(true);
                }
                else if (keyboardState.IsKeyDown(key) && !PreviousKeyboardState.IsKeyDown(key))
                {
                    return(true);
                }
            }
            else
            {
                if (key == Keys.Up && (keyboardState.IsKeyDown(Keys.Up) || keyboardState.IsKeyDown(Keys.W) ||
                                       gamePadState.IsButtonDown(Buttons.DPadUp) || gamePadState.ThumbSticks.Left.Y > 0.2))
                {
                    return(true);
                }
                else if (key == Keys.Down && (keyboardState.IsKeyDown(Keys.Down) || keyboardState.IsKeyDown(Keys.S) ||
                                              gamePadState.IsButtonDown(Buttons.DPadDown) || gamePadState.ThumbSticks.Left.Y < -0.2))
                {
                    return(true);
                }
                else if (key == Keys.Left && (keyboardState.IsKeyDown(Keys.Left) || keyboardState.IsKeyDown(Keys.A) ||
                                              gamePadState.IsButtonDown(Buttons.DPadLeft) || gamePadState.ThumbSticks.Left.X < -0.2))
                {
                    return(true);
                }
                else if (key == Keys.Right && (keyboardState.IsKeyDown(Keys.Right) || keyboardState.IsKeyDown(Keys.D) ||
                                               gamePadState.IsButtonDown(Buttons.DPadRight) || gamePadState.ThumbSticks.Left.X > 0.2))
                {
                    return(true);
                }
                else if (keyboardState.IsKeyDown(key) && !PreviousKeyboardState.IsKeyDown(key))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Applies movement to the player character
        /// </summary>
        /// <param name="gameTime"></param>
        /// <returns>The new rectangle where the character needs to be drawn</returns>
        public override Vector2 ApplyMovement(GameTime gameTime)
        {
            Vector2 returnValue;

            // Apply movement based on keys pressed
            if ((CurrentKeyboardState.IsKeyDown(Keys.A)) && (PreviousKeyboardState.IsKeyUp(Keys.A)) ||
                (CurrentKeyboardState.IsKeyDown(Keys.Left)) && (PreviousKeyboardState.IsKeyUp(Keys.Left)))
            {
                base.MovementAppliedTo = MovementAppliedTo.Left;
                base.SpriteEffect      = SpriteEffects.FlipHorizontally;
            }
            else if ((CurrentKeyboardState.IsKeyDown(Keys.D)) && (PreviousKeyboardState.IsKeyUp(Keys.D)) ||
                     (CurrentKeyboardState.IsKeyDown(Keys.Right)) && (PreviousKeyboardState.IsKeyUp(Keys.Right)))
            {
                base.MovementAppliedTo = MovementAppliedTo.Right;
                base.SpriteEffect      = SpriteEffects.None;
            }
            else if ((CurrentKeyboardState.IsKeyUp(Keys.A)) && (PreviousKeyboardState.IsKeyDown(Keys.A)) ||
                     (CurrentKeyboardState.IsKeyUp(Keys.Left)) && (PreviousKeyboardState.IsKeyDown(Keys.Left)))
            {
                if ((!base.JumpInProgress) && (!base.HasJumped))
                {
                    base.MovementAppliedTo = MovementAppliedTo.None;
                }
            }
            else if ((CurrentKeyboardState.IsKeyUp(Keys.D)) && (PreviousKeyboardState.IsKeyDown(Keys.D)) ||
                     (CurrentKeyboardState.IsKeyUp(Keys.Right)) && (PreviousKeyboardState.IsKeyDown(Keys.Right)))
            {
                if ((!base.JumpInProgress) && (!base.HasJumped))
                {
                    base.MovementAppliedTo = MovementAppliedTo.None;
                    base.SpriteEffect      = SpriteEffects.None;
                }
            }
            // Implement the jump feature
            if (base.GravityDirection == GravityDirection.Down)
            {
                if (((CurrentKeyboardState.IsKeyDown(Keys.Space)) && (PreviousKeyboardState.IsKeyUp(Keys.Space)) ||
                     (CurrentKeyboardState.IsKeyDown(Keys.Up)) && (PreviousKeyboardState.IsKeyUp(Keys.Up))) &&
                    ((base.HitObstacle == HitObstacle.FromTop) || (this.JumpCount == 1)))
                {
                    base.TimeSinceJump = gameTime.ElapsedGameTime.Milliseconds;

                    base.MovementAppliedTo = MovementAppliedTo.Up;

                    base.HitObstacle = HitObstacle.None;

                    if (this.PlatformVerticalAcceleration > 0)
                    {
                        base.GravitationalVelocity -= this.PlatformVerticalAcceleration;
                    }

                    if (base.HasJumped == false)
                    {
                        base.HasJumped = true;
                        SoundEffectInstances["JumpSound"].Play();
                    }

                    if (base.JumpInProgress == false)
                    {
                        base.JumpInProgress = true;
                    }
                }
            }
            else if (base.GravityDirection == GravityDirection.Up)
            {
                if (((CurrentKeyboardState.IsKeyDown(Keys.Space)) && (PreviousKeyboardState.IsKeyUp(Keys.Space)) ||
                     (CurrentKeyboardState.IsKeyUp(Keys.Up)) && (PreviousKeyboardState.IsKeyDown(Keys.Up))) &&
                    ((base.HitObstacle == HitObstacle.FromTop) || (this.JumpCount == 1)))
                {
                    base.MovementAppliedTo = MovementAppliedTo.Down;

                    base.HitObstacle = HitObstacle.None;

                    if (base.HasJumped == false)
                    {
                        base.HasJumped = true;
                    }

                    if (base.JumpInProgress == false)
                    {
                        base.JumpInProgress = true;
                    }
                }
            }
            // Cancel movement if nothing is being pressed (because of velocity)
            if ((CurrentKeyboardState.IsKeyUp(Keys.A)) && (CurrentKeyboardState.IsKeyUp(Keys.D)) &&
                (CurrentKeyboardState.IsKeyUp(Keys.Left)) && (CurrentKeyboardState.IsKeyUp(Keys.Right)) &&
                (base.Falling == false) && (base.HasJumped == false) && (base.JumpInProgress == false))
            {
                base.MovementAppliedTo = MovementAppliedTo.None;
            }
            // Attempt at working with gametime
            if (base.TimeSinceLastUpdate > 100)
            {
                this.UpdateSprite();
                base.SelectSprite(base.CurrentSpriteIndex);

                base.TimeSinceLastUpdate = 0;
            }

            base.CalculateGravity(gameTime);
            base.CalculateMovement(gameTime);

            returnValue = new Vector2(
                this.DrawLocation.X + base.MovementVelocity,
                this.DrawLocation.Y + base.GravitationalVelocity
                );

            return(returnValue);
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Queries the current and previous keyboard states to work out whether a key has been pressed
 /// </summary>
 /// <param name="key">The key we wish to query</param>
 /// <returns>Returns true if the key is down this frame and up the previous frame</returns>
 public bool IsKeyPressed(Keys key)
 {
     return(CurrentKeyboardState.IsKeyDown(key) && PreviousKeyboardState.IsKeyUp(key));
 }
Ejemplo n.º 30
0
 public static bool IsKeyPressed(Keys key) => CurrentKeyboardState.IsKeyDown(key) && PreviousKeyboardState.IsKeyUp(key);