Skip to content

Commit

Permalink
Merge pull request #607 from AlmasB/dev
Browse files Browse the repository at this point in the history
11.1-beta
  • Loading branch information
AlmasB authored Mar 17, 2019
2 parents 932a7ec + d23f664 commit 6e83466
Show file tree
Hide file tree
Showing 172 changed files with 5,970 additions and 5,244 deletions.
33 changes: 23 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Any new API or changes to existing API should be discussed to avoid inconsistenc
* 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).
* Suggest an API change if you think some calls can be made more concise.
* Add missing tests.
* [Samples](fxgl-samples) might get outdated quite quickly, see if you can find something weird / not working.
* Share details about your project based on FXGL (this will go to the showcase section).
* Write a tutorial on how to use FXGL.
Expand All @@ -28,26 +29,38 @@ This will create FXGL-x.y.z.jar, sources.jar, javadoc.jar and uber-jar in the "f

## Workflow

Typically there are 2 branches: `master` and `dev`.
There are 2 branches: `master` and `dev`.
The `master` branch is for releases only.
All the work goes to and stems from the `dev` branch.
Hence, after cloning you should always branch away from `dev` and once
your work is complete, pull a request back to `dev`.
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:

1. Fork FXGL into your GitHub repo, then clone your repo to your machine.
1. `cd` to that directory -> `git checkout -b BRANCH_NAME dev`, where `BRANCH_NAME` is your working branch.
1. Open IDEA -> File -> New -> Project from Existing Sources -> Select the cloned FXGL directory.
1. Import project from external model -> Maven -> Next -> Next.
1. Select the provided Maven project to import -> Next -> Use JDK11 -> Next -> Finish.
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.

You now should see something like this:
You should now see something like this:

![FXGL](https://raw.githubusercontent.com/AlmasB/git-server/master/storage/images/FXGL_IDEA.jpg)
<img src="https://raw.githubusercontent.com/AlmasB/git-server/master/storage/images/fxgl11_IDEA.jpg" width="400" />

## Running all tests

In IntelliJ,

1. Run -> Edit Configurations
2. Add new JUnit configuration with name "ALL FXGL TESTS"
3. Select "Test kind" - "All in package" and "Search for tests" - "In whole project".
4. Apply -> OK.

<img src="https://raw.githubusercontent.com/AlmasB/git-server/master/storage/images/fxgl11_tests.jpg" width="400" />

Now you can run your configuration "ALL FXGL TESTS" which runs tests from all modules.

## Coding Standards

Expand Down
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ JavaFX Game Development Framework
### Why FXGL?

* No installation or setup required
* "Out of the box": Java 8/9/10/11(alpha), Win/Mac/Linux/Android 5.0+([Sample](https://github.com/AlmasB/FXGL-MobileApp))/iOS([alpha](https://github.com/AlmasB/FXGL-MobileApp))/Web([alpha](https://github.com/AlmasB/FXGL-WebApp))
* "Out of the box": Java 8/9/10/11, Win/Mac/Linux/Android 5.0+([Sample](https://github.com/AlmasB/FXGL-MobileApp))/iOS([alpha](https://github.com/AlmasB/FXGL-MobileApp))/Web([alpha](https://github.com/AlmasB/FXGL-WebApp))
* 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, Event System, Scripting, etc.
* Real-world game development techniques: Entity-Component, Event System, Scripting, and [many more](https://github.com/AlmasB/FXGL/wiki/Core-Features)
* Games are easily packaged into a single executable .jar

### Good for:
Expand All @@ -27,11 +27,6 @@ JavaFX Game Development Framework
* Teaching / learning / improving game development skills
* Fast prototyping of game ideas

### Features

* [More than 60 major features](https://github.com/AlmasB/FXGL/wiki/Core-Features)
* [Showcase](http://almasb.github.io/FXGLGames/)

### Minimal Example

```java
Expand All @@ -53,17 +48,17 @@ public class BasicGameApp extends GameApplication {
## Getting Started

- Version for Java 8/9/10: `0.5.4`
- Version for Java 11: `11.0-alpha`
- Version for Java 11: `11.1-beta`

Note: from now on only 11.0+ will be developed.
FXGL 11 supports Java 11 and has a more scalable architecture,
FXGL 11 supports Java 11+ and has a more scalable architecture,
but currently supports only a subset of features from `0.5.4`.

* [Java 11 modules](https://github.com/AlmasB/FXGL/wiki/FXGL-11-%28Java-11-modules%29)
* [Wiki & Written tutorials](https://github.com/AlmasB/FXGL/wiki)
* [YouTube tutorials](https://www.youtube.com/playlist?list=PL4h6ypqTi3RTiTuAQFKE6xwflnPKyFuPp)
* [Sample code demos](fxgl-samples)
* [Game demos](https://github.com/AlmasB/FXGLGames) (src)
* [FXGL games](https://github.com/AlmasB/FXGLGames) (src)
* [Game demos](https://github.com/AlmasB/FXGLGames/tree/master/binaries) (.jar)

### Maven
Expand All @@ -77,7 +72,7 @@ Already have `pom.xml`? Then add: (use `0.5.4` for Java 8/9/10)
<dependency>
<groupId>com.github.almasb</groupId>
<artifactId>fxgl</artifactId>
<version>11.0-alpha</version>
<version>11.1-beta</version>
</dependency>
```

Expand All @@ -94,7 +89,7 @@ repositories {
}
dependencies {
compile 'com.github.almasb:fxgl:11.0-alpha'
compile 'com.github.almasb:fxgl:11.1-beta'
}
```

Expand Down
2 changes: 1 addition & 1 deletion fxgl-animation/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>11.0-alpha</version>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ abstract class Animation<T>(
var isAnimating = false
private set

private var checkDelay = true

private val delay = builder.delay

private var checkDelay = delay.greaterThan(Duration.ZERO)

var cycleCount = builder.times

fun startReverse() {
Expand All @@ -117,6 +117,8 @@ abstract class Animation<T>(
fun start() {
if (!isAnimating) {
isAnimating = true
resetTime()
onProgress(animatedValue.getValue(if (isReverse) 1.0 else 0.0))
}
}

Expand All @@ -126,7 +128,7 @@ abstract class Animation<T>(
time = 0.0
count = 0
isReverse = false
checkDelay = true
checkDelay = delay.greaterThan(Duration.ZERO)
}
}

Expand All @@ -148,18 +150,12 @@ abstract class Animation<T>(
if (time >= delay.toSeconds()) {
checkDelay = false
resetTime()
return
} else {
return
}
}

if ((isReverse && time == endTime) || (!isReverse && time == 0.0)) {
onProgress(animatedValue.getValue(if (isReverse) 1.0 else 0.0))

updateTime(tpf)
return
}

updateTime(tpf)

if ((!isReverse && time >= endTime) || (isReverse && time <= 0.0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
package com.almasb.fxgl.animation

import javafx.geometry.Point2D
import javafx.scene.paint.Color
import javafx.scene.shape.CubicCurve
import javafx.scene.shape.QuadCurve
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.MatcherAssert.assertThat
import org.junit.jupiter.api.Test
Expand All @@ -33,4 +36,31 @@ class AnimatedValueTest {
assertThat(anim.getValue(1.0), `is`(200.0))
assertThat(anim.getValue(0.5), `is`(150.0))
}

@Test
fun `Bezier quad`() {
val anim = AnimatedQuadBezierPoint2D(QuadCurve(0.0, 0.0, 15.0, 3.0, 100.0, 100.0))

assertThat(anim.getValue(0.0), `is`(Point2D(0.0, 0.0)))
assertThat(anim.getValue(1.0), `is`(Point2D(100.0, 100.0)))
assertThat(anim.getValue(0.5), `is`(Point2D(32.5, 26.5)))
}

@Test
fun `Bezier cubic`() {
val anim = AnimatedCubicBezierPoint2D(CubicCurve(0.0, 0.0, 15.0, 3.0, 55.0, 33.0, 100.0, 100.0))

assertThat(anim.getValue(0.0), `is`(Point2D(0.0, 0.0)))
assertThat(anim.getValue(1.0), `is`(Point2D(100.0, 100.0)))
assertThat(anim.getValue(0.5), `is`(Point2D(38.75, 26.0)))
}

@Test
fun `Color`() {
val anim = AnimatedColor(Color.BLACK, Color.WHITE)

assertThat(anim.getValue(0.0), `is`(Color.BLACK))
assertThat(anim.getValue(1.0), `is`(Color.WHITE))
assertThat(anim.getValue(0.5), `is`(Color.color(0.5, 0.5, 0.5)))
}
}
Loading

0 comments on commit 6e83466

Please sign in to comment.