private static void Main(string[] args) { Settings.Load(); Game = new Main(args); Game.Run(); // Tidying up when the game closes MediaPlayer.Stop(); Settings.Save(); }
private static void ChangeMenuButton(Menu menu, Main.Direction dir) { switch (dir) { case Main.Direction.Down: // Next button if (menu.Selected > 0) { menu.Buttons[menu.Selected].IsHovering = false; menu.Selected--; menu.Buttons[menu.Selected].IsHovering = true; } else if (menu.Selected == 0) { menu.Buttons[menu.Selected].IsHovering = false; menu.Selected = 2; menu.Buttons[menu.Selected].IsHovering = true; } break; case Main.Direction.Up: // Prev button if (menu.Selected < 2) { menu.Buttons[menu.Selected].IsHovering = false; menu.Selected++; menu.Buttons[menu.Selected].IsHovering = true; } else if (menu.Selected == 2) { menu.Buttons[menu.Selected].IsHovering = false; menu.Selected = 0; menu.Buttons[menu.Selected].IsHovering = true; } break; } }
/// <summary> /// Move this player in the specified direction. /// </summary> /// <param name="dir">The direction to move in.</param> public void Move(Main.Direction dir) { switch (dir) { case Main.Direction.Left: // Set direction to left. Dir = dir; if (IsGrounded) // Move left. Loc.X -= (GroundSpeed); else // Move left. Loc.X -= (AirSpeed); // Play walking animation. CurrentAnimation = Animations[(int) Animation.Old_Walk]; // Play walking animation. Weapon.CurrentAnimation = Weapon.Animations[(int) Weapon.Type]; break; case Main.Direction.Right: // set direction to right Dir = dir; if (IsGrounded) // Move right. Loc.X += (GroundSpeed); else // Move right. Loc.X += (AirSpeed); // Play walking animation. CurrentAnimation = Animations[(int) Animation.Old_Walk]; // Play walking animation. Weapon.CurrentAnimation = Weapon.Animations[(int) Weapon.Type]; break; // We can't move a player up or down so we just ignore these. case Main.Direction.Up: break; case Main.Direction.Down: break; default: throw new ArgumentOutOfRangeException(nameof(dir), dir, "An invalid direction was given to a player."); } }