예제 #1
0
 public GamerControll(Ball ball)
 {
     Ball = ball;
 }
예제 #2
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);
        }
예제 #3
0
 public AIControll(Ball ball)
 {
     Ball = ball;
 }