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

Comments

Add game systems template#13

Merged
thnhmai06 merged 5 commits intomainfrom
feat/GameSystems
Oct 13, 2025
Merged

Add game systems template#13
thnhmai06 merged 5 commits intomainfrom
feat/GameSystems

Conversation

@thnhmai06
Copy link
Member

No description provided.

Implement configuration loading from properties files to manage game settings dynamically. This includes setting the game title, version, and application mode based on the loaded configurations. Additionally, update the .gitignore to include new configuration files.
@thnhmai06 thnhmai06 self-assigned this Oct 11, 2025
Copilot AI review requested due to automatic review settings October 11, 2025 16:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a configuration system for the Bounceverse game application, replacing hardcoded settings with dynamic configuration loading from properties files.

  • Adds configuration loading infrastructure with a Utils class for reading properties files
  • Creates a settings.properties file to store game metadata and development mode settings
  • Refactors the main application class to use configuration-driven settings initialization

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
src/main/resources/configs/system/settings.properties Adds game configuration with name, version, and development mode settings
src/main/java/com/github/codestorm/bounceverse/Utils.java Introduces utility class with file operations for loading properties files
src/main/java/com/github/codestorm/bounceverse/Bounceverse.java Refactors to use configuration-based settings initialization
.run/run.run.xml Updates Gradle run configuration to include info logging

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

public static Properties settings;

public static void loadConfigs() throws IOException {
DEFAULT = Utils.File.loadProperties(ROOT + "default.properties");
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

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

The code attempts to load 'default.properties' but this file is not included in the PR. This will cause a runtime exception when the application starts.

Suggested change
DEFAULT = Utils.File.loadProperties(ROOT + "default.properties");
try {
DEFAULT = Utils.File.loadProperties(ROOT + "default.properties");
if (DEFAULT == null || DEFAULT.isEmpty()) {
DEFAULT = new Properties();
DEFAULT.setProperty("width", "800");
DEFAULT.setProperty("height", "600");
}
} catch (IOException e) {
DEFAULT = new Properties();
DEFAULT.setProperty("width", "800");
DEFAULT.setProperty("height", "600");
}

Copilot uses AI. Check for mistakes.
Add structured loading of game configurations with separate classes for default options and system settings. This enhances the game's configurability and prepares for future expansion of settings management.
Implement collision handling system and launch options for game configuration. This includes a new Collision class for managing collision logic and a LaunchOption class for parsing launch arguments (e.g., debug mode).
Copilot AI review requested due to automatic review settings October 13, 2025 02:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Override
protected void initPhysics() {
Collision.getInstance().apply();
;
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

Remove the unnecessary semicolon on line 99. It serves no purpose and reduces code readability.

Suggested change
;

Copilot uses AI. Check for mistakes.
Comment on lines 21 to 22
InputStream fileStream = IO.class.getResourceAsStream(path);
assert fileStream != null : "Cannot open InputStream in " + path;
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

Using assert for null checking in production code is not recommended as assertions can be disabled at runtime. Consider throwing an IllegalArgumentException or FileNotFoundException instead.

Copilot uses AI. Check for mistakes.
Improve the loadConfigs method to throw an IOException when properties files cannot be opened (replaces assertion with exception handling). This ensures better error management during configuration loading.
Copilot AI review requested due to automatic review settings October 13, 2025 09:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +75 to +78
var scanner = new Scanner(path);
while (scanner.hasNext()) {
res.add(scanner.next());
}
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

The Scanner constructor is being passed a String path instead of an InputStream. This will cause the Scanner to interpret the path as literal text to scan rather than opening a file. Use Utils.class.getResourceAsStream(path) to get an InputStream.

Suggested change
var scanner = new Scanner(path);
while (scanner.hasNext()) {
res.add(scanner.next());
}
InputStream fileStream = IO.class.getResourceAsStream(path);
if (fileStream == null) {
throw new RuntimeException("Cannot open InputStream in " + path);
}
var scanner = new Scanner(fileStream);
while (scanner.hasNextLine()) {
res.add(scanner.nextLine());
}

Copilot uses AI. Check for mistakes.
// Basic
settings.setTitle(Configs.System.settings.getProperty("settings.name"));
settings.setVersion(Configs.System.settings.getProperty("settings.version"));
settings.setCredits(Utils.IO.readTextFile("credits.txt"));
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

This will fail because readTextFile has a bug where it passes the path string directly to Scanner constructor. The path should be prefixed with '/' to read from resources: Utils.IO.readTextFile(\"/credits.txt\").

Suggested change
settings.setCredits(Utils.IO.readTextFile("credits.txt"));
settings.setCredits(Utils.IO.readTextFile("/credits.txt"));

Copilot uses AI. Check for mistakes.
Comment on lines +83 to +84
settings.setWidth(Integer.parseInt(Configs.Options.DEFAULT.getProperty("width")));
settings.setHeight(Integer.parseInt(Configs.Options.DEFAULT.getProperty("height")));
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

These lines will throw NullPointerException because Configs.Options.DEFAULT is never loaded in loadConfigs() method. The default.properties file is loaded but the file doesn't exist in the diff.

Copilot uses AI. Check for mistakes.
- Added SceneFactory for managing game scenes (facilitates scene transitions).
- Renamed Collision to CollisionSystem for clarity and improved structure.
- Integrated credits loading into game settings (enhances user experience).
@thnhmai06 thnhmai06 changed the title Adding Game Systems Add game systems template Oct 13, 2025
@thnhmai06 thnhmai06 marked this pull request as ready for review October 13, 2025 13:38
Copilot AI review requested due to automatic review settings October 13, 2025 13:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@thnhmai06 thnhmai06 merged commit 3ba00d8 into main Oct 13, 2025
8 checks passed
@thnhmai06 thnhmai06 deleted the feat/GameSystems branch October 13, 2025 13:40
@thnhmai06
Copy link
Member Author

Summary: Add CollisionSystem (template) and SettingSystems

ManhTanTran pushed a commit that referenced this pull request Oct 22, 2025
* feat: add configuration loading and game settings management

Implement configuration loading from properties files to manage game settings dynamically. This includes setting the game title, version, and application mode based on the loaded configurations. Additionally, update the .gitignore to include new configuration files.

* feat: implement game configuration loading and management

Add structured loading of game configurations with separate classes for default options and system settings. This enhances the game's configurability and prepares for future expansion of settings management.

* feat: add collision handling and launch options management

Implement collision handling system and launch options for game configuration. This includes a new Collision class for managing collision logic and a LaunchOption class for parsing launch arguments (e.g., debug mode).

* feat: enhance configuration loading with error handling

Improve the loadConfigs method to throw an IOException when properties files cannot be opened (replaces assertion with exception handling). This ensures better error management during configuration loading.

* feat: implement scene management and enhance collision handling

- Added SceneFactory for managing game scenes (facilitates scene transitions).
- Renamed Collision to CollisionSystem for clarity and improved structure.
- Integrated credits loading into game settings (enhances user experience).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant