-
Notifications
You must be signed in to change notification settings - Fork 0
coin functionality added #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
/invoke |
|
/refacto-visz |
|
Refacto is reviewing this PR. Please wait for the review comments to be posted. |
Multi-Domain Review: Coin System👍 Well Done
📁 Selected files for review (1)
🎯 Custom Instructions
📝 Additional Comments
|
| run(() -> { | ||
| if (random(0, 100) < 20) { | ||
| double x = random(0, getAppWidth() - 80); | ||
| System.out.println("Spawning coin at x=" + x + ", y = 0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Console Spam Performance
Debug output in production game loop executes every second with 20% probability. Console I/O operations block execution thread causing frame drops and performance degradation.
Standards
- ISO-25010 Time Behaviour
- Production Code Standards
| bomb = spawn("Bomb", getAppCenter().getX() - 260, getAppCenter().getY() - 180); | ||
|
|
||
| coin = spawn("Coins", getAppCenter().getX() - 260, getAppCenter().getY() - 120); | ||
| System.out.println("Coins at : " + coin.getPosition()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Debug Code
Debug print statement left in production code clutters console output. Should be removed or replaced with proper logging framework for maintainable debugging.
Standards
- Clean Code
- Production Readiness
| /* | ||
| * | ||
| * | ||
| * | ||
| * | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Empty Comments
Empty comment block provides no documentation value and clutters codebase. Should be removed or populated with meaningful documentation describing coin spawning logic.
Standards
- Clean Code
- Documentation Standards
| FXGL.play(GameConstants.COIN_GAIN); | ||
| coin.removeFromWorld(); | ||
| System.out.println("You touched a coin!"); | ||
| coinComponent.incrementCoin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null Pointer Risk
CoinComponent accessed without null check after entity spawning. If coin entity creation fails or component missing, NullPointerException crashes game during collision detection.
if (coinComponent != null) {
coinComponent.incrementCoin();
} else {
System.err.println("Warning: CoinComponent is null, unable to increment coin");
}
Commitable Suggestion
| coinComponent.incrementCoin(); | |
| if (coinComponent != null) { | |
| coinComponent.incrementCoin(); | |
| } else { | |
| System.err.println("Warning: CoinComponent is null, unable to increment coin"); | |
| } |
Standards
- ISO-25010 Fault Tolerance
- Defensive Programming
|
/refacto-visz |
|
Refacto is reviewing this PR. Please wait for the review comments to be posted. |
Multi-Domain Review: Coin System👍 Well Done
📁 Selected files for review (1)
🎯 Custom Instructions
📝 Additional Comments
|
| FXGL.play(GameConstants.COIN_GAIN); | ||
| coin.removeFromWorld(); | ||
| System.out.println("You touched a coin!"); | ||
| coinComponent.incrementCoin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global State Coupling
Collision handler modifies global coinComponent instead of collision participant's component. Creates tight coupling between UI display and collision logic. Breaks single responsibility principle.
Standards
- SOLID-SRP
- Clean Code
- Low Coupling
| double x = random(0, getAppWidth() - 80); | ||
| System.out.println("Spawning coin at x=" + x + ", y = 0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug Output Removal
Console output in game loop creates I/O overhead during runtime. Debug statements should be removed from production code. Repeated printing impacts frame rate performance.
Standards
- Clean Code
- Production Readiness
| bomb = spawn("Bomb", getAppCenter().getX() - 260, getAppCenter().getY() - 180); | ||
|
|
||
| coin = spawn("Coins", getAppCenter().getX() - 260, getAppCenter().getY() - 120); | ||
| System.out.println("Coins at : " + coin.getPosition()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug Output Removal
Debug print statement in initialization code should be removed for production. Console output adds unnecessary overhead and clutters logs.
Standards
- Clean Code
- Production Readiness
| onCollisionBegin(EntityType.PLAYER, EntityType.COIN, (player, coin) -> { | ||
| FXGL.play(GameConstants.COIN_GAIN); | ||
| coin.removeFromWorld(); | ||
| System.out.println("You touched a coin!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug Output Removal
Debug output in collision handler executes frequently during gameplay. Console I/O in hot path degrades performance and should be removed from production builds.
Standards
- Clean Code
- Hot Path Optimization
| FXGL.play(GameConstants.COIN_GAIN); | ||
| coin.removeFromWorld(); | ||
| System.out.println("You touched a coin!"); | ||
| coinComponent.incrementCoin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null Pointer Risk
CoinComponent accessed without null check after collision. If coin entity lacks CoinComponent, NullPointerException crashes game. Component retrieval can fail during entity lifecycle transitions.
if (coinComponent != null) {
coinComponent.incrementCoin();
} else {
System.out.println("Warning: CoinComponent not available");
}
Commitable Suggestion
| coinComponent.incrementCoin(); | |
| if (coinComponent != null) { | |
| coinComponent.incrementCoin(); | |
| } else { | |
| System.out.println("Warning: CoinComponent not available"); | |
| } |
Standards
- ISO-25010 Fault Tolerance
- Defensive Programming
|
/refacto-visz |
|
The user @0dd190f8-7b54-4892-a024-d71e8e7524f9 does not have an active seat allocated for code reviews. Please contact your organization admin to assign a seat or upgrade your subscription. |
|
/refacto-visz |
|
The user @0dd190f8-7b54-4892-a024-d71e8e7524f9 does not have an active seat allocated for code reviews. Please contact your organization admin to assign a seat or upgrade your subscription. |
|
/refacto-visz |
|
Refacto is reviewing this PR. Please wait for the review comments to be posted. |
Multi-Domain Review: Coin System📌 Files Processed
📝 Additional Comments
|
| FXGL.play(GameConstants.COIN_GAIN); | ||
| coin.removeFromWorld(); | ||
| System.out.println("You touched a coin!"); | ||
| coinComponent.incrementCoin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Component Reference Mismatch
Global coinComponent references UI display entity while collision handler receives different coin pickup entity. Increment affects wrong component causing display/logic desynchronization.
Standards
- Object Reference Integrity
- Component Lifecycle Management
| @@ -124,6 +145,12 @@ | |||
| System.out.println("You touched a dino !"); | |||
| damagePlayer(); | |||
| }); | |||
| onCollisionBegin(EntityType.PLAYER, EntityType.COIN, (player, coin) -> { | |||
| FXGL.play(GameConstants.COIN_GAIN); | |||
| coin.removeFromWorld(); | |||
| System.out.println("You touched a coin!"); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug Code Cleanup
Multiple debug print statements remain in production code. These create console noise and indicate incomplete development cleanup before merge.
Standards
- Clean Code
- Production Readiness
| FXGL.play(GameConstants.COIN_GAIN); | ||
| coin.removeFromWorld(); | ||
| System.out.println("You touched a coin!"); | ||
| coinComponent.incrementCoin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null Pointer Risk
CoinComponent accessed without null check after collision. If coin entity lacks CoinComponent, NullPointerException crashes game during collision handling.
if (coinComponent != null) {
coinComponent.incrementCoin();
}
Commitable Suggestion
| coinComponent.incrementCoin(); | |
| if (coinComponent != null) { | |
| coinComponent.incrementCoin(); | |
| } |
Standards
- ISO-25010 Fault Tolerance
- Java Exception Handling
|
/refacto-visz |
|
Refacto is reviewing this PR. Please wait for the review comments to be posted. |
Multi-Domain Review: Coin System📌 Files Processed
📝 Additional Comments
|
| run(() -> { | ||
| if (random(0, 100) < 20) { | ||
| double x = random(0, getAppWidth() - 80); | ||
| System.out.println("Spawning coin at x=" + x + ", y = 0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug Code Present
Debug print statements left in production code create console noise and potential performance overhead. Should be removed or replaced with proper logging framework.
Standards
- Clean Code
- Production Readiness
| bomb = spawn("Bomb", getAppCenter().getX() - 260, getAppCenter().getY() - 180); | ||
|
|
||
| coin = spawn("Coins", getAppCenter().getX() - 260, getAppCenter().getY() - 120); | ||
| System.out.println("Coins at : " + coin.getPosition()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug Code Present
Debug print statements left in production code create console noise and potential performance overhead. Should be removed or replaced with proper logging framework.
Standards
- Clean Code
- Production Readiness
| onCollisionBegin(EntityType.PLAYER, EntityType.COIN, (player, coin) -> { | ||
| FXGL.play(GameConstants.COIN_GAIN); | ||
| coin.removeFromWorld(); | ||
| System.out.println("You touched a coin!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug Code Present
Debug print statements left in production code create console noise and potential performance overhead. Should be removed or replaced with proper logging framework.
Standards
- Clean Code
- Production Readiness
| /* | ||
| * | ||
| * | ||
| * | ||
| * | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty Comment Block
Empty comment block provides no documentation value and clutters code. Should contain meaningful description of coin spawning logic or be removed entirely.
Standards
- Clean Code
- Documentation Standards
| FXGL.play(GameConstants.COIN_GAIN); | ||
| coin.removeFromWorld(); | ||
| System.out.println("You touched a coin!"); | ||
| coinComponent.incrementCoin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null Pointer Risk
CoinComponent accessed without null check in collision handler. If coin entity lacks component, NullPointerException crashes game during collision detection.
if (coinComponent != null) {
coinComponent.incrementCoin();
}
Commitable Suggestion
| coinComponent.incrementCoin(); | |
| if (coinComponent != null) { | |
| coinComponent.incrementCoin(); | |
| } |
Standards
- ISO-25010 Fault Tolerance
- Defensive Programming
|
/refacto-visz |
|
Refacto is reviewing this PR. Please wait for the review comments to be posted. |
Multi-Domain Review: Coin System👍 Well Done
📌 Files Processed
📝 Additional Comments
|
|
|
||
| coin = spawn("Coins", getAppCenter().getX() - 260, getAppCenter().getY() - 120); | ||
| System.out.println("Coins at : " + coin.getPosition()); | ||
| coinComponent = coin.getComponent(CoinComponent.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Component Initialization Race
CoinComponent retrieved immediately after entity spawn without validation. Component may not be attached yet causing null reference in collision handlers.
Standards
- ISO-25010 Maturity
- Component Lifecycle Management
| if (random(0, 100) < 20) { | ||
| double x = random(0, getAppWidth() - 80); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random Generation Inefficiency
Two separate random() calls per spawn cycle creates unnecessary overhead. Single random value could determine both spawn decision and position reducing computational cost.
Standards
- ISO-25010 Resource Utilization
- Algorithm Optimization
| FXGL.play(GameConstants.COIN_GAIN); | ||
| coin.removeFromWorld(); | ||
| System.out.println("You touched a coin!"); | ||
| coinComponent.incrementCoin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null Pointer Risk
CoinComponent accessed without null check in collision handler. If coin entity lacks CoinComponent, NullPointerException crashes game during collision processing.
if (coinComponent != null) {
coinComponent.incrementCoin();
}
Commitable Suggestion
| coinComponent.incrementCoin(); | |
| if (coinComponent != null) { | |
| coinComponent.incrementCoin(); | |
| } |
Standards
- ISO-25010 Fault Tolerance
- Defensive Programming
👉 Checklist
Please make sure to check off the following before submitting:
I have reviewed my submission thoroughly.
I have tested my code (if submission is related to coding) and run the game before pushing (to make sure the project compile).
I have run the JUnit tests (if submission is related to coding).
I have read the Code of Conduct and Contribution Guidelines.
✍ Description of the Pull Request
Please concisely describe the changes you have made.
added coin component and it randomly arise like greendino
when touch a coin it added the
🔗 Issue link
Issue reference number and link goes here e.g. 'Fixes/Closes #<issue_number>'.
This Pull Request fixes the issue : 'Closes #'
This Pull Request does not fix an issue.
Thanks for taking the time to fill out this Pull Request! ❤️ Thanks for contributing to this project 🦖
sample demo