Inheritance: Game.DrawObject
Example #1
0
 public override void OnHit(ref Ball b)
 {
     b.changed = true;
     b = new GhostBall(b);
     GameManager.AddScoreByFactor();
     StateSaver.SetBallState(StateSaver.BallStates.Transform);
 }
Example #2
0
 public override void OnHit(ref Ball b)
 {
     Debug.WriteLine("Hit!!!");
     b.changed = true;
     b = new ChargedBall(b);
     GameManager.AddScoreByFactor();
     StateSaver.SetBallState(StateSaver.BallStates.Transform);
 }
Example #3
0
 public override void OnHit(ref Ball b)
 {
     GameManager.AddScoreByFactor();
 }
Example #4
0
        private SizeF calculateSpeed(ref Ball b, RectangleF playerBox)
        {
            //Calculate the move vector when bouncing on the pad (player)
            float speed = b.moveVector.Size();
            float speedFactor = 1.05f;
            if (speed * speedFactor > playerBox.Height)
            {
                speed = playerBox.Height;
            }
            else
            {
                speed *= 1.05f;
            }

            float ballMiddle = b.boundingBox.Left + b.boundingBox.Width / 2;
            float ballOnPadPosition = (ballMiddle - (playerBox.Left - b.boundingBox.Width / 2)) / (playerBox.Width + b.boundingBox.Width);

            //convert between radians and degrees
            double angle = (Math.PI / 180) * (120 - 60 * ballOnPadPosition);
            float x = (float)Math.Cos(angle);
            float y = -(float)Math.Sin(angle);
            SizeF expected = new SizeF(x * speed, y * speed);

            return expected;
        }
Example #5
0
 public ChargedBall(Ball b)
     : base(b)
 {
 }
Example #6
0
 /// <summary>
 /// What to do when the ball hits the brick
 /// </summary>
 /// <param name="b"></param>
 public abstract void OnHit(ref Ball b);
Example #7
0
 public Player(Point pos)
 {
     this.position = pos;
     this.size = new SizeF(GameSettings.PaddleWidth, GameSettings.PaddleHeight);
     this.ball = new RegularBall(pos + new Size(10, -10));
 }
Example #8
0
 public GhostBall(Ball b)
     : base(b)
 {
 }
Example #9
0
 public RegularBall(Ball b)
     : base(b)
 {
 }
Example #10
0
 public Ball(Ball b)
 {
     this.position = b.position;
     this.moveVector = b.moveVector;
     this.size = new SizeF(10.0f, 10.0f);
 }