Ball Position Property Delta Engine Documentation

Namespace: Breakout
Assembly: Breakout (in Breakout.exe) Version: 1.1.1.0 (1.1.1)
Syntax

public Vector2D Position { get; protected set; }

Property Value

Type: Vector2D
Remarks

Tests: Breakout.Tests.BallInLevelTests
Remarks

Tests: Breakout.Tests.BallInLevelTests
Examples

4 unit tests call Breakout.Ball.Position
[Test, CloseAfterFirstFrame]
public void FireBall()
{
    Resolve<BallInLevel>();
    var ball = Resolve<Ball>();
    Assert.IsTrue(ball.IsVisible);
    AdvanceTimeAndUpdateEntities(0.01f);
    var initialBallPosition = new Vector2D(0.5f, 0.86f);
    Assert.AreEqual(initialBallPosition, ball.Position);
    if (!IsMockResolver)
        return; //ncrunch: no coverage
    Resolve<MockKeyboard>().SetKeyboardState(Key.Space, State.Pressing);
    AdvanceTimeAndUpdateEntities();
    Assert.AreNotEqual(initialBallPosition, ball.Position);
}
[Test, CloseAfterFirstFrame]
public void FireBall()
{
    if (!IsMockResolver)
        return; //ncrunch: no coverage 
    var ball = Resolve<Ball>();
    Assert.IsTrue(ball.IsVisible);
    AdvanceTimeAndUpdateEntities(0.1f);
    var initialBallPosition = new Vector2D(0.5f, 0.86f);
    Assert.AreEqual(initialBallPosition, ball.Position);
    Resolve<MockKeyboard>().SetKeyboardState(Key.Space, State.Pressing);
    AdvanceTimeAndUpdateEntities(0.1f);
    Assert.AreNotEqual(initialBallPosition, ball.Position);
}
[Test, CloseAfterFirstFrame]
public void PaddleCollision()
{
    var ball = Resolve<TestBall>();
    var paddle = Resolve<Paddle>();
    AdvanceTimeAndUpdateEntities(0.01f);
    ball.CurrentVelocity = new Vector2D(0f, 0.1f);
    ball.SetPosition(paddle.Position);
    Assert.IsFalse(ball.IsCurrentlyOnPaddle);
    AdvanceTimeAndUpdateEntities(0.01f);
    Assert.LessOrEqual(ball.CurrentVelocity.Y, 0.1f);
}
Examples

1 unit tests call Breakout.Ball.Position
[Test, CloseAfterFirstFrame]
public void FireBall()
{
    Resolve<BallInLevel>();
    var ball = Resolve<Ball>();
    Assert.IsTrue(ball.IsVisible);
    AdvanceTimeAndUpdateEntities(0.01f);
    var initialBallPosition = new Vector2D(0.5f, 0.86f);
    Assert.AreEqual(initialBallPosition, ball.Position);
    if (!IsMockResolver)
        return; //ncrunch: no coverage
    Resolve<MockKeyboard>().SetKeyboardState(Key.Space, State.Pressing);
    AdvanceTimeAndUpdateEntities();
    Assert.AreNotEqual(initialBallPosition, ball.Position);
}
See Also