Skip to content

Commit

Permalink
update to latest fxgl
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmasB committed Aug 5, 2019
1 parent 0cafd32 commit 3cea25a
Show file tree
Hide file tree
Showing 16 changed files with 165 additions and 74 deletions.
Expand Up @@ -48,7 +48,7 @@ public void onAdded() {
getEntity().getTransformComponent().setRotationOrigin(new Point2D(42, 42));

texture = FXGL.getAssetLoader().loadTexture("player.png");
view.setView(texture);
view.addChild(texture);
}

private double speed = 0;
Expand Down
Expand Up @@ -42,7 +42,8 @@ public void onHit() {
lives--;

if (lives == 1) {
entity.setView(FXGL.getAssetLoader().loadTexture("brick_blue_cracked.png", 232 / 3, 104 / 3));
entity.getViewComponent().clearChildren();
entity.getViewComponent().addChild(FXGL.getAssetLoader().loadTexture("brick_blue_cracked.png", 232 / 3, 104 / 3));
} else if (lives == 0) {
entity.removeFromWorld();
}
Expand Down
21 changes: 14 additions & 7 deletions SlidingPuzzle/pom.xml → CrystalChase/pom.xml
Expand Up @@ -5,20 +5,27 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.almasb</groupId>
<artifactId>SlidingPuzzle</artifactId>
<version>0.1</version>
<artifactId>CrystalChase</artifactId>
<version>1.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<source.version>1.8</source.version>
<source.version>11</source.version>

<!-- plugins -->
<maven.compiler.version>3.3</maven.compiler.version>
<maven.shade.version>2.4.2</maven.shade.version>
<maven.compiler.version>3.8.0</maven.compiler.version>
<maven.shade.version>3.0.0</maven.shade.version>

<fxgl.version>0.4.0</fxgl.version>
<fxgl.version>dev-SNAPSHOT</fxgl.version>
</properties>

<repositories>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.github.almasb</groupId>
Expand Down Expand Up @@ -52,7 +59,7 @@
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.almasb.fxglgames.slidingpuzzle.SlidingPuzzleApp</mainClass>
<mainClass>com.almasb.fxglgames.cc.CrystalApp</mainClass>
</transformer>
</transformers>
</configuration>
Expand Down
44 changes: 44 additions & 0 deletions CrystalChase/src/main/java/com/almasb/fxglgames/cc/CrystalApp.java
@@ -0,0 +1,44 @@
package com.almasb.fxglgames.cc;

import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.core.math.FXGLMath;
import com.almasb.fxgl.dsl.FXGL;
import javafx.geometry.Rectangle2D;
import javafx.util.Duration;

import static com.almasb.fxgl.dsl.FXGL.*;

/**
* @author Almas Baimagambetov (almaslvl@gmail.com)
*/
public class CrystalApp extends GameApplication {

private enum Type {
PLAYER, CRYSTAL
}

@Override
protected void initSettings(GameSettings settings) {
settings.setTitle("Crystal Chase");
}

@Override
protected void initGame() {
run(this::spawnCrystal, Duration.seconds(1));
}

private void spawnCrystal() {
var texture = texture("YellowCrystal.png");


entityBuilder().at(FXGLMath.randomPoint(new Rectangle2D(0, 0, getAppWidth() - 55, getAppHeight() - 55)))
.type(Type.CRYSTAL)
.view(texture.toAnimatedTexture(8, Duration.seconds(0.2)).loop())
.buildAndAttach();
}

public static void main(String[] args) {
launch(args);
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -74,7 +74,7 @@ public static void colorImage(Color color) {

@Override
public void onAdded() {
entity.setView(new Texture(coloredImages.get(color)));
entity.getViewComponent().addChild(new Texture(coloredImages.get(color)));
}

@Override
Expand Down
Expand Up @@ -73,7 +73,7 @@ private Entity getRandomCard(double x, double y) {
CardFrame cardView = new CardFrame(card);
cardView.addCardView(getView(entity));

entity.getViewComponent().setViewFromNode(cardView);
entity.getViewComponent().addChild(cardView);

return entity;
}
Expand Down
2 changes: 1 addition & 1 deletion Pacman/pom.xml
Expand Up @@ -16,7 +16,7 @@
<maven.compiler.version>3.3</maven.compiler.version>
<maven.shade.version>2.4.2</maven.shade.version>

<fxgl.version>0.5.3-SNAPSHOT</fxgl.version>
<fxgl.version>0.5.4</fxgl.version>
</properties>

<repositories>
Expand Down
86 changes: 86 additions & 0 deletions Pong/pom.xml
Expand Up @@ -17,6 +17,7 @@
<maven.shade.version>3.0.0</maven.shade.version>

<fxgl.version>dev-SNAPSHOT</fxgl.version>
<client.plugin.version>0.0.11</client.plugin.version>
</properties>

<dependencies>
Expand All @@ -27,11 +28,23 @@
</dependency>
</dependencies>

<pluginRepositories>
<pluginRepository>
<id>gluon-releases</id>
<url>http://nexus.gluonhq.com/nexus/content/repositories/releases/</url>
</pluginRepository>
</pluginRepositories>

<repositories>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
</repository>

<repository>
<id>nexus-gluon</id>
<url>https://nexus.gluonhq.com/nexus/content/repositories/releases/</url>
</repository>
</repositories>

<build>
Expand All @@ -44,6 +57,79 @@
</configuration>
</plugin>


<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>client-maven-plugin</artifactId>
<version>${client.plugin.version}</version>
<configuration>
<bundlesList>
<list>com/almasb/fxgl/app/system</list>
</bundlesList>
<attachList>
<list>storage</list>
</attachList>
<resourcesList>
<list>properties</list>
<list>wav</list>
<list>tmx</list>
</resourcesList>
<verbose>true</verbose>
<reflectionList>
<list>com.almasb.fxgl.app.GameApplication</list>
<list>com.almasb.fxgl.app.GameApplication$FXGLApplication</list>
<list>com.almasb.fxgl.app.ReadOnlyGameSettings</list>
<list>com.almasb.fxgl.app.GameSettings</list>

<!-- Engine services -->
<list>com.almasb.fxgl.audio.AudioPlayer</list>
<list>com.almasb.fxgl.notification.impl.NotificationServiceProvider</list>
<list>com.almasb.fxgl.notification.view.XboxNotificationView</list>
<list>com.almasb.fxgl.achievement.AchievementManager</list>

<!-- Components -->

<list>com.almasb.fxgl.entity.components.BoundingBoxComponent</list>
<list>com.almasb.fxgl.entity.components.CollidableComponent</list>
<list>com.almasb.fxgl.entity.components.IDComponent</list>
<list>com.almasb.fxgl.entity.components.IrremovableComponent</list>
<list>com.almasb.fxgl.entity.components.TimeComponent</list>
<list>com.almasb.fxgl.entity.components.TransformComponent</list>
<list>com.almasb.fxgl.entity.components.TypeComponent</list>
<list>com.almasb.fxgl.entity.components.ViewComponent</list>
<list>com.almasb.fxgl.particle.ParticleComponent</list>
<list>com.almasb.fxgl.physics.PhysicsComponent</list>
<list>com.almasb.fxgl.dsl.components.LiftComponent</list>
<list>com.almasb.fxgl.dsl.components.OffscreenCleanComponent</list>
<list>com.almasb.fxgl.dsl.components.OffscreenPauseComponent</list>
<list>com.almasb.fxgl.dsl.components.ProjectileComponent</list>

<!-- Custom components -->

<list>com.almasb.chron.components.CatapultComponent</list>
<list>com.almasb.chron.components.CatapultLineIndicatorComponent</list>
<list>com.almasb.chron.components.CircularMovementComponent</list>
<list>com.almasb.chron.components.DestructibleBoxComponent</list>
<list>com.almasb.chron.components.EnemyAttackZombieComponent</list>
<list>com.almasb.chron.components.EnemyBoxComponent</list>
<list>com.almasb.chron.components.EnemyMissileTurretComponent</list>
<list>com.almasb.chron.components.EnemyTurretComponent</list>
<list>com.almasb.chron.components.EnemyZombieComponent</list>
<list>com.almasb.chron.components.HomingMissileProjectileComponent</list>
<list>com.almasb.chron.components.HPComponent</list>
<list>com.almasb.chron.components.JumpPadComponent</list>
<list>com.almasb.chron.components.LootBoxComponent</list>
<list>com.almasb.chron.components.PhysicsLiftComponent</list>
<list>com.almasb.chron.components.PlayerComponent</list>
<list>com.almasb.chron.components.PlayerGuardComponent</list>
<list>com.almasb.chron.components.PortalComponent</list>
<list>com.almasb.chron.components.TimeoutBoxComponent</list>
</reflectionList>
<target>ios-sim</target>
<mainClass>com.almasb.chron.ChronApp</mainClass>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion Pong/src/main/java/com/almasb/fxglgames/pong/PongApp.java
Expand Up @@ -185,7 +185,7 @@ private void initPlayerBat() {
}

private void initEnemyBat() {
spawn("bat", new SpawnData(3 * getAppWidth() / 4 - 20, getAppHeight() / 2 - 30).put("isPlayer", true));
spawn("bat", new SpawnData(3 * getAppWidth() / 4 - 20, getAppHeight() / 2 - 30).put("isPlayer", false));
}

private void playHitAnimation(Entity bat) {
Expand Down
8 changes: 4 additions & 4 deletions Pong/src/main/java/com/almasb/fxglgames/pong/PongFactory.java
Expand Up @@ -92,11 +92,11 @@ public Entity newBat(SpawnData data) {
.with(new CollidableComponent(true))
.build();

PhysicsComponent batPhysics = new PhysicsComponent();
batPhysics.setBodyType(BodyType.KINEMATIC);
bat.addComponent(batPhysics);
PhysicsComponent batPhysics = new PhysicsComponent();
batPhysics.setBodyType(BodyType.KINEMATIC);
bat.addComponent(batPhysics);

bat.addComponent(isPlayer ? new BatComponent() : new EnemyBatComponent());
bat.addComponent(isPlayer ? new BatComponent() : new EnemyBatComponent());

return bat;
}
Expand Down

This file was deleted.

Binary file not shown.
Expand Up @@ -4,6 +4,7 @@
import com.almasb.fxgl.entity.component.Component;
import com.almasb.fxgl.entity.components.ViewComponent;
import com.almasb.fxglgames.slotmachine.SlotMachineApp;
import javafx.scene.input.MouseEvent;

/**
* @author Almas Baimagambetov (almaslvl@gmail.com)
Expand All @@ -15,7 +16,7 @@ public class LeverComponent extends Component {

@Override
public void onAdded() {
view.addClickListener(this::trigger);
view.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> trigger());
}

public void trigger() {
Expand All @@ -24,7 +25,8 @@ public void trigger() {

currentTextureName = currentTextureName.equals("lever0.png") ? "lever1.png" : "lever0.png";

view.setView(FXGL.texture(currentTextureName));
view.clearChildren();
view.addChild(FXGL.texture(currentTextureName));

FXGL.<SlotMachineApp>getAppCast().spin();
}
Expand Down
2 changes: 1 addition & 1 deletion SpaceInvaders/pom.xml
Expand Up @@ -16,7 +16,7 @@
<maven.compiler.version>3.3</maven.compiler.version>
<maven.shade.version>2.4.2</maven.shade.version>

<fxgl.version>0.5.2</fxgl.version>
<fxgl.version>0.5.4</fxgl.version>
</properties>

<repositories>
Expand Down
@@ -1,6 +1,9 @@
package com.almasb.fxglgames.tictactoe;

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.physics.BoundingShape;
import com.almasb.fxgl.physics.HitBox;
import com.almasb.fxglgames.tictactoe.components.TileComponent;

/**
Expand All @@ -15,7 +18,8 @@ public TileEntity(double x, double y) {
setY(y);
addComponent(new TileValueComponent());

getViewComponent().setViewFromNode(new TileView(this));
getBoundingBoxComponent().addHitBox(new HitBox(BoundingShape.box(FXGL.getAppWidth() / 3, FXGL.getAppWidth() / 3)));
getViewComponent().addChild(new TileView(this));
addComponent(new TileComponent());
}

Expand Down

0 comments on commit 3cea25a

Please sign in to comment.