feat: Add PowerUp class#5
Conversation
- Introduced PowerUp class to manage special effects and abilities for game objects (provides lazy-update functionality). - Updated build.gradle to include JavaFX plugin and specified version. - Modified project configuration files for compatibility with new features.
- Corrected the description of PowerUps to use plural form for consistency. - Improved clarity in the apply and unapply method descriptions (automatically used when power up becomes active/ends).
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new PowerUp abstract class that provides a framework for implementing timed power-up effects in the game. The class manages automatic activation and deactivation of power-ups using FXGL's timer system.
- Implements timer-based activation/deactivation system for power-ups
- Provides abstract methods for applying and unapplying effects
- Includes multiple constructors for different initialization patterns
Files not reviewed (2)
- .idea/google-java-format.xml: Language not supported
- .idea/misc.xml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 5 changed files in this pull request and generated 3 comments.
Files not reviewed (2)
- .idea/google-java-format.xml: Language not supported
- .idea/misc.xml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| this( | ||
| FXGL.getGameTimer().getNow() + after.toMillis(), | ||
| FXGL.getGameTimer().getNow() + after.toMillis() + duration.toMillis()); |
There was a problem hiding this comment.
The game timer is called twice unnecessarily. Store the current time in a variable to avoid the duplicate call: double currentTime = FXGL.getGameTimer().getNow();
| this( | |
| FXGL.getGameTimer().getNow() + after.toMillis(), | |
| FXGL.getGameTimer().getNow() + after.toMillis() + duration.toMillis()); | |
| double currentTime = FXGL.getGameTimer().getNow(); | |
| this( | |
| currentTime + after.toMillis(), | |
| currentTime + after.toMillis() + duration.toMillis()); |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 5 changed files in this pull request and generated 2 comments.
Files not reviewed (2)
- .idea/google-java-format.xml: Language not supported
- .idea/misc.xml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| private void updateWaitAction() { | ||
| final var gameTimer = FXGL.getGameTimer(); | ||
| final var currentTime = gameTimer.getNow(); | ||
| // when not executed | ||
| if (currentTime < startAt) { | ||
| if (waitAction != null) { | ||
| waitAction.expire(); | ||
| } | ||
| final var timeLeft = Duration.millis(startAt - currentTime); | ||
| waitAction = gameTimer.runOnceAfter(this::doApply, timeLeft); | ||
| } | ||
| } | ||
|
|
||
| /** Update {@code activeAction} when {@code endAt} is changed. */ | ||
| private void updateActiveAction() { | ||
| final var gameTimer = FXGL.getGameTimer(); | ||
| final var currentTime = gameTimer.getNow(); | ||
| // when not executed | ||
| if (currentTime < endAt) { | ||
| if (activeAction != null) { | ||
| activeAction.expire(); | ||
| } | ||
| final var timeLeft = Duration.millis(endAt - currentTime); | ||
| activeAction = gameTimer.runOnceAfter(this::doUnapply, timeLeft); | ||
| } | ||
| } |
There was a problem hiding this comment.
Need situation for startAt >= currentTime, and checking if startAt >= endAt
* feat: add PowerUp class - Introduced PowerUp class to manage special effects and abilities for game objects (provides lazy-update functionality). - Updated build.gradle to include JavaFX plugin and specified version. - Modified project configuration files for compatibility with new features. * docs: update PowerUp class documentation - Corrected the description of PowerUps to use plural form for consistency. - Improved clarity in the apply and unapply method descriptions (automatically used when power up becomes active/ends).
No description provided.