Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 7 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ plugins {
id 'com.diffplug.spotless' version "8.0.0"
}

group = 'com.github.codestorm'
version = '1.0.0'

repositories {
mavenCentral()
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(24)
vendor.set(JvmVendorSpec.ADOPTIUM)
}
}

dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
Expand Down Expand Up @@ -72,23 +76,3 @@ spotless {
formatAnnotations()
}
}

// enable flexible constructors (preview feature)
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += "--enable-preview"
}

tasks.withType(Test).configureEach {
jvmArgs += "--enable-preview"
}

tasks.withType(JavaExec).configureEach {
jvmArgs += "--enable-preview"
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(24)
vendor.set(JvmVendorSpec.ADOPTIUM)
}
}
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ?漧 ch? l� khai b嫪 c?a project, ch? kh獼g ph?i application.
# N?u mu?n khai b嫪 application, h緉 truy c?p /src/main/resources/settings.properties
Comment on lines +1 to +2
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment text contains encoding errors. The Vietnamese text should be properly encoded in UTF-8. The garbled characters suggest the file is being saved with incorrect encoding.

Suggested change
# ?�y ch? l� khai b�o c?a project, ch? kh�ng ph?i application.
# N?u mu?n khai b�o application, h�y truy c?p /src/main/resources/settings.properties
# Đây chỉ là khai báo của project, chứ không phải application.
# Nếu muốn khai báo application, hãy truy cập /src/main/resources/settings.properties

Copilot uses AI. Check for mistakes.
#
name=Bounceverse
group=com.github.codestorm
version=1.0.0-dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.almasb.fxgl.app.GameApplication;
import com.github.codestorm.bounceverse.core.*;
import com.github.codestorm.bounceverse.core.systems.*;
import com.github.codestorm.bounceverse.typing.exceptions.BounceverseException;
import java.io.IOException;

