-
-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
167 additions
and
6 deletions.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
fxgl-core/src/main/java/com/almasb/fxgl/core/collection/grid/NeighborFilteringOption.java
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,28 @@ | ||
/* | ||
* FXGL - JavaFX Game Library. The MIT License (MIT). | ||
* Copyright (c) AlmasB (almaslvl@gmail.com). | ||
* See LICENSE for details. | ||
*/ | ||
|
||
package com.almasb.fxgl.core.collection.grid; | ||
|
||
|
||
/** | ||
* Define Movement Directions | ||
* | ||
* @author Jean-Rene Lavoie (jeanrlavoie@gmail.com) | ||
*/ | ||
public enum NeighborFilteringOption { | ||
|
||
FOUR_DIRECTIONS, EIGHT_DIRECTIONS; | ||
|
||
public boolean is(NeighborFilteringOption... neighborFilteringOptions) { | ||
for(NeighborFilteringOption neighborFilteringOption : neighborFilteringOptions) { | ||
if(neighborFilteringOption.equals(this)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |
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
21 changes: 21 additions & 0 deletions
21
...-core/src/test/java/com/almasb/fxgl/core/collection/grid/NeighborFilteringOptionTest.java
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,21 @@ | ||
/* | ||
* FXGL - JavaFX Game Library. The MIT License (MIT). | ||
* Copyright (c) AlmasB (almaslvl@gmail.com). | ||
* See LICENSE for details. | ||
*/ | ||
|
||
package com.almasb.fxgl.core.collection.grid; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class NeighborFilteringOptionTest { | ||
|
||
@Test | ||
public void testIs() { | ||
assertTrue(NeighborFilteringOption.FOUR_DIRECTIONS.is(NeighborFilteringOption.FOUR_DIRECTIONS)); | ||
assertFalse(NeighborFilteringOption.EIGHT_DIRECTIONS.is(NeighborFilteringOption.FOUR_DIRECTIONS)); | ||
} | ||
|
||
} |