Skip to content

Commit

Permalink
Merge pull request #914 from AlmasB/dev
Browse files Browse the repository at this point in the history
Release 11.12
  • Loading branch information
AlmasB committed Dec 11, 2020
2 parents 5b0d769 + 8410902 commit b7d14f6
Show file tree
Hide file tree
Showing 133 changed files with 4,690 additions and 968 deletions.
6 changes: 6 additions & 0 deletions .github/.ci/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To release:

1. release-fxgl.sh
2. Merge dev branch into release (currently called master)

Continue developing in dev
7 changes: 7 additions & 0 deletions .github/.ci/fxgl-local-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# run from top-level FXGL directory

mvn clean

mvn -T 4 install -pl :fxgl -am -DskipTests=true -Dgpg.skip=true -Dlicense.skip=true -Dpmd.skip=true
37 changes: 37 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Java CI with Maven

on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Cache maven deps
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and test with Maven using xvfb
uses: GabrielBB/xvfb-action@v1
with:
run: |
mvn test -B -Dgpg.skip=true -Dmaven.javadoc.skip=true
- name: Upload to CodeCov
run: bash <(curl -s https://codecov.io/bash)
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- xvfb
jdk:
- openjdk11
- openjdk14
- openjdk15
- openjdk-ea

before_install:
Expand All @@ -20,8 +20,8 @@ before_install:
install:
- echo "install NOOP"

after_success:
- bash <(curl -s https://codecov.io/bash)
script:
- mvn test -B -Dmaven.javadoc.skip=true -Djacoco.skip=true

deploy:
# release dev build of FXGL to Sonatype
Expand Down
28 changes: 8 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Please see the list below on how you can contribute to the project.
Once you've decided what you would like to do, let me know about it first.
This is just to make sure that the issue you want hasn't already been implemented,
fixed or being worked on in newer versions.
Any new API or changes to existing API should be discussed to avoid inconsistency.
Any new API or changes to existing API should be discussed to avoid inconsistencies.

* Proof read public documentation for errors, ambiguities and typos.
* Proof read the public documentation for errors, ambiguities and typos.
* Crash test features for bugs or write a unit test for one.
* Create an issue or suggest a feature backed up by a use case.
* Provide or suggest an implementation of an issue from [GitHub Issues](https://github.com/AlmasB/FXGL/issues).
Expand All @@ -17,33 +17,21 @@ Any new API or changes to existing API should be discussed to avoid inconsistenc
* Share details about your project based on FXGL (this will go to the showcase section).
* Write a tutorial on how to use FXGL.

## Building

You need to have JDK 11 to build FXGL.
You can build FXGL from sources using [Maven](https://maven.apache.org/):
```maven
mvn clean package
```

This will create FXGL-x.y.z.jar, sources.jar, javadoc.jar and uber-jar in the "fxgl/target/" directory.

## Workflow

There are 2 branches: `master` and `dev`.
There are 2 branches: `dev` and `master`.
The `master` branch is for releases only.
All the work goes to your `dev` branch, then pull a request back to `dev`.

## Development

Due to use of Kotlin, the only feasible IDE is [IntelliJ IDEA](https://www.jetbrains.com/idea/).
To start developing FXGL you can setup IDEA (2018.3.4+) as follows:
Due to use of Kotlin, [IntelliJ IDEA](https://www.jetbrains.com/idea/) is recommended.
To start developing FXGL you can set up IDEA (2020.2+) as follows:

1. Fork FXGL into your GitHub repo, then clone your repo to your machine.
2. `cd` to that directory -> `git checkout dev` to switch to development branch.
3. Open IDEA -> File -> New -> Project from Existing Sources -> Select the cloned FXGL directory.
4. Import project from external model -> Maven -> Next.
5. Tick "Search for projects recursively" and "Import Maven projects automatically" -> Next.
6. Select the provided Maven project to import -> Next -> Use JDK11 -> Next -> Finish.
2. Open IDEA -> File -> New -> Project from Existing Sources -> Select the cloned FXGL directory.
3. Import project from external model -> Maven -> Next.
4. Select the provided Maven project to import. Use default settings and JDK 11 (or higher).

You should now see something like this:

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
JavaFX Game Development Framework

[![Maven Central](https://img.shields.io/maven-central/v/com.github.almasb/fxgl.svg)]()
[![Build Status](https://travis-ci.org/AlmasB/FXGL.svg?branch=master)](https://travis-ci.org/AlmasB/FXGL)
[![codecov](https://codecov.io/gh/AlmasB/FXGL/branch/master/graph/badge.svg)](https://codecov.io/gh/AlmasB/FXGL)
[![Build Status](https://github.com/AlmasB/FXGL/workflows/Java%20CI%20with%20Maven/badge.svg)](https://github.com/AlmasB/FXGL/actions)
[![codecov](https://codecov.io/gh/AlmasB/FXGL/branch/dev/graph/badge.svg)](https://codecov.io/gh/AlmasB/FXGL)

### Why FXGL?

* No installation or setup required
* "Out of the box": Java 8-14, Win/Mac/Linux/Android 5.0+/iOS 11.0+/Web
* "Out of the box": Java 8-15, Win/Mac/Linux/Android 5.0+/iOS 11.0+/Web
* Simple and clean API, higher level than other engines
* Superset of JavaFX: no need to learn new UI API
* Real-world game development techniques: Entity-Component, interpolated animations, particles, and [many more](https://github.com/AlmasB/FXGL/wiki/Core-Features)
Expand Down Expand Up @@ -50,6 +50,7 @@ public class BasicGameApp extends GameApplication {
For a quick dive into code, see standalone [basic examples](https://github.com/AlmasB/FXGL/tree/master/fxgl-samples/src/main/java/basics).
Otherwise, see:

* [Showcase Trailer](https://youtu.be/fuDQg7W0v4g)
* [Wiki & written tutorials](https://github.com/AlmasB/FXGL/wiki)
* [YouTube tutorials](https://www.youtube.com/playlist?list=PL4h6ypqTi3RTiTuAQFKE6xwflnPKyFuPp)
* [Java 11 modules](https://github.com/AlmasB/FXGL/wiki/FXGL-11-%28Java-11-modules%29)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.almasb.fxgl.entity.component.Component;
import com.almasb.fxgl.entity.component.Required;
import com.almasb.fxgl.pathfinding.CellMoveComponent;
import javafx.beans.value.ChangeListener;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -31,6 +32,13 @@ public final class AStarMoveComponent extends Component {

private Runnable delayedPathCalc = EmptyRunnable.INSTANCE;

private ChangeListener<Boolean> isAtDestinationListener = (o, old, isAtDestination) -> {
if (isAtDestination) {
delayedPathCalc.run();
delayedPathCalc = EmptyRunnable.INSTANCE;
}
};

public AStarMoveComponent(AStarGrid grid) {
this(new LazyValue<>(() -> grid));
}
Expand All @@ -44,15 +52,14 @@ public AStarMoveComponent(LazyValue<AStarGrid> grid) {

@Override
public void onAdded() {

moveComponent = entity.getComponent(CellMoveComponent.class);

moveComponent.atDestinationProperty().addListener((o, old, isAtDestination) -> {
if (isAtDestination) {
delayedPathCalc.run();
delayedPathCalc = EmptyRunnable.INSTANCE;
}
});
moveComponent.atDestinationProperty().addListener(isAtDestinationListener);
}

@Override
public void onRemoved() {
moveComponent.atDestinationProperty().removeListener(isAtDestinationListener);
}

public boolean isMoving() {
Expand All @@ -79,6 +86,10 @@ public void stopMovementAt(int cellX, int cellY) {
moveComponent.setPositionToCell(cellX, cellY);
}

public void stopMovement() {
stopMovementAt(moveComponent.getCellX(), moveComponent.getCellY());
}

public void moveToRightCell() {
getGrid().getRight(moveComponent.getCellX(), moveComponent.getCellY())
.ifPresent(this::moveToCell);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
import com.almasb.fxgl.pathfinding.Pathfinder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author Almas Baimagambetov (almaslvl@gmail.com)
*/
public final class AStarPathfinder implements Pathfinder<AStarCell> {

private AStarGrid grid;
private final AStarGrid grid;

public AStarPathfinder(AStarGrid grid) {
this.grid = grid;
Expand Down Expand Up @@ -69,7 +71,7 @@ public List<AStarCell> findPath(AStarCell[][] grid, AStarCell start, AStarCell t
boolean found = false;

while (!found && !closed.contains(target)) {
for (AStarCell neighbor : getValidNeighbors(current, grid, busyNodes)) {
for (AStarCell neighbor : getValidNeighbors(current, busyNodes)) {
if (neighbor == target) {
target.setParent(current);
found = true;
Expand Down Expand Up @@ -128,42 +130,14 @@ private List<AStarCell> buildPath(AStarCell start, AStarCell target) {

/**
* @param node the A* node
* @param grid the A* grid
* @param busyNodes nodes which are busy, i.e. walkable but have a temporary obstacle
* @return neighbors of the node
*/
protected List<AStarCell> getValidNeighbors(AStarCell node, AStarCell[][] grid, AStarCell... busyNodes) {
int x = node.getX();
int y = node.getY();
int[] points = {
x - 1, y,
x + 1, y,
x, y - 1,
x, y + 1
};

List<AStarCell> result = new ArrayList<>();

for (int i = 0; i < points.length; i++) {
int x1 = points[i];
int y1 = points[++i];

if (x1 >= 0 && x1 < grid.length
&& y1 >= 0 && y1 < grid[0].length
&& grid[x1][y1].getState() == CellState.WALKABLE
&& !contains(x1, y1, busyNodes)) {
result.add(grid[x1][y1]);
}
}

return result;
}

private boolean contains(int x, int y, AStarCell... cells) {
for (AStarCell n : cells)
if (n.getX() == x && n.getY() == y)
return true;

return false;
protected List<AStarCell> getValidNeighbors(AStarCell node, AStarCell... busyNodes) {
var busyNodesList = Arrays.asList(busyNodes);
return grid.getNeighbors(node.getX(), node.getY()).stream()
.filter(AStarCell::isWalkable)
.filter(neighbor -> !busyNodesList.contains(neighbor))
.collect(Collectors.toList());
}
}

This file was deleted.

0 comments on commit b7d14f6

Please sign in to comment.