- Description
- Technical Requirements
- Installation and Setup
- Usage
- Architecture and Technologies
- Features
- Testing
- Authors
DarkForest is a straightforward game engine for 2D top-down games. The engine allows for game configuration without altering the source code. It supports location configuration, adding new elements to the game, player configuration, and more.
This game engine was developed in Java using the JavaFX library as a semester project for the Programming in Java course at CTU in Prague.
Since it was created as a semester project, DarkForest is relatively simple in design. The primary goal was to study Java and understand the principles of software development in the context of Java and OOP. This project provided hands-on experience with Java programming and offered insights into the key concepts involved in building such software.
Documentation for the project can be found here.
To build and run the project, you need JDK 21 and Maven 3.9.8.
To run the project, follow these steps:
- Clone the repository to your computer.
- Navigate to the project folder.
- Run the application using the JavaFX plugin:
mvn javafx:run
You can also build the project into a jar file. Steps 1 and 2 remain the same, then execute the following command:
mvn clean packageAfter that, a jar file will appear in the target directory, which can be run with the following command:
java -jar darkforest-1.0-SNAPSHOT.jarThe maven-shade-plugin is used to build the jar file with all dependencies. Therefore, you can move the jar file anywhere on your computer and run it without needing to install additional libraries. Just make sure to include the config directory with the configuration files alongside the jar file.
Once the user launches the application, the main menu is displayed.
Next, the user presses the "Start Game" button to begin the game. The player will find himself in an open world. The player can navigate the map using the W, A, S, D keys.
Using the "J" key, the player can attack the enemy. Each monster has its own speed, visibility and attack radius. If a monster notices you, it will move after you until it dies, until you kill it or change location (through a portal).
During the game the player can open the game menu by pressing a key Escape. During this time the game will be paused. In the game menu the player can exit to the main menu, save the game, load the game or exit the game.
The player can collect various items on the map, which he can then see in his inventory, which he can go to by pressing I. There will only be three types of items in the game (weapons, armor and healing potions). The player will be able to equip weapons and armor and use potions.
The player can also select items in the inventory using the W, A, S, D keys, put on or take off an item using the J key, use an item using the K key, and delete an item using the L key. The currently selected item and items that are already equipped will stand out with different colors. To return back to the game, the player can use the "Escape" key.
There are portals in the game that allow you to move between locations.
If the player dies, the game will start again.
I tried my best to separate the main parts of the game to make it easier to expand.
The JavaFX library is used for graphics. The game world is rendered using canvas.
Almost everything in the game can be set up with configuration files, without the need to change the game code.
All configuration files are located in the config directory. The game uses JSON and txt files to configure the game elements.
Example player configuration.
{
"name": "Mikita",
"initialHealth": 500,
"health": 500,
"damage": 50,
"armor": 0,
"damageRadius": 10,
"locationId": 1,
"positionX": 17,
"positionY": 9,
"equippedWeaponId": 4,
"equippedArmorId": -1,
"inventory": [1, 5]
}
Example map configuration. Each character represents a separate tile.
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBB
AAAABBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAABBBBBBB
AAAABBBBBBBBBBBBBAAAAAAAAAAAAAABBBBBBBBBBBB
AAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBAAABBBBBBB
AAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBAAABBBBBBB
AAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBB
AAAAAAAAAAAAAABAAAABAAAAAAABBBBBBAAAAAAAAAA
AAAAAAAAABAAAAAAABAAAABAAAAAAAAAAAAAAAAAAAA
AAABAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABBBBBAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABBBBBAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABBBBBAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
{
"id": "A",
"passable": true
}
{
"id": 1,
"name": "Dark forest",
"portals": [
{
"id": 1,
"positionX": 27,
"positionY": 7
}
],
"items": [
{
"id": 1,
"positionX": 36,
"positionY": 9
},
{
"id": 2,
"positionX": 35,
"positionY": 13
},
{
"id": 3,
"positionX": 11,
"positionY": 9
},
{
"id": 4,
"positionX": 10,
"positionY": 3
},
{
"id": 7,
"positionX": 13,
"positionY": 11
}
],
"monsters": [
{
"id": 1,
"positionX": 36,
"positionY": 9
},
{
"id": 2,
"positionX": 35,
"positionY": 11
},
{
"id": 1,
"positionX": 10,
"positionY": 3
},
{
"id": 3,
"positionX": 7,
"positionY": 12
}
]
}
{
"id": 1,
"locationId": 2,
"playerX": 13,
"playerY": 5
}
{
"id": 6,
"name": "Sphere of death",
"type": "weapon",
"damage": 100,
"radius": 50
}
{
"id": 1,
"name": "Life Eater",
"health": 350,
"damage": 20,
"damageRadius": 20,
"viewingRadius": 64,
"speed": 70,
"attackSpeed": 1000
}
- Save and Load: Players can save their progress and load from saved games.
- Inventory System: Players can manage their items using an inventory system.
- Combat System: Basic combat mechanics are implemented for player and monster interactions.
- Element Configuration: Easily configure various game elements including characters, locations, items, and portals without altering the source code.
- Add New Elements: Ability to add new locations, items, portals, and other game elements.
- Behavior Algorithms for Monsters: Monsters are controlled by simple behavior algorithms.
In the context of the semester project, unit tests were written for some components of the game engine. The primary goal of these tests is to familiarize with the testing process rather than achieving comprehensive code coverage. The tests are located in the src/test/java directory.






