Ejemplo n.º 1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            playerOneTexture = Content.Load<Texture2D>("PlayerOneBat");
            ballTexture = Content.Load<Texture2D>("BallTexture");
            statusBarTexture = Content.Load<Texture2D>("HealthBar");
            PongBat batOne = new PongBat(this, spriteBatch, playerOneTexture)
                                 {
                                     Speed = 0.3f,
                                     NextPosition = new Vector2(64, 300),
                                     DoNotAllowChangePositionUntilNextPositionReached = true
                                 };
            PongBat batTwo = new PongBat(this, spriteBatch, playerOneTexture)
            {
                Speed = 0.3f,
                NextPosition = new Vector2(700, 150),
                DoNotAllowChangePositionUntilNextPositionReached = true
            };
            ball = new Ball(this, spriteBatch, ballTexture)
                       {
                           StartPosition = new Vector2(400,240),
                           Countdown = 2500f,
                           Direction = RandomHelper.GetRandomDirection(),
                           Speed = 0.3f,
                           MaxHeight = 480,
                           MaxWidth = 800
                       };
            ball.Reset();

            batOne.SetControll(new GamerControll(ball));
            batTwo.SetControll(new AIControll(ball));

            playerOne = new Player(batOne);
            playerTwo = new Player(batTwo);

            CollisionHelper.GameObjects.Add(batOne);
            CollisionHelper.GameObjects.Add(batTwo);
            CollisionHelper.GameObjects.Add(ball);

            guiControl = new GUIControl(spriteBatch);
            _HealthBar = new StatusBar(statusBarTexture)
                             {
                                 Width = statusBarTexture.Width,
                                 Height = statusBarTexture.Height
                             };
            guiControl.Add(_HealthBar);
        }
Ejemplo n.º 2
0
 public Player(PongBat bat)
 {
     Bat = bat;
     Health = 100;
 }