This project implements a dynamic 2D game world using the Danogl engine.
The world includes terrain generation, animated weather, day-night cycles,
an avatar with energy mechanics, and interactive objects such as trees and collectible fruits.
- Dynamically generates terrain blocks using Perlin noise.
- Exposes
createInRange(minX, maxX)to create blocks in a specific X range. - Each block is represented by the
Blockclass. - The terrain's base height is determined by the y-coordinate of the window.
- The
Floraclass manages tree creation. - Each
Treeis composed of:- A trunk (stack of blocks).
- Several
Leafobjects (animated with wind sway). - One or more
Fruitobjects (collectible and regenerating).
- Leaves and fruits are placed in randomized positions near the trunk.
- The
CloudsManagercreates animatedCloudobjects that float across the screen. - On avatar jump, rain drops are triggered from all clouds using a repeating
ScheduledTask. - Drops fall with opacity fade-out to simulate rain animation.
- The
Avatarclass handles movement and jump mechanics, as well as energy consumption and regeneration. - The
EnergyPaneldisplays current energy level in the UI using colored rectangles.
- Includes three components:
Sun: moves across the sky.SunHalo: halo effect that follows the sun.Night: semi-transparent dark layer that simulates nighttime.
- The full cycle duration is configurable (default: 30 seconds).
-
Component-based design:
Most game objects are composed rather than extended.
For example, trees are built from trunk, leaf, and fruit components. -
Observer pattern:
CloudsManagerimplementsJumpObserverand listens to avatar jumps.
When the avatar jumps, the manager triggers rain using a repeatingScheduledTask.
- Run
PepseGameManager.main()from your IDE or terminal. - Use arrow keys (or configured controls) to move and jump.
- Observe:
- Avatar energy depletion while moving.
- Rain when jumping.
- Day-night transitions every 30 seconds.
- Collectible fruits near trees that replenish energy.
- All objects respect their coordinate space (world vs camera).
- Magic numbers were minimized using constants for maintainability.
- Each class is documented with JavaDoc or inline comments.
- Code style follows the university's coding style guide.
Developed by: Zvi Marmor, Adi Zuarets
Course: Object-Oriented Programming, Hebrew University
Year: 2025