/**
Expand All @@ -27,7 +28,7 @@ protected void initSettings(com.almasb.fxgl.app.GameSettings settings) {
try {
SettingsManager.load(settings);
} catch (IOException e) {
throw new RuntimeException(e);
throw new BounceverseException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.component.Component;
import com.almasb.fxgl.time.TimerAction;
import com.github.codestorm.bounceverse.data.types.DirectionUnit;
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;
import com.github.codestorm.bounceverse.typing.enums.DirectionUnit;
import com.github.codestorm.bounceverse.typing.enums.EntityType;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
Expand All @@ -12,8 +15,8 @@
import javafx.util.Duration;

/** Utilities. */
public final class Utils {
private Utils() {}
public final class Utilities {
private Utilities() {}

/** Input/Output utilities. */
public static final class IO {
Expand Down Expand Up @@ -276,4 +279,74 @@ public static DirectionUnit getCollisionDirection(Entity source, Entity target)
: direction.getY() > 0 ? DirectionUnit.DOWN : DirectionUnit.UP;
}
}

public static final class Compatibility {
/**
* Throw {@link IllegalArgumentException} n廕簑 nh c籀 component trong {@code params} kh繫ng
* ph羅 h廙φ v廙 {@code onlyFor}.
*
* @param onlyFor {@link EntityType} mu廙 ki廙 tra tng th穩ch
* @param params C獺c component c廕吵 ki廙 tra
*/
public static void throwIfNotCompatible(EntityType onlyFor, Component... params) {
for (var param : params) {
final var annotation = param.getClass().getAnnotation(ForEntity.class);
if (annotation != null) {
final var paramSet = EnumSet.copyOf(Arrays.asList(annotation.value()));
if (paramSet.isEmpty() || paramSet.contains(onlyFor)) {
continue;
}
}
throw new IllegalArgumentException(
String.format(
"Class '%s' does not compatible for entity has '%s' type.",
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammatical error in the error message. Should be "is not compatible" instead of "does not compatible".

Suggested change
"Class '%s' does not compatible for entity has '%s' type.",
"Class '%s' is not compatible for entity has '%s' type.",

Copilot uses AI. Check for mistakes.
param.getClass().getSimpleName(), onlyFor.name()));
}
}

/**
* {@link #throwIfNotCompatible(EntityType, Component...)} nhng kh繫ng throw exception.
*
* @param onlyFor {@link EntityType} mu廙 ki廙 tra tng th穩ch
* @param params C獺c component c廕吵 ki廙 tra
* @return {@code true} n廕簑 t廕另 c廕� tng th穩ch, ng廙θ l廕【 {@code false}.
*/
public static boolean isCompatible(EntityType onlyFor, Component... params) {
try {
throwIfNotCompatible(onlyFor, params);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}

/**
* Throw {@link IllegalArgumentException} n廕簑 nh c籀 component trong {@code params} kh繫ng
* ph羅 h廙φ �廙g th廙 t廕另 c廕� v廙 {@code onlyFor}.
*
* @param onlyFor C獺c {@link EntityType} mu廙 ki廙 tra tng th穩ch
* @param params C獺c component c廕吵 ki廙 tra
*/
public static void throwIfNotCompatible(EntityType[] onlyFor, Component... params) {
for (var only : onlyFor) {
throwIfNotCompatible(only, params);
}
}

/**
* {@link #throwIfNotCompatible(EntityType[], Component...)} nhng kh繫ng throw exception.
*
* @param onlyFor C獺c {@link EntityType} mu廙 ki廙 tra tng th穩ch
* @param params C獺c component c廕吵 ki廙 tra
* @return {@code true} n廕簑 t廕另 c廕� tng th穩ch, ng廙θ l廕【 {@code false}.
*/
public static boolean isCompatible(EntityType[] onlyFor, Component... params) {
try {
throwIfNotCompatible(onlyFor, params);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.almasb.fxgl.dsl.components.HealthIntComponent;
import com.almasb.fxgl.entity.Entity;
import com.github.codestorm.bounceverse.components.properties.Attributes;
import com.github.codestorm.bounceverse.data.meta.entities.ForEntity;
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;
import java.util.List;

/**
Expand Down Expand Up @@ -32,9 +32,6 @@ public void execute(List<Object> data) {

final var actualDamage = damage >= 0 ? Math.max(0, damage - theirDefense) : damage;
theirHealth.get().damage(actualDamage);
if (theirHealth.get().isZero()) {
theirHealth.get().getEntity().removeFromWorld();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.component.Component;
import com.github.codestorm.bounceverse.components.properties.Property;
import com.github.codestorm.bounceverse.data.contracts.CanExecute;
import com.github.codestorm.bounceverse.typing.interfaces.CanExecute;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.codestorm.bounceverse.components.behaviors;

import com.github.codestorm.bounceverse.Utils.Time.Cooldown;
import com.github.codestorm.bounceverse.data.contracts.CanExecute;
import com.github.codestorm.bounceverse.Utilities.Time.Cooldown;
import com.github.codestorm.bounceverse.typing.interfaces.CanExecute;
import java.util.List;
import javafx.util.Duration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.component.Required;
import com.github.codestorm.bounceverse.Utils;
import com.github.codestorm.bounceverse.Utilities;
import com.github.codestorm.bounceverse.components.properties.Attributes;
import com.github.codestorm.bounceverse.data.meta.entities.ForEntity;
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;
import java.util.List;

/**
Expand All @@ -29,7 +29,7 @@ public void execute(List<Object> data) {
final double cx = getEntity().getCenter().getX();
final double cy = getEntity().getCenter().getY();

final var nearEntities = Utils.Geometric.getEntityInCircle(cx, cy, radius);
final var nearEntities = Utilities.Geometric.getEntityInCircle(cx, cy, radius);
super.execute(nearEntities.stream().map(e -> (Object) e).toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.almasb.fxgl.dsl.components.HealthIntComponent;
import com.almasb.fxgl.entity.component.Required;
import com.github.codestorm.bounceverse.data.meta.entities.ForEntity;
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;
import java.util.List;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.components.TransformComponent;
import com.github.codestorm.bounceverse.data.meta.entities.ForEntity;
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;
import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.time.TimerAction;
import com.github.codestorm.bounceverse.data.contracts.CanUndo;
import com.github.codestorm.bounceverse.typing.interfaces.CanUndo;
import java.util.List;
import javafx.util.Duration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import com.almasb.fxgl.core.math.Vec2;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.entity.SpawnData;
import com.github.codestorm.bounceverse.Utils.Time.Cooldown;
import com.github.codestorm.bounceverse.Utilities.Time.Cooldown;
import com.github.codestorm.bounceverse.components.behaviors.Attack;
import com.github.codestorm.bounceverse.components.behaviors.Behavior;
import com.github.codestorm.bounceverse.data.meta.entities.ForEntity;
import com.github.codestorm.bounceverse.data.types.DirectionUnit;
import com.github.codestorm.bounceverse.data.types.EntityType;
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;
import com.github.codestorm.bounceverse.typing.enums.DirectionUnit;
import com.github.codestorm.bounceverse.typing.enums.EntityType;
import java.util.List;
import javafx.util.Duration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.codestorm.bounceverse.components.properties;

import com.almasb.fxgl.entity.Entity;
import com.github.codestorm.bounceverse.data.meta.entities.ForEntity;
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.codestorm.bounceverse.components.properties;

import com.almasb.fxgl.entity.Entity;
import com.github.codestorm.bounceverse.data.meta.entities.ForEntity;
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;
import java.util.Arrays;
import java.util.EnumSet;
import javafx.geometry.Side;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.codestorm.bounceverse.core;

import com.github.codestorm.bounceverse.Utils;
import com.github.codestorm.bounceverse.Utilities;

/**
*
Expand All @@ -21,7 +21,7 @@ private LaunchOptions() {}
* @param args Command-Line Arguments - �廙θ truy廙 v�o t廙� h�m {@code main()}
*/
public static void load(String... args) {
final var map = Utils.IO.parseArgs(args, null, null);
final var map = Utilities.IO.parseArgs(args, null, null);

debug = Boolean.parseBoolean(map.getOrDefault("debug", "false"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.almasb.fxgl.app.ApplicationMode;
import com.almasb.fxgl.app.GameSettings;
import com.github.codestorm.bounceverse.Utils;
import com.github.codestorm.bounceverse.Utilities;
import com.github.codestorm.bounceverse.factory.SceneFactory;
import java.io.IOException;

Expand Down Expand Up @@ -31,13 +31,13 @@ private SettingsManager() {}
* @throws IOException if an error occurred when reading from the input stream.
*/
public static void load(GameSettings target) throws IOException {
final var gameSettings = Utils.IO.loadProperties("/settings.properties");
final var gameSettings = Utilities.IO.loadProperties("/settings.properties");
final var userSettings = UserSetting.getSetting();

// ? General
target.setTitle(gameSettings.getProperty("general.name"));
target.setVersion(gameSettings.getProperty("general.version"));
target.setCredits(Utils.IO.readTextFile("credits.txt"));
target.setCredits(Utilities.IO.readTextFile("credits.txt"));
target.setApplicationMode(
Boolean.parseBoolean(gameSettings.getProperty("general.devMode"))
? ApplicationMode.DEVELOPER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.input.UserAction;
import com.github.codestorm.bounceverse.data.types.DirectionUnit;
import com.github.codestorm.bounceverse.data.types.EntityType;
import com.github.codestorm.bounceverse.typing.enums.DirectionUnit;
import com.github.codestorm.bounceverse.typing.enums.EntityType;
import javafx.scene.input.KeyCode;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.physics.CollisionHandler;
import com.almasb.fxgl.physics.PhysicsComponent;
import com.github.codestorm.bounceverse.Utils;
import com.github.codestorm.bounceverse.Utilities;
import com.github.codestorm.bounceverse.components.behaviors.Attack;
import com.github.codestorm.bounceverse.data.types.EntityType;
import com.github.codestorm.bounceverse.typing.enums.EntityType;
import java.util.List;

/**
Expand Down Expand Up @@ -51,7 +51,7 @@ protected void onCollisionBegin(Entity bullet, Entity brick) {
protected void onCollisionBegin(Entity ball, Entity brick) {
// collision
final var collisionDirection =
Utils.Collision.getCollisionDirection(ball, brick);
Utilities.Collision.getCollisionDirection(ball, brick);

final var physics = ball.getComponent(PhysicsComponent.class);
switch (collisionDirection) {
Expand All @@ -75,7 +75,7 @@ protected void onCollisionBegin(Entity ball, Entity brick) {
@Override
protected void onCollisionBegin(Entity ball, Entity paddle) {
final var collisionDirection =
Utils.Collision.getCollisionDirection(ball, paddle);
Utilities.Collision.getCollisionDirection(ball, paddle);

final var physics = ball.getComponent(PhysicsComponent.class);
switch (collisionDirection) {
Expand All @@ -95,7 +95,7 @@ protected void onCollisionBegin(Entity ball, Entity paddle) {
@Override
protected void onCollisionBegin(Entity ball, Entity wall) {
final var collisionDirection =
Utils.Collision.getCollisionDirection(ball, wall);
Utilities.Collision.getCollisionDirection(ball, wall);

final var physics = ball.getComponent(PhysicsComponent.class);
switch (collisionDirection) {
Expand Down
Loading
Loading