Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Commit f3239a4

Browse files
committed
merge: integrate feature/strong-shield-brick with latest power-up system
1 parent 1338acc commit f3239a4

33 files changed

Lines changed: 748 additions & 226 deletions

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies {
2323
implementation 'com.github.almasb:fxgl:21.1'
2424
implementation 'com.google.guava:guava:33.5.0-jre'
2525
implementation 'com.moandjiezana.toml:toml4j:0.7.2'
26+
implementation 'com.google.guava:guava:33.5.0-jre'
2627
implementation 'com.google.auto.service:auto-service-annotations:1.1.1'
2728
annotationProcessor 'com.google.auto.service:auto-service:1.1.1'
2829
}

docs/dev/guide.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ Chi tiết: [Spotless Gradle Plugin](https://github.com/diffplug/spotless/tree/m
4848
* **Commits:** [Conventional Commits](https://www.conventionalcommits.org/) (và viết message bằng **Tiếng Anh**)
4949
* **Files Structure:**
5050
[Gradle project Structure](https://docs.gradle.org/current/userguide/organizing_gradle_projects.html)
51+
52+
Ngoài ra:
53+
* [Hướng dẫn viết javadoc](javadoc.md)

docs/dev/javadoc.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# 📄 Viết Javadoc
2+
3+
### 💾 Format
4+
5+
Javadoc được viết tuân theo các quy tắc javadoc cơ bản và viết trên format HTML.
6+
7+
### 🏗️ Cấu trúc
8+
9+
Trên IDE, khi bạn di chuyển lên trên đầu lớp/method và viết `/**` rồi Enter, IDE sẽ tự sinh ra cho bạn khung để bạn viết
10+
javadoc. Cấu trúc của dự án chúng ta sẽ là:
11+
12+
- Đối với Lớp:
13+
14+
```java
15+
/**
16+
*
17+
*
18+
* <h1>?{@link Tên Lớp}</h1>
19+
*
20+
* Mô tả lớp... Có thể sử dụng {@link Class nào đó#TP trong class} để liên kết <br>
21+
* <b>Chú ý: Sử dụng thẻ br để xuống dòng</b> <br>
22+
* <i>Plot Twist: tui cũng ko bt viết gì ở đây nữa</i>
23+
*
24+
* @see ...
25+
*/
26+
27+
```
28+
29+
trong đó `?` ở Tên lớp sẽ là:
30+
31+
| Loại lớp | 📚 Class | 📱Interface | 🔢 Enum | ❗ Exception | 📍 Annotation | 📝 Record |
32+
|----------|----------|-------------|---------|-------------|---------------|-----------|
33+
| Kí hiệu | | % | # | ! | @ | $ |
34+
35+
**VD:** `ThisIsClass`, `%Interface`, `!StackoverflowException`, `#EntityType`
36+
37+
- Đối với method:
38+
39+
```java
40+
/**
41+
* Hàm này thực hiện chức năng gì... .
42+
*
43+
* @params Input1 Đầu vào 1
44+
* @params Input2 Đầu vào 2
45+
* @return Kết quả của hàm
46+
* @throws Exception nếu có lỗi xảy ra...
47+
*/
48+
49+
```
50+
51+
### ❗Chú ý
52+
53+
- Formating docs sau khi viết code xong. (Phím tắt thường là `Alt` + `Shift` + `F`)
54+
55+
### Bạn có thể xem source code trong dự án để xem ví dụ.

settings.ADMIN.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[video]
2+
width = 1280.0
3+
height = 960.0
4+
fullscreen = false
5+
[audio]
6+
music = 1.0
7+
sound = 1.0

src/main/java/com/github/codestorm/bounceverse/Bounceverse.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
import com.almasb.fxgl.app.GameApplication;
66
import com.almasb.fxgl.app.GameSettings;
7-
import com.github.codestorm.bounceverse.core.LaunchOptions;
8-
import com.github.codestorm.bounceverse.core.SettingsManager;
7+
import com.github.codestorm.bounceverse.core.settings.GameSettingsManager;
8+
import com.github.codestorm.bounceverse.core.settings.LaunchOptionsManager;
9+
import com.github.codestorm.bounceverse.core.systems.AppEventSystem;
910
import com.github.codestorm.bounceverse.core.systems.GameSystem;
1011
import com.github.codestorm.bounceverse.core.systems.InputSystem;
1112
import com.github.codestorm.bounceverse.core.systems.PhysicSystem;
@@ -28,27 +29,32 @@
2829
public final class Bounceverse extends GameApplication {
2930

3031
public static void main(String[] args) {
31-
LaunchOptions.load(args);
32+
LaunchOptionsManager.load(args);
3233
launch(args);
3334
}
3435

3536
@Override
3637
protected void initSettings(GameSettings settings) {
3738
try {
38-
SettingsManager.load(settings);
39+
GameSettingsManager.loadTo(settings);
3940
} catch (IOException e) {
4041
throw new BounceverseException(e);
4142
}
4243
}
4344

4445
@Override
45-
protected void initGame() {
46-
GameSystem.getInstance().apply();
46+
protected void initInput() {
47+
InputSystem.getInstance().apply();
4748
}
4849

4950
@Override
50-
protected void initInput() {
51-
InputSystem.getInstance().apply();
51+
protected void onPreInit() {
52+
AppEventSystem.getInstance().apply();
53+
}
54+
55+
@Override
56+
protected void initGame() {
57+
GameSystem.getInstance().apply();
5258
}
5359

5460
@Override

src/main/java/com/github/codestorm/bounceverse/Utilities.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,17 @@ public static final class Compatibility {
291291
public static void throwIfNotCompatible(EntityType onlyFor, Component... params) {
292292
for (var param : params) {
293293
final var annotation = param.getClass().getAnnotation(ForEntity.class);
294-
if (annotation != null) {
295-
final var paramSet = EnumSet.copyOf(Arrays.asList(annotation.value()));
296-
if (paramSet.isEmpty() || paramSet.contains(onlyFor)) {
297-
continue;
298-
}
294+
if (annotation == null) {
295+
continue;
296+
}
297+
298+
final var paramEntityTypeSet = EnumSet.copyOf(Arrays.asList(annotation.value()));
299+
if (!paramEntityTypeSet.contains(onlyFor)) {
300+
throw new IllegalArgumentException(
301+
String.format(
302+
"Class '%s' does not compatible for entity has '%s' type.",
303+
param.getClass().getSimpleName(), onlyFor.name()));
299304
}
300-
throw new IllegalArgumentException(
301-
String.format(
302-
"Class '%s' does not compatible for entity has '%s' type.",
303-
param.getClass().getSimpleName(), onlyFor.name()));
304305
}
305306
}
306307

src/main/java/com/github/codestorm/bounceverse/components/behaviors/Attack.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.almasb.fxgl.dsl.components.HealthIntComponent;
44
import com.almasb.fxgl.entity.Entity;
55
import com.github.codestorm.bounceverse.components.properties.Attributes;
6-
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;
76
import java.util.List;
87

98
/**
@@ -13,7 +12,6 @@
1312
*
1413
* Hành động tấn công/gây sát thương của {@link Entity}. <br>
1514
*/
16-
@ForEntity({})
1715
public class Attack extends Behavior {
1816
public static final int DEFAULT_DAMAGE = 1;
1917
private int damage = DEFAULT_DAMAGE;

src/main/java/com/github/codestorm/bounceverse/components/behaviors/HealthDeath.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.almasb.fxgl.dsl.components.HealthIntComponent;
44
import com.almasb.fxgl.entity.component.Required;
55
import com.github.codestorm.bounceverse.core.BackgroundColorManager;
6-
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;
76
import com.github.codestorm.bounceverse.typing.enums.EntityType;
87

98
import java.util.List;
@@ -17,7 +16,6 @@
1716
* <b>Yêu cầu entity có {@link HealthIntComponent} trước.</b>
1817
*/
1918
@Required(HealthIntComponent.class)
20-
@ForEntity({})
2119
public class HealthDeath extends Behavior {
2220
@Override
2321
public void execute(List<Object> data) {

src/main/java/com/github/codestorm/bounceverse/components/behaviors/ScaleChange.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import com.almasb.fxgl.entity.Entity;
44
import com.almasb.fxgl.entity.components.TransformComponent;
5-
import com.github.codestorm.bounceverse.typing.annotations.ForEntity;
65
import java.util.ArrayList;
76
import java.util.List;
7+
import javafx.util.Duration;
88

99
/**
1010
*
@@ -18,7 +18,6 @@
1818
*
1919
* @see TransformComponent
2020
*/
21-
@ForEntity({})
2221
public class ScaleChange extends UndoableBehavior {
2322
public static final double DONT_CHANGE = 1;
2423
private double scaleWidth = DONT_CHANGE;
@@ -61,4 +60,8 @@ public double getScaleHeight() {
6160
public void setScaleHeight(double scaleHeight) {
6261
this.scaleHeight = scaleHeight;
6362
}
63+
64+
public ScaleChange(Duration duration) {
65+
super(duration, true);
66+
}
6467
}

src/main/java/com/github/codestorm/bounceverse/components/behaviors/Special.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public class Special extends Component {
1313

1414
@Override
1515
public void onRemoved() {
16-
FXGL.spawn("powerUp", getEntity().getCenter());
16+
if (Math.random() < 0.3) { // 30% tỉ lệ rơi PowerUp
17+
FXGL.spawn("powerUp", getEntity().getCenter());
18+
}
1719
}
1820
}

0 commit comments

Comments
 (0)