-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #37: Added syntax rect.toPoints
- Loading branch information
1 parent
565542e
commit d8546d2
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
roguelike-starterkit/src/main/scala/roguelikestarterkit/starterkit/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
roguelike-starterkit/src/test/scala/roguelikestarterkit/starterkit/SyntaxTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package roguelikestarterkit.starterkit | ||
|
||
import indigo.* | ||
import roguelikestarterkit.syntax.toPoints | ||
|
||
class SyntaxTests extends munit.FunSuite { | ||
|
||
test("Can convert a rectangle to a grid of points") { | ||
val actual = Rectangle(0,0,4,3).toPoints | ||
|
||
val expected = | ||
Batch( | ||
Point(0, 0), | ||
Point(1, 0), | ||
Point(2, 0), | ||
Point(3, 0), | ||
Point(0, 1), | ||
Point(1, 1), | ||
Point(2, 1), | ||
Point(3, 1), | ||
Point(0, 2), | ||
Point(1, 2), | ||
Point(2, 2), | ||
Point(3, 2), | ||
) | ||
|
||
assertEquals(actual, expected) | ||
} | ||
|
||
test("Can convert a offset rectangle to a grid of points") { | ||
val actual = Rectangle(10,20,4,3).toPoints | ||
|
||
val expected = | ||
Batch( | ||
Point(10 + 0, 20 + 0), | ||
Point(10 + 1, 20 + 0), | ||
Point(10 + 2, 20 + 0), | ||
Point(10 + 3, 20 + 0), | ||
Point(10 + 0, 20 + 1), | ||
Point(10 + 1, 20 + 1), | ||
Point(10 + 2, 20 + 1), | ||
Point(10 + 3, 20 + 1), | ||
Point(10 + 0, 20 + 2), | ||
Point(10 + 1, 20 + 2), | ||
Point(10 + 2, 20 + 2), | ||
Point(10 + 3, 20 + 2), | ||
) | ||
|
||
assertEquals(actual, expected) | ||
} | ||
|
||
} |