Tutorial 5.3 (Tests for objects) - Aerll/rpp GitHub Wiki

Object

You can think of this function as a replacement for IndexAt. Unlike IndexAt however, this function doesn't take any coordinates. This is simply because it wouldn't make any sense. We will be using it to write tests for objects in the exact same way as we did until now.

Example:

InsertObject(:2x2, :2x2.R).If(
    Object().HasSpace()
);

Here Object refers to each object we're inserting. In our case it's :2x2 and :2x2.R.

HasSpace

Tests whether there is enough space to place the object.

Example:

InsertObject(red:3x1).If(
    Object().HasSpace().IsNotOverlapping(blue:1x2)
);

Run().FillObjects();

Fits

Tests whether the object fits perfectly into a shape.

Example:

InsertObject(blue:2x1).If(
    Object().Fits()
);

Run().FillObjects();

IsOver

Tests whether the object is over any of the given objects. This function tests only anchors.

Example:

InsertObject(red:2x2).If(
    Object().IsOver(blue:2x2)
);

Run().FillObjects();

IsTouchingObjectAt

Tests whether the whole side of the object is touching the given object. We can choose 1 out of 4 sides: top, left, bottom, right.

Example:

InsertObject(red:1x2).If(
    Object().IsTouchingObjectAt(blue:2x2, left)
).NoDefaultPosRule();

Run().FillObjects();

IsTouchingWallAt

Tests whether the whole side of the object is touching a wall. We can choose 1 out of 4 sides: top, left, bottom, right.

Example:

InsertObject(red:1x2).If(
    Object().IsTouchingWallAt(bottom)
);

Run().FillObjects();

IsEdge

Tests whether the object is on the edge of the map. We can choose 1 out of 8 edges: top, left, bottom, right, topLeft, bottomLeft, topRight, bottomRight.

Example:

InsertObject(blue:2x2).If(
    Object().IsEdge(bottomRight)
).NoDefaultPosRule();

Run().FillObjects();

IsNotEdge

Tests whether the object is not on any of the given edges of the map. We can choose from 4 edges and freely combine them: top, left, bottom, right. We can also use all to test all edges.

Example:

InsertObject(blue:2x2).If(
    Object().IsNotEdge(bottom, right).IsNotOverlapping(blue:2x2)
).NoDefaultPosRule();

Run().FillObjects();

IsNextTo

Tests whether any tile of the object is adjacent to any tile of one of the given objects. Diagonals aren't included.

Example:

InsertObject(red:2x1).If(
    Object().IsNextTo(blue:1x2).IsNotOverlapping(red:2x1)
);

Run().FillObjects();

IsNotNextTo

Tests whether all tiles of the object are not adjacent to any tile of any of the given objects. Diagonals aren't included.

Example:

InsertObject(red:2x1).If(
    Object().IsNotNextTo(blue:1x2).IsNotOverlapping(red:2x1)
);

Run().FillObjects();

IsOverlapping

Tests whether the object is overlapping one of the given objects.

Example:

InsertObject(red:2x1).If(
    Object().IsOverlapping(blue:1x2).IsNotOverlapping(red:2x1).HasSpace()
);

Run().FillObjects();

IsNotOverlapping

Tests whether the object is not overlapping any of the given objects.

Example:

InsertObject(red:2x1).If(
    Object().IsNotOverlapping(red:2x1, blue:1x2)
);

Run().FillObjects();

Example

todo...

Full code

todo...

⚠️ **GitHub.com Fallback** ⚠️