You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A top-down 2D RPG game built in Java using Swing and AWT, inspired by Dante Alighieri's Divine Comedy. The player traverses three worlds — Hell (Inferno), Purgatory (Purgatoriu), and Paradise (Paradis) — making moral choices that affect their karma and determine the final outcome of the game.
The game is a multi-level RPG where the player character (Alvie) moves through three distinct worlds, each with unique maps, NPCs, enemies, and items. Dialogue choices with NPCs award or deduct karma points. The final ending depends on whether the player's karma is positive or negative at the end of Level 3.
Key features:
Three fully tiled maps loaded from CSV layer files
NPC dialogue system with branching moral choices
Inventory system with potions, keys, and collectibles
Karma and health tracking with a live HUD
Enemy AI (Orcs in Hell, Ghosts in Purgatory)
In-game pause menu with save/load system (SQLite, 7 slots)
The core package that wires everything together and manages the game loop.
Class
Responsibility
Main
Entry point. Launches the MainMenu on the Swing thread.
MainMenu
Swing-based main menu with Start, Load Game, Leaderboard, and Exit options using CardLayout.
GamePanel
Central game panel. Extends JPanel and implements Runnable. Contains the game loop (60 FPS target), manages level transitions, spawning, painting, and references to all game objects.
KeyHandler
Implements KeyListener. Tracks all key states as boolean flags (movement, attack, pick up, drink, drop, navigate, menu, dialogue).
Inventory
Renders the 10-slot hotbar HUD, handles item selection, potion usage, and item dropping.
LiveHealthBar
Draws the health bar, karma bar, and coin count in the top-left corner of the screen.
ScreenManager
Draws the Game Over screen (with RELOAD/EXIT buttons), Level Complete screen, and final Game End screen.
inGameMenu/MenuIngame
Draws the in-game pause menu (Resume / Save / Exit) and the save slot selection screen. Handles saving to any of 7 SQLite slots via DataBaseSaveSlotManager.
Entity
All characters and related factory/interface hierarchy.
Interfaces & Abstract Classes
Type
Name
Description
Interface
Characterr
Base interface for all characters. Requires getPlayerImage(), setPlayerSpawn(), draw().
Interface
MainCharacter
Extends Characterr. Adds update(), getHurt(), and Observer pattern methods.
Interface
AggroCharacter
Extends Characterr. For hostile enemies — adds update(harta, player).
Interface
NPC
Extends Characterr. For non-hostile NPCs — adds speak(), update(), chooseResponse(), dialogue index getters/setters.
Interface
PlayerObserver
Observer pattern. updateObs(player) is called when player state changes.
Abstract
Entity
Base class for Player, Orco. Holds sprite frames, position (x,y), speed, life, attack, collision box.
Abstract
CharacterFactory<T>
Generic Abstract Factory base.
Concrete Characters
Class
Type
Description
Player
MainCharacter / Entity
The player character. Handles movement, collision, spritesheet animation (walk, attack, hurt), inventory management, karma/life tracking, dialogue flags, and level progression flags.
Orco
AggroCharacter / Entity
Orc enemy in Level 1 (Inferno). Chases the player within aggro range, attacks on contact, handles collision avoidance via CollisionCheck.
Ghost
AggroCharacter
Ghost enemy in Level 2 (Purgatory). Moves randomly when the player is within 240px, deals contact damage. No collision with map (passes through walls).
Mike
NPC
NPC in Inferno. 5-dialogue moral conversation about betrayal and regret.
Son
NPC
NPC in Purgatory. 5-dialogue conversation about fatherhood and truth. Giving a Skull item affects karma.
Sot
NPC
NPC in Paradise. Part of a two-NPC couple dialogue sequence (alternates with Sotie).
Sotie
NPC
NPC in Paradise. Counterpart to Sot, shares a priorityflag for alternating dialogue turns.
Seller
NPC
Shop NPC. Allows purchasing potions and items with coins.
OracolInfern
NPC
Oracle NPC in Inferno. Provides exposition and level guidance.
OracolParadis
NPC
Oracle NPC in Paradise. Provides final narrative context.
Factories
Class
Creates
MainCharacterFactory
Player (type: "player1")
NPCFactory
Sot, Sotie, Seller, OracolInfern, OracolParadis, Mike, Son
AggroCharacterFactory
Orco (type: "orc"), Ghost (type: "ghost")
Harta (Map)
Handles tile-based map loading and rendering from CSV layer files.
Uses a HashMap<Integer, BufferedImage> tile cache to avoid redundant getSubimage() calls.
Implements frustum culling — only tiles within the current camera viewport are drawn.
Has a dedicated draw(...) method that also renders entities at the correct layer depth.
Obiecte (Objects)
All pickable items and their management.
Interfaces
Interface
Description
ObjInterface
Base for all pickable objects. Requires getImg(), draw(), getX/Y(), setX/Y(), getIsPicked(), setIsPicked(), getDefaultImg(), getID().
PotionInterface
Extends ObjInterface. Adds getAffectByPotion(Player) for use-effects.
MoneyInterface
Interface for Money. Requires getImg() and draw().
Items
Class
Type
Effect
HealthPotion
PotionInterface
Restores 34 HP (capped at 200). Animated 6-frame sprite.
SpeedPotion
PotionInterface
Increases player speed by 26% (capped at 3.0). Animated 6-frame sprite.
InutilPotion
PotionInterface
Deals 20 damage and grants +1 karma. Animated 6-frame sprite.
KeyOne
ObjInterface
Key for Level 1. Singleton. 24-frame animated sprite. Cannot be dropped.
KeyTwo
ObjInterface
Key for Level 2. Singleton. 12-frame animated sprite. Cannot be dropped.
KeyThree
ObjInterface
Key for Level 3. Singleton. 12-frame animated sprite. Cannot be dropped.
Ring
ObjInterface
Quest item used in Sot/Sotie dialogue. Single-frame sprite.
Skull
ObjInterface
Quest item used in Son dialogue. Giving it causes a large karma penalty.
Money
MoneyInterface
Coin collectible. 7-frame animated sprite. Grants +13 coins on pickup.
MoneyManager
Manages coin spawning, collection, and rendering. Spawns 300 coins in Inferno and 20 in other maps, placed in non-collidable tiles. Uses a copy-on-iterate list to avoid ConcurrentModificationException.
Camera
Class
Description
Camera
Tracks world-space viewport position (x, y) and scale (default: 4.0). update(player) centers the camera on the player. apply(Graphics2D) applies an AffineTransform (translate + scale). Clamps position to map bounds to prevent showing areas outside the map.
Collision
Class
Description
CollisionCheck
checkCollision(entity, harta) — returns true if the entity's collision box will enter a solid tile in the current movement direction. avoidCollision(harta, entity) — redirects enemies around walls by testing adjacent directions when a collision is detected. Used by Orco and Player.
DatabaseManager
Class
Description
SaveData
Plain data container (DTO). Holds all fields needed to restore a game state: level, life, coins, karma, position, NPC dialogue indices, enemy list, inventory, field items, and coins on field.
DataBaseSaveSlotManager
Manages SQLite persistence via JDBC (org.sqlite.JDBC). Handles: saving/loading player state, inventory (serialized object mapping), field items, enemy states, coin positions, and individual NPC dialogue indices. Supports 7 named save slots. Also writes winners to a WINNERS table for the leaderboard.