Skip to content

Commit

Permalink
Merge pull request #363 from AlmasB/0.3.6
Browse files Browse the repository at this point in the history
0.3.6
  • Loading branch information
AlmasB authored Aug 3, 2017
2 parents 41ba00e + 035039d commit cd4a306
Show file tree
Hide file tree
Showing 337 changed files with 2,104 additions and 598 deletions.
12 changes: 5 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 first to avoid inconsistency.
Any new API or changes to existing API should be discussed to avoid inconsistency.

* Proof read public documentation for errors, ambiguities and typos.
* Crash test features for bugs or write a unit test for one.
Expand All @@ -24,13 +24,12 @@ You can build FXGL from sources using [Maven](https://maven.apache.org/):
mvn clean package
```

This will compile and package all FXGL modules, as well as
create FXGL-x.y.z.jar, including sources, javadoc and uber-jar in the "fxgl/target/" directory.
This will create FXGL-x.y.z.jar, sources.jar, javadoc.jar and uber-jar in the "fxgl/target/" directory.

## Workflow

Typically there are 2 branches: `master` and `x.y.z`.
The `master` branch is always *clean* and deployable, i.e. only for releases.
The `master` branch is for releases only.
All the work goes to and stems from the `x.y.z` branch.
Hence, after cloning you should always branch away from `x.y.z` and once
your work is complete, pull a request back to `x.y.z`.
Expand All @@ -56,10 +55,9 @@ The project uses the following guidelines (the list is likely to grow over time)

* Tabs set to 4 spaces & consistent indentation.
* Consistent naming conventions (no [Hungarian notation](https://en.wikipedia.org/wiki/Hungarian_notation)).
* Javadoc on all public and protected API.
* Javadoc on public and protected API (where appropriate).
* Keep access to fields and methods as restricted as you can.
* [License](LICENSE) header in each new file.
* Short license header in each new file and `@author`.

Code quality reports are available from [Codacy](https://www.codacy.com/app/AlmasB/FXGL/dashboard).
If in doubt, skim through the existing source code to get a feel for it.
If a pull request violates too many guidelines it is unlikely to be merged.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![promo](https://raw.githubusercontent.com/AlmasB/git-server/master/storage/images/fxgl_promo.jpg)

## What?

JavaFX Game Development Framework
Expand Down Expand Up @@ -30,8 +32,6 @@ JavaFX Game Development Framework
* The list of features can be found in the [Wiki](https://github.com/AlmasB/FXGL/wiki/Core-Features)
* [Showcase](http://almasb.github.io/FXGLGames/)

![promo](https://raw.githubusercontent.com/AlmasB/git-server/master/storage/images/fxgl_promo.jpg)

## Minimal Example

```java
Expand All @@ -52,11 +52,11 @@ public class BasicGameApp extends GameApplication {

## Getting Started

* Written tutorials - [Wiki](https://github.com/AlmasB/FXGL/wiki)
* Video tutorials - [YouTube](https://www.youtube.com/playlist?list=PL4h6ypqTi3RTiTuAQFKE6xwflnPKyFuPp)
* The [Samples](fxgl-samples) module is constantly updated with feature demos
* Advanced examples - [FXGLGames](https://github.com/AlmasB/FXGLGames)
* Pre-built game demos (standalone .jar) - [Games](https://github.com/AlmasB/FXGLGames/tree/master/binaries)
* [Wiki & Written tutorials](https://github.com/AlmasB/FXGL/wiki)
* [YouTube tutorials](https://www.youtube.com/playlist?list=PL4h6ypqTi3RTiTuAQFKE6xwflnPKyFuPp)
* [Feature demos](fxgl-samples)
* [Game demos](https://github.com/AlmasB/FXGLGames) (src)
* [Game demos](https://github.com/AlmasB/FXGLGames/tree/master/binaries) (.jar)

## Maven

Expand All @@ -69,7 +69,7 @@ Already have `pom.xml`? Then add:
<dependency>
<groupId>com.github.almasb</groupId>
<artifactId>fxgl</artifactId>
<version>0.3.5</version>
<version>0.3.6</version>
</dependency>
```

Expand All @@ -86,7 +86,7 @@ repositories {
}
dependencies {
compile 'com.github.almasb:fxgl:0.3.5'
compile 'com.github.almasb:fxgl:0.3.6'
}
```

Expand Down
4 changes: 2 additions & 2 deletions fxgl-games/pom.xml → fxgl-extra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<artifactId>fxgl-framework</artifactId>
<groupId>com.github.almasb</groupId>
<version>0.3.5</version>
<version>0.3.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>fxgl-games</artifactId>
<artifactId>fxgl-extra</artifactId>

<dependencies>
<dependency>
Expand Down
3 changes: 0 additions & 3 deletions fxgl-games/README.md

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions fxgl-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>fxgl-framework</artifactId>
<groupId>com.github.almasb</groupId>
<version>0.3.5</version>
<version>0.3.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -15,7 +15,7 @@
<dependencies>
<dependency>
<groupId>com.github.almasb</groupId>
<artifactId>fxgl</artifactId>
<artifactId>fxgl-extra</artifactId>
<version>${fxgl.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import com.almasb.fxgl.physics.BoundingShape;
import com.almasb.fxgl.physics.HitBox;
import com.almasb.fxgl.physics.PhysicsComponent;
import com.almasb.fxgl.physics.box2d.dynamics.BodyType;
import com.almasb.fxgl.physics.box2d.dynamics.FixtureDef;
import com.almasb.fxglgames.breakout.control.BallControl;
import com.almasb.fxglgames.breakout.control.BatControl;
import com.almasb.fxglgames.breakout.control.BrickControl;
import com.almasb.fxgl.physics.box2d.dynamics.BodyType;
import com.almasb.fxgl.physics.box2d.dynamics.FixtureDef;

/**
* @author Almas Baimagambetov ([email protected])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@
package com.almasb.fxglgames.drop;

import com.almasb.fxgl.app.ApplicationMode;
import com.almasb.fxgl.app.DSLKt;
import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.ecs.Entity;
import com.almasb.fxgl.input.Input;
import com.almasb.fxgl.input.UserAction;
import com.almasb.fxgl.physics.CollisionHandler;
import com.almasb.fxgl.physics.PhysicsWorld;
import com.almasb.fxgl.input.Input;
import com.almasb.fxgl.settings.GameSettings;
import javafx.scene.input.KeyCode;
import javafx.util.Duration;

import static com.almasb.fxgl.app.DSLKt.onCollision;
import static com.almasb.fxgl.app.DSLKt.onCollisionBegin;
import static com.almasb.fxgl.app.DSLKt.play;

/**
* This is an FXGL version of the libGDX simple game tutorial which can be found
* here - https://github.com/libgdx/libgdx/wiki/A-simple-game
Expand Down Expand Up @@ -72,16 +77,21 @@ protected void initGame() {

@Override
protected void initPhysics() {
PhysicsWorld physicsWorld = getPhysicsWorld();

physicsWorld.addCollisionHandler(new CollisionHandler(DropType.DROPLET, DropType.BUCKET) {
@Override
protected void onCollisionBegin(Entity droplet, Entity bucket) {
droplet.removeFromWorld();

getAudioPlayer().playSound("drop/drop.wav");
}
onCollisionBegin(DropType.DROPLET, DropType.BUCKET, (droplet, bucket) -> {
droplet.removeFromWorld();
play("drop/drop.wav");
});

// PhysicsWorld physicsWorld = getPhysicsWorld();
//
// physicsWorld.addCollisionHandler(new CollisionHandler(DropType.DROPLET, DropType.BUCKET) {
// @Override
// protected void onCollisionBegin(Entity droplet, Entity bucket) {
// droplet.removeFromWorld();
//
// getAudioPlayer().playSound("drop/drop.wav");
// }
// });
}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

import com.almasb.fxgl.app.ApplicationMode;
import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.audio.Music;
import com.almasb.fxgl.ecs.Entity;
import com.almasb.fxgl.entity.Entities;
import com.almasb.fxgl.entity.EntityView;
import com.almasb.fxgl.entity.GameEntity;
import com.almasb.fxgl.input.Input;
import com.almasb.fxgl.input.UserAction;
import com.almasb.fxgl.physics.CollisionHandler;
import com.almasb.fxgl.physics.PhysicsWorld;
import com.almasb.fxgl.input.Input;
import com.almasb.fxgl.settings.GameSettings;
import com.almasb.fxgl.ui.WheelMenu;
import com.almasb.fxglgames.geowars.component.GraphicsComponent;
Expand All @@ -37,6 +38,9 @@

import java.util.Map;

import static com.almasb.fxgl.app.DSLKt.getd;
import static com.almasb.fxgl.app.DSLKt.set;

/**
* @author Almas Baimagambetov (AlmasB) ([email protected])
*/
Expand Down Expand Up @@ -120,6 +124,13 @@ protected void onActionBegin() {
openWeaponMenu();
}
}, MouseButton.SECONDARY);

input.addAction(new UserAction("Time") {
@Override
protected void onActionBegin() {
set("timeRatio", getd("timeRatio") == 1.0 ? 0.05 : 1.0);
}
}, KeyCode.G);
}

@Override
Expand All @@ -128,9 +139,12 @@ protected void initGameVars(Map<String, Object> vars) {
vars.put("multiplier", 1);
vars.put("kills", 0);
vars.put("time", 180);
vars.put("timeRatio", 1.0);
vars.put("weaponType", WeaponType.NORMAL);
}

private Music music;

@Override
protected void initGame() {
getAudioPlayer().setGlobalSoundVolume(0.2);
Expand All @@ -145,7 +159,16 @@ protected void initGame() {
getMasterTimer().runAtInterval(() -> getGameWorld().spawn("Crystal", getRandomPoint()), Duration.seconds(4));
getMasterTimer().runAtInterval(() -> getGameState().increment("time", -1), Duration.seconds(1));

getAudioPlayer().playMusic("bgm.mp3");
music = getAssetLoader().loadMusic("bgm.mp3");

getGameState().<Double>addListener("timeRatio", (prev, now) -> {
if (now != 1.0) {
now = 0.85;
}
music.setRate(now);
});

getAudioPlayer().playMusic(music);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.almasb.fxgl.annotation.Spawns;
import com.almasb.fxgl.app.FXGL;
import com.almasb.fxgl.core.math.FXGLMath;
import com.almasb.fxgl.ecs.component.TimeComponent;
import com.almasb.fxgl.entity.Entities;
import com.almasb.fxgl.entity.EntityFactory;
import com.almasb.fxgl.entity.GameEntity;
Expand Down Expand Up @@ -77,11 +78,14 @@ public GameEntity spawnPlayer(SpawnData data) {
public GameEntity spawnBullet(SpawnData data) {
FXGL.getAudioPlayer().playSound("shoot" + (int) (Math.random() * 8 + 1) + ".wav");

TimeComponent time = new TimeComponent();
time.valueProperty().bind(FXGL.getApp().getGameState().doubleProperty("timeRatio"));

return Entities.builder()
.type(GeoWarsType.BULLET)
.from(data)
.viewFromTextureWithBBox("Bullet.png")
.with(new CollidableComponent(true))
.with(new CollidableComponent(true), time)
.with(new ProjectileControl(data.get("direction"), 600),
new BulletControl(FXGL.<GeoWarsApp>getAppCast().getGrid()),
new OffscreenCleanControl())
Expand All @@ -95,12 +99,15 @@ public GameEntity spawnWanderer(SpawnData data) {
int moveSpeed = red ? config.getRedEnemyMoveSpeed()
: FXGLMath.random(100, config.getWandererMaxMoveSpeed());

TimeComponent time = new TimeComponent();
time.valueProperty().bind(FXGL.getApp().getGameState().doubleProperty("timeRatio"));

return Entities.builder()
.type(GeoWarsType.WANDERER)
.at(getRandomSpawnPoint())
.viewFromTextureWithBBox(red ? "RedWanderer.png" : "Wanderer.png")
.with(new HPComponent(red ? config.getRedEnemyHealth() : config.getEnemyHealth()),
new CollidableComponent(true))
new CollidableComponent(true), time)
.with(new WandererControl(moveSpeed))
.build();
}
Expand All @@ -112,12 +119,15 @@ public GameEntity spawnSeeker(SpawnData data) {
int moveSpeed = red ? config.getRedEnemyMoveSpeed()
: FXGLMath.random(150, config.getSeekerMaxMoveSpeed());

TimeComponent time = new TimeComponent();
time.valueProperty().bind(FXGL.getApp().getGameState().doubleProperty("timeRatio"));

return Entities.builder()
.type(GeoWarsType.SEEKER)
.at(getRandomSpawnPoint())
.viewFromTextureWithBBox(red ? "RedSeeker.png" : "Seeker.png")
.with(new HPComponent(red ? config.getRedEnemyHealth() : config.getEnemyHealth()),
new CollidableComponent(true))
new CollidableComponent(true), time)
.with(new SeekerControl(FXGL.<GeoWarsApp>getAppCast().getPlayer(), moveSpeed))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import com.almasb.fxgl.entity.component.CollidableComponent;
import com.almasb.fxgl.entity.component.TypeComponent;
import com.almasb.fxgl.input.ActionType;
import com.almasb.fxgl.input.Input;
import com.almasb.fxgl.input.InputMapping;
import com.almasb.fxgl.net.Server;
import com.almasb.fxgl.physics.CollisionHandler;
import com.almasb.fxgl.physics.HitBox;
import com.almasb.fxgl.input.Input;
import com.almasb.fxgl.settings.GameSettings;
import com.almasb.fxgl.settings.MenuItem;
import com.almasb.fxgl.ui.UI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import com.almasb.fxgl.physics.BoundingShape;
import com.almasb.fxgl.physics.HitBox;
import com.almasb.fxgl.physics.PhysicsComponent;
import com.almasb.fxgl.physics.box2d.dynamics.BodyType;
import com.almasb.fxgl.physics.box2d.dynamics.FixtureDef;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import com.almasb.fxgl.physics.box2d.dynamics.BodyType;
import com.almasb.fxgl.physics.box2d.dynamics.FixtureDef;

/**
* @author Almas Baimagambetov (AlmasB) ([email protected])
Expand Down
Loading

0 comments on commit cd4a306

Please sign in to comment.