예제 #1
0
        public void Update(GameTime _gameTime)
        {
            if (position.X + width >= PaddleBall.WIDTH)
            {
                movementVec.X = -1.0f;
                Collide();
            }
            else if (position.X <= 0)
            {
                movementVec.X = 1.0f;
                Collide();
            }

            if (position.Y >= PaddleBall.HEIGHT)
            {
                movementVec = Vector2.Zero;
                paddle.SetChild(this);
                ballMoving = false;
                trailPositions.Clear();
            }
            if (position.Y <= 0)
            {
                movementVec.Y = 1.0f;
                Collide();
            }

            Move(movementVec, moveSpeed, _gameTime);
            boundingRect.Location = position.ToPoint();


            if (ballMoving && drawTrail)
            {
                UpdateTrailPosition();
            }
        }
예제 #2
0
 public GameScreen(ScreenManager _screenManager)
     : base(_screenManager)
 {
     paddle = new Paddle();
     ball   = new Ball(paddle);
     paddle.SetChild(ball);
     builder = new LevelBuilder();
     // TODO allow save progression
     // Load level from file
     builder.SetLevel(1);
     builder.Build();
     blocks = builder.GetLevelBlocks();
     foreach (Block block in blocks)
     {
         block.SetBallObject(ball);
         block.SetPaddleObject(paddle);
     }
 }