public float Mass; //Mass to calculate Forces public GameElement(ref GameApplication App, ref NewGame Game) : base(App) { this.App = App; this.Game = Game; this.Position = new Vector2(0, 0); }
public Scoreboard(ref GameApplication App) : base(App) { this.App = App; this.PositionPlayer = new Vector2(609.035f, 690); this.PositionCPU = new Vector2(687.110f, 690); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (GameApplication Game = new GameApplication()) { Game.Run(); } }
public GameApplication() { #region XNA. this.IsMouseVisible = true; this.IsFixedTimeStep = true; this.Graphics = new GraphicsDeviceManager(this); this.Graphics.PreferMultiSampling = true; this.Graphics.PreferredBackBufferHeight = 768; this.Graphics.PreferredBackBufferWidth = 1366; this.Graphics.IsFullScreen = true; this.Graphics.ApplyChanges(); this.Content.RootDirectory = "Content"; #endregion #region Application. this.AppState = AppState.MainMenu; this.Application = this; this.GameEnd = new GameOver(); this.InstructionsWindow = new InstructionsWindow(); this.MainMenu = new MainMenu(); this.Game = new NewGame(ref this.Application); this.PauseMenu = new PauseMenu(); this.StopWatch = new Stopwatch(); this.UI = new UI(ref this.Application); #endregion this.Mute = false; }
public static void Lose(ref GameApplication App) { Vector2 Position = new Vector2( App.Graphics.GraphicsDevice.Viewport.Width / 2, App.Graphics.GraphicsDevice.Viewport.Height / 2); App.UI.DrawBackground(Color.White, 1f); App.UI.DrawBackground(Color.Red, 0.8f); App.UI.DrawText("GAME OVER", Color.White, Position, 1f); }
public static void Win(ref GameApplication App) { Vector2 Position = new Vector2( App.Graphics.GraphicsDevice.Viewport.Width / 2, App.Graphics.GraphicsDevice.Viewport.Height / 2); App.UI.DrawBackground(Color.White, 1f); App.UI.DrawBackground(Color.Green, 0.8f); App.UI.DrawText("YOU WIN!", Color.White, Position, 1f); }
public Puck(ref GameApplication App, ref NewGame Game) : base(ref App, ref Game) { this.Velocity = Vector2.Zero; this.PreviousPosition = Vector2.Zero; this.FrictionCoefficient = 0.5f; this.Acceleration = new Vector2(this.FrictionCoefficient * 9.8f, this.FrictionCoefficient * 9.8f); this.MaximumSpeed = 125; this.Mass = 0.05f; this.CornerCollision = false; }
public NewGame(ref GameApplication Application) { this.Application = Application; this.Game = this; this.CPU = new CPU(ref this.Application, ref this.Game); this.GameState = GameState.Running; this.Player = new Player(ref this.Application, ref this.Game); this.Puck = new Puck(ref this.Application, ref this.Game); this.Scoreboard = new Scoreboard(ref this.Application); this.StopWatch = new Stopwatch(); this.Table = new Table(ref this.Application, ref this.Game); }
// Member methods. /// <summary> /// Drawing the pause menu buttons. /// </summary> /// <param name="Application"> The application where the pause menu would be drawn. </param> public void Draw(ref GameApplication Application) { MouseState State = Mouse.GetState(); // Getting mouse position. Vector2 Position = new Vector2(); // The position where the button would be drawn. Color Color; // The text color. #region Background. // Setting color. Color = Color.Black; Application.UI.DrawBackground(Color, 0.5f); #endregion #region Resume. // Setting color. Color = Color.Red * 1.5f; // Setting position. Position.X = 675; Position.Y = 200; // Incase the mouse position is inside the button. if (State.X >= ResumeButtonBeginX && State.X <= ResumeButtonEndX && State.Y >= ResumeButtonBeginY && State.Y <= ResumeButtonEndY) { Color = Color.White; // Adding vitality by changing the used color. } // Drawing the button. Application.UI.DrawText("Resume", Color, Position, 0.5f); #endregion #region Main menu. // Setting color. Color = Color.Red * 1.5f; // Setting position. Position.X = 675; Position.Y = 500; // Incase the mouse position is inside the button. if (State.X >= MainMenuButtonBeginX && State.X <= MainMenuButtonEndX && State.Y >= MainMenuButtonBeginY && State.Y <= MainMenuButtonEndY) { Color = Color.White; // Adding vitality by changing the used color. } // Drawing the button. Application.UI.DrawText("Main menu", Color, Position, 0.5f); #endregion }
// Member methods. /// <summary> /// Drawing the instructions and the back button. /// </summary> /// <param name="Application"> The application where the instructions window would be drawn. </param> public void Draw(ref GameApplication Application) { MouseState State = Mouse.GetState(); // Getting mouse position. Vector2 Position = new Vector2(); // Position where instructions would be written. Color Color = Color.DarkBlue * 2f; // The text color. #region Background. Application.SpriteBatch.Draw( Application.Content.Load <Texture2D>("MenuBackGround"), Application.Graphics.GraphicsDevice.Viewport.Bounds, Color.White); #endregion #region Esc. Position.X = 575; Position.Y = 275; Application.UI.DrawText("P", Color, Position, 0.252f); #endregion #region M. Position.Y += 75; Application.UI.DrawText("M", Color, Position, 0.252f); #endregion #region Alt + F4. Position.Y += 75; Application.UI.DrawText("Alt + F4", Color, Position, 0.252f); #endregion #region Pause. Position.X += 200; Position.Y = 275; Application.UI.DrawText("Pause", Color, Position, 0.252f); #endregion #region Mute / Unmute. Position.Y += 75; Application.UI.DrawText("Mute / Unmute", Color, Position, 0.252f); #endregion #region Exit. Position.Y += 75; Application.UI.DrawText("Exit", Color, Position, 0.252f); #endregion #region Back. // Setting color. Color = Color.Red * 1.5f; // Setting position. Position.X = 675; Position.Y = 525; // Incase the mouse position is inside the button. if (State.X >= BackButtonBeginX && State.X <= BackButtonEndX && State.Y >= BackButtonBeginY && State.Y <= BackButtonEndY) { Color = Color.White; // Adding vitality by changing the used color. } // Drawing the button. Application.UI.DrawText("Back", Color, Position, 0.5f); #endregion }
public Paddle(ref GameApplication App, ref NewGame Game) : base(ref App, ref Game) { this.Mass = 0.135f; this.Position = new Vector2(0, 0); }
public Player(ref GameApplication App, ref NewGame Game) : base(ref App, ref Game) { this.PlayerPaddle = new PlayerPaddle(ref App, ref Game); }
public PlayerPaddle(ref GameApplication App, ref NewGame Game) : base(ref App, ref Game) { this.Velocity = new Vector2(0, 0); }
public CPUPaddle(ref GameApplication App, ref NewGame Game) : base(ref App, ref Game) { this.Velocity = Vector2.Zero; }
public CPU(ref GameApplication App, ref NewGame Game) : base(ref App, ref Game) { this.CPUPaddle = new CPUPaddle(ref App, ref Game); }
public UI(ref GameApplication App) { this.App = App; }
// Member methods. /// <summary> /// Drawing the main menu buttons. /// </summary> /// <param name="Application"> The application where the main menu would be drawn. </param> /// public void Draw(ref GameApplication Application) { MouseState State = Mouse.GetState(); // Getting mouse position. Vector2 Position = new Vector2(); // The position where the button would be drawn. Color Color; // The text color. #region Background. Application.SpriteBatch.Draw( Application.Content.Load <Texture2D>("MenuBackGround"), Application.Graphics.GraphicsDevice.Viewport.Bounds, Color.White); #endregion #region Start. // Setting color. Color = Color.Red * 1.5f; // Setting position. Position.X = 675; Position.Y = 285; // Incase the mouse position is inside the button. if (State.X >= StartButtonBeginX && State.X <= StartButtonEndX && State.Y >= StartButtonBeginY && State.Y <= StartButtonEndY) { Color = Color.White; // Adding vitality by changing the used color. } // Drawing the button. Application.UI.DrawText("Start", Color, Position, 0.5f); #endregion #region Instructions. // Setting color. Color = Color.Red * 1.5f; // Setting position. Position.X = 675; Position.Y = 420; // Incase the mouse position is inside the button. if (State.X >= InstructionsButtonBeginX && State.X <= InstructionsButtonEndX && State.Y >= InstructionsButtonBeginY && State.Y <= InstructionsButtonEndY) { Color = Color.White; // Adding vitality by changing the used color. } // Drawing the instructions button. Application.UI.DrawText("Instructions", Color, Position, 0.5f); #endregion #region Exit. // Setting color. Color = Color.Red * 1.5f; // Setting position. Position.X = 675; Position.Y = 600; // In case the mouse position is inside the button. if (State.X >= ExitButtonBeginX && State.X <= ExitButtonEndX && State.Y >= ExitButtonBeginY && State.Y <= ExitButtonEndY) { Color = Color.White; // Adding vitality by changing the used color. } // Drawing the button. Application.UI.DrawText("Exit", Color, Position, 0.5f); #endregion }
public Table(ref GameApplication App, ref NewGame Game) : base(App) { this.Game = Game; this.App = App; }
public User(ref GameApplication App, ref NewGame Game) : base(App) { }