示例#1
0
        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);
        }
示例#2
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);
 }
示例#3
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (GameApplication Game = new GameApplication())
     {
         Game.Run();
     }
 }
示例#4
0
        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;
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
 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;
 }
示例#8
0
 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);
 }
示例#9
0
        //  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
        }
示例#10
0
        //  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
        }
示例#11
0
 public Paddle(ref GameApplication App, ref NewGame Game)
     : base(ref App, ref Game)
 {
     this.Mass     = 0.135f;
     this.Position = new Vector2(0, 0);
 }
示例#12
0
 public Player(ref GameApplication App, ref NewGame Game)
     : base(ref App, ref Game)
 {
     this.PlayerPaddle = new PlayerPaddle(ref App, ref Game);
 }
示例#13
0
 public PlayerPaddle(ref GameApplication App, ref NewGame Game)
     : base(ref App, ref Game)
 {
     this.Velocity = new Vector2(0, 0);
 }
示例#14
0
 public CPUPaddle(ref GameApplication App, ref NewGame Game)
     : base(ref App, ref Game)
 {
     this.Velocity = Vector2.Zero;
 }
示例#15
0
文件: CPU.cs 项目: adrirach/AirHockey
 public CPU(ref GameApplication App, ref NewGame Game) : base(ref App, ref Game)
 {
     this.CPUPaddle = new CPUPaddle(ref App, ref Game);
 }
示例#16
0
文件: UI.cs 项目: adrirach/AirHockey
 public UI(ref GameApplication App)
 {
     this.App = App;
 }
示例#17
0
        //  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
        }
示例#18
0
 public Table(ref GameApplication App, ref NewGame Game)
     : base(App)
 {
     this.Game = Game;
     this.App  = App;
 }
示例#19
0
 public User(ref GameApplication App, ref NewGame Game)
     : base(App)
 {
 }