/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { inputHelper.Update(); if (inputHelper.IsNewKeyPress(Keys.Escape)) { Exit(); } if (inputHelper.IsNewKeyPress(Keys.Left) && movement.X == 0) { movement.X = -1; movement.Y = 0; } if (inputHelper.IsNewKeyPress(Keys.Right) && movement.X == 0) { movement.X = 1; movement.Y = 0; } if (inputHelper.IsNewKeyPress(Keys.Up) && movement.Y == 0) { movement.X = 0; movement.Y = -1; } if (inputHelper.IsNewKeyPress(Keys.Down) && movement.Y == 0) { movement.X = 0; movement.Y = 1; } player.Update(movement, graphics, appleRect); base.Update(gameTime); }
public override void Sprawdzanie() { helper.Update(); if (GUIRect.Contains(new Point(Mouse.GetState().X, Mouse.GetState().Y)) && Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { if (_metoda != null) { _metoda(); } } if (CzyEnter == true && text.Length > 0) { CzyEnter2 = true; } else { CzyEnter = false; } var zmienna = Keyboard.GetState().GetPressedKeys().FirstOrDefault(); if (zmienna != Keys.None && Regex.IsMatch(zmienna.ToString(), @"[a-zA-Z]")) { if (helper.IsNewPress(zmienna)) { if (zmienna == Keys.Back) { if (text.Length > 0) { text = text.Remove(text.Length - 1); } } else if (zmienna == Keys.Enter) { if (text.Length > 0) { CzyEnter2 = true; } } else if (text.Length < 8 && zmienna.ToString().Length == 1) { text += zmienna.ToString(); } } } if (CzyEnter2 == true && text.Length > 0) { text.ToString(); FileManager.SaveScoreToFile(HighList, text); } }