Entity2D DrawArea Property Delta Engine Documentation

Namespace: DeltaEngine.Rendering2D
Assembly: DeltaEngine.Rendering2D (in DeltaEngine.Rendering2D.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public virtual Rectangle DrawArea { get; set; }

Property Value

Type: Rectangle
Remarks

Tests: Snake.Tests.SnakeGameTests
Examples

2 unit tests call DeltaEngine.Rendering2D.Entity2D.DrawArea
[Test, CloseAfterFirstFrame]
public void RespawnChunkIfCollidingWithSnake()
{
    var game = new Game(Resolve<Window>());
    game.StartGame();
    game.Chunk.DrawArea = game.Snake.Get<Body>().BodyParts[0].DrawArea;
    Assert.IsTrue(game.Chunk.IsCollidingWithSnake(game.Snake.Get<Body>().BodyParts));
    game.RespawnChunk();
    Assert.IsFalse(game.Chunk.IsCollidingWithSnake(game.Snake.Get<Body>().BodyParts));
}
[Test, CloseAfterFirstFrame]
public void SnakeEatsChunk()
{
    var game = new Game(Resolve<Window>());
    game.StartGame();
    var snakeHead = game.Snake.Get<Body>().BodyParts[0].DrawArea;
    var direction = game.Snake.Get<Body>().Direction;
    var originalLength = game.Snake.Get<Body>().BodyParts.Count;
    game.Chunk.DrawArea =
        new Rectangle(new Vector2D(snakeHead.Left + direction.X, snakeHead.Top + direction.Y),
            new Size(blockSize));
    game.MoveUp();
    AdvanceTimeAndUpdateEntities(moveSpeed);
    Assert.AreEqual(originalLength + 1, game.Snake.Get<Body>().BodyParts.Count);
}
See Also