Select Page

2D Game Engine in Java

Initially a project started to deepen my understanding of what's going on behind the scenes of each game that ended up inspiring me into creating a 2D top-down RPG game. Currently work in progress. It is being created using Java 1.8 using LWJGL. I have focused on correct Object Oriented Design that would make the creation of a game simple by extending the correct classes.
Eclipse Logo

Even though I have created games before using game engines such as game maker, it felt as if I was “cheating” as I never understood what was truly going on behind the scenes. I decided that it’s time that I take the matter in my own hands and start learning what is actually going on. I watched many tutorials online and read a lot of material. Java being the language I currently am most proficient at, I decided that I should create this project in Java 1.8, initially avoiding the use of any libraries. Later on I decided to include LWJGL (Lightweight Java Game Library) to benefit from the performance boost coming from the use of GPU. All the assets except the player have been taken from the internet and I do not own the rights for them. They are being used as placeholders to demonstrate the engine.

To enable level creation I have created a level editor within using the game engine itself. The use of text files has been used to store the information of each tile and other information to avoid hard-coding each tile separately. Each tile has a unique id associated with it. This feature was used to store the level itself as a .png file where the RGB of each pixel corresponds to the id of the tile. The functionality of the editor goes beyond editing and saving the level, but the designer can also display the grid, add new tiles or delete tiles that are no longer needed.

One of the newest updates to the game engine is the improvement of the light mechanism. To begin with the light is more smooth by employing different approach to light, in contrast to the old pixelated version. Further, coloured light and colour blending has been added enabling more attention to detail any light colour in the RGB spectrum can be used. The last additions included ray-casting to enable the use of shadows.

In order to give some context to the design choices, I shall explain that the main character is a pirate who gained fire conjuring abilities after finding a relic during a treasure hunt in a forgotten cave. This video illustrates the use of camera, some of the animations, the two-part melee combo, point and click projectile shooting (screen to camera to world coordinates), camera shaking collisions, live particles, lighting and more.