Skip to content

Commit

Permalink
Merge branch 'AlmasB:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
chengenzhao authored Dec 24, 2024
2 parents 41755b4 + 1d2936f commit 08b8db3
Show file tree
Hide file tree
Showing 177 changed files with 5,852 additions and 983 deletions.
6 changes: 6 additions & 0 deletions .LICENSE_3RD_PARTY/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### 3rd-party Licenses

This file lists major codebases from which some of the code in this project originated. You may wish to inspect each file to trace its origin and authors. Please contact the project maintainer to inform of a missing license or header, so they can be restored as appropriate.

- The code from jbox2d is used under the BSD 2-clause "Simplified" License (see [LICENSE](jbox2d-LICENSE))
- The code from libGDX is used under Apache 2.0 (see [LICENSE](libGDX-LICENSE)).
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions .github/workflows/deploy_SNAPSHOT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up JDK 21
- name: Set up JDK 23
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 21
java-version: 23
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/latest_jdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest ]
java: [ 21 ]
java: [ 23 ]
runs-on: ${{ matrix.os }}
steps:
- name: 'Checkout'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 21
java-version: 23

- name: Cache maven deps
uses: actions/cache@v3
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Otherwise, see:
<dependency>
<groupId>com.github.almasb</groupId>
<artifactId>fxgl</artifactId>
<version>21</version>
<version>21.1</version>
</dependency>
```

Expand All @@ -95,7 +95,7 @@ repositories {
}
dependencies {
compile 'com.github.almasb:fxgl:21'
compile 'com.github.almasb:fxgl:21.1'
}
```

Expand Down Expand Up @@ -126,7 +126,7 @@ Download the latest uber jar from [Releases](https://github.com/AlmasB/FXGL/rele
* FHNW School of Engineering / Computer Science, Switzerland
* Johann-Andreas-Schmeller-Gymnasium Nabburg, Germany

If your institution wants to use or is using FXGL, add a note in the [Chat](https://gitter.im/AlmasB/FXGL) to be added to the list.
If your institution wants to use or is using FXGL, add a note via [GitHub Discussions](https://github.com/AlmasB/FXGL/discussions) to be added to the list.

Community tutorials:

Expand All @@ -140,7 +140,7 @@ Community projects (identified using `fxgl` topic):
- [Consume](https://ergoscrit.itch.io/consume)
- [FXGL Sliding Puzzle](https://github.com/beryx/fxgl-sliding-puzzle)

If you'd like your project featured here, just add a note in the [Chat](https://gitter.im/AlmasB/FXGL).
If you'd like your project featured here, just add a note via [GitHub Discussions](https://github.com/AlmasB/FXGL/discussions).

### Development Team

Expand Down
8 changes: 4 additions & 4 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class BasicGameApp extends GameApplication {
<dependency>
<groupId>com.github.almasb</groupId>
<artifactId>fxgl</artifactId>
<version>21</version>
<version>21.1</version>
</dependency>
```

Expand All @@ -90,7 +90,7 @@ repositories {
}
dependencies {
compile 'com.github.almasb:fxgl:21'
compile 'com.github.almasb:fxgl:21.1'
}
```

Expand Down Expand Up @@ -120,7 +120,7 @@ open module app.name {
- 巴西南里奥格兰德联邦教育、科学和技术学院
- 瑞士西北高等专业学院 工程/计算机科学学院

如果您的机构想要使用或正在使用 FXGL,请在[Chat](https://gitter.im/AlmasB/FXGL)中添加注释以添加到列表中。
如果您的机构想要使用或正在使用 FXGL,请在[Discussions](https://github.com/AlmasB/FXGL/discussions)中添加注释以添加到列表中。

社区教程:

Expand All @@ -134,7 +134,7 @@ open module app.name {
- [消耗](https://ergoscrit.itch.io/consume)
- [FXGL 滑动拼图](https://github.com/beryx/fxgl-sliding-puzzle)

如果您希望在此处展示您的项目,只需在[Chat](https://gitter.im/AlmasB/FXGL)中添加注释即可。
如果您希望在此处展示您的项目,只需在[Discussions](https://github.com/AlmasB/FXGL/discussions)中添加注释即可。

### 开发团队

Expand Down
8 changes: 4 additions & 4 deletions README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class BasicGameApp extends GameApplication {
<dependency>
<groupId>com.github.almasb</groupId>
<artifactId>fxgl</artifactId>
<version>21</version>
<version>21.1</version>
</dependency>
```

Expand All @@ -95,7 +95,7 @@ repositories {
}
dependencies {
compile 'com.github.almasb:fxgl:21'
compile 'com.github.almasb:fxgl:21.1'
}
```

Expand Down Expand Up @@ -126,7 +126,7 @@ open module app.name {
* Школа инженерии / информатики FHNW, Швейцария
* Гимназия Иоганна-Андреаса-Шмеллера, Наббург, Германия

Если ваше учебное заведение хочет использовать FXGL или уже использует его, оставьте заметку в [чате](https://gitter.im/AlmasB/FXGL), чтобы мы могли внести его в список.
Если ваше учебное заведение хочет использовать FXGL или уже использует его, оставьте заметку в [чате](https://github.com/AlmasB/FXGL/discussions), чтобы мы могли внести его в список.

Руководства сообщества:

Expand All @@ -140,7 +140,7 @@ open module app.name {
- [Consume](https://ergoscrit.itch.io/consume)
- [FXGL Sliding Puzzle](https://github.com/beryx/fxgl-sliding-puzzle)

Если вы хотите, чтобы ваш проект был представлен здесь, просто добавьте заметку в [чате](https://gitter.im/AlmasB/FXGL).
Если вы хотите, чтобы ваш проект был представлен здесь, просто добавьте заметку в [чате](https://github.com/AlmasB/FXGL/discussions).

### Команда разработчиков

Expand Down
2 changes: 1 addition & 1 deletion fxgl-controllerinput/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>fxgl-framework</artifactId>
<groupId>com.github.almasb</groupId>
<version>21+dev-SNAPSHOT</version>
<version>25+dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 0 additions & 2 deletions fxgl-core/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion fxgl-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>fxgl-framework</artifactId>
<groupId>com.github.almasb</groupId>
<version>21+dev-SNAPSHOT</version>
<version>25+dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.almasb.fxgl.core.collection.grid;

import com.almasb.fxgl.core.math.FXGLMath;
import static com.almasb.fxgl.core.collection.grid.NeighborDirection.*;

import java.lang.reflect.Array;
import java.util.ArrayList;
Expand All @@ -15,7 +16,6 @@
import java.util.Random;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;

/**
* @param <T> cell type
Expand Down Expand Up @@ -98,7 +98,6 @@ public final int getCellHeight() {
return cellHeight;
}


/**
* Checks if given (x,y) is within the bounds of the grid,
* i.e. get(x, y) won't return OOB.
Expand All @@ -125,17 +124,36 @@ public final List<T> getCells() {

/**
* Note: returned cells are in the grid (i.e. bounds are checked).
* Diagonal cells are not included.
* The order is left, up, right, down.
*
* @return a new list of neighboring cells to given (x, y)
* @return a new list of neighboring cells to given (x, y) in 4 directions
*/
public final List<T> getNeighbors(int x, int y) {
return getNeighbors(x, y, FOUR_DIRECTIONS);
}

/**
* Note: returned cells are in the grid (i.e. bounds are checked).
* The order is left, up, right, down for 4 directions
* + (optionally) up-left, up-right, down-right, down-left for 8 directions.
*
* @return a new list of neighboring cells to given (x, y) in desired # of directions
*/
public final List<T> getNeighbors(int x, int y, NeighborDirection neighborDirection) {
List<T> result = new ArrayList<>();
getLeft(x, y).ifPresent(result::add);
getUp(x, y).ifPresent(result::add);
getRight(x, y).ifPresent(result::add);
getDown(x, y).ifPresent(result::add);

// Include "Corner" neighbors when eight directions
if (neighborDirection == EIGHT_DIRECTIONS) {
getUpLeft(x, y).ifPresent(result::add);
getUpRight(x, y).ifPresent(result::add);
getDownRight(x, y).ifPresent(result::add);
getDownLeft(x, y).ifPresent(result::add);
}

return result;
}

Expand Down Expand Up @@ -171,6 +189,22 @@ public final Optional<T> getDown(Cell cell) {
return getDown(cell.getX(), cell.getY());
}

public final Optional<T> getUpRight(Cell cell) {
return getUpRight(cell.getX(), cell.getY());
}

public final Optional<T> getUpLeft(Cell cell) {
return getUpLeft(cell.getX(), cell.getY());
}

public final Optional<T> getDownRight(Cell cell) {
return getDownRight(cell.getX(), cell.getY());
}

public final Optional<T> getDownLeft(Cell cell) {
return getDownLeft(cell.getX(), cell.getY());
}

public final Optional<T> getRight(int x, int y) {
return getOptional(x + 1, y);
}
Expand All @@ -187,6 +221,22 @@ public final Optional<T> getDown(int x, int y) {
return getOptional(x, y + 1);
}

public final Optional<T> getUpRight(int x, int y) {
return getOptional(x + 1, y - 1);
}

public final Optional<T> getUpLeft(int x, int y) {
return getOptional(x - 1, y - 1);
}

public final Optional<T> getDownRight(int x, int y) {
return getOptional(x + 1, y + 1);
}

public final Optional<T> getDownLeft(int x, int y) {
return getOptional(x - 1, y + 1);
}

/**
* @param x pixel coord x
* @param y pixel coord y
Expand Down Expand Up @@ -248,7 +298,7 @@ public final Optional<T> getRandomCell(Predicate<T> predicate) {
public final Optional<T> getRandomCell(Random random, Predicate<T> predicate) {
List<T> filtered = getCells().stream()
.filter(predicate)
.collect(Collectors.toList());
.toList();

if (filtered.isEmpty())
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* FXGL - JavaFX Game Library. The MIT License (MIT).
* Copyright (c) AlmasB ([email protected]).
* See LICENSE for details.
*/

package com.almasb.fxgl.core.collection.grid;

/**
* Defines neighboring directions.
*
* @author Jean-Rene Lavoie ([email protected])
*/
public enum NeighborDirection {
FOUR_DIRECTIONS, EIGHT_DIRECTIONS
}
Loading

0 comments on commit 08b8db3

Please sign in to comment.