This repository contains lab work for Object-Oriented Software Development using JavaFX.
Each lab builds upon the previous one, enhancing the JavaAnimation application with new features, improved design, and better software engineering practices.
👉 Visit my lab work: JavaAnimation
👉 Original base project: JavaAnimation
The JavaAnimation application was extended with new UI elements, configuration options, and improved gameplay controls.
Key Features Added:
- Main Screen
- Configuration Screen
- Added interactive controls:
- Checkbox: Enable Shadow.
- Radio buttons: Red, Green, Blue.
- Slider (5–20) to adjust ball size dynamically (updates label).
- Added interactive controls:
- Game Integration
- All settings affect the game directly (color, shadow effect, size).
- Arrow key controls updated:
- ⬅ Left: decrease speed (X direction).
- ➡ Right: increase speed (X direction).
- ⬆ Up: increase speed (Y direction).
- ⬇ Down: decrease speed (Y direction).
Focused on enhancing the UI design and improving software structure using SOLID principles.
Key Improvements:
- UI Enhancements
- Introduced
styles.cssfor a more polished look.
- Introduced
- Exit Confirmation
- Added a dialog to confirm before quitting, triggered by the Exit button or window close.
- Code Refactoring (SOLID Principles)
- Extracted logic from
Main.javainto separate classes. - Introduced a
Screeninterface; each screen (MainScreen,GameScreen,ConfigureScreen) implements it. - Created a
Frameinterface to decoupleMainfrom individual screen implementations. - Added a
Gameclass under themodelpackage to manage game data. - Added
ScreenWithGameinterface for screens that need access to game data.
- Extracted logic from
Improved layout and refactored using GRASP design principles.
Key Features:
- Redesigned
GameScreenlayout with game area(board) at top, Back button at bottom. - Game area enclosed in a visible rectangle with balanced margins.
- Applied GRASP principles:
- Information Expert: Moved ball data and logic to
Game. - Creator: Added
GamePaneto handle visualization. - Controller: Added
GameControllerto handle input.
- Information Expert: Moved ball data and logic to
Introduced a flexible sprite system with Factory and Singleton patterns.
Key Features:
- Created
Spriteinterface withgetNode()andsetXY(). - Implemented
StarSprite(visual star). - Added
SpriteFactory(Singleton + Factory pattern) for sprite creation. - Updated
GamePaneto display 10 randomly positioned stars at game start. - Created UML diagram showing relationships between Sprite system components.
- Improved ball movement responsiveness.
Shifted towards an entity-based architecture with time-based updates.
Key Features:
- Added
GameConfig(Singleton) to manage configuration. - Created
GameEntityabstract class withPlayerandFoodsubclasses. - Used
process()method for frame-rate independent movement. - Linked
SpriteswithEntities. - Updated
SpriteFactoryas a middle layer between Game and GamePane. - Added entity life cycles (eternal, limited, expired).
- Introduced
PlayerSpriteandFoodlinked toStarSprite. - Food items with random lifespan (5–15s), some stationary, some moving.
Added generics to sprites, player life system, decorator pattern, and audio functions.
Key Features:
- Updated
Spriteinterface with generics. - Player starts with 10s life; eating food adds +5s and shows flying “+1”.
- Applied Decorator pattern for low-life display.
- Game over when life reaches 0.
- Added audio with Facade pattern:
- Background music.
- Sound effects for eating, dying, and spawning.
- Java
- JavaFX
- CSS (UI styling)
- JUnit 5 (Testing)
- Mockito (Mocking)
# Clone the repo
git clone https://github.com/ayakoneko/JavaAnimation2.git
cd JavaAnimation2
# Open in your IDE (e.g., IntelliJ or Eclipse) and run Main.java / mvn clean javafx:run