MENU

Jokemon

Repository

I developed Jokemon to experiment with building a game engine from scratch using only the Java standard library and console-based rendering. This project features a tile-based world system, persistent game saves via serialization, and a modular architecture for managing entities like buildings and Jokemons. It served as a deep dive into object-oriented design patterns and the use of modern Java features to simplify complex game logic.

Jokemon screenshot

Persistent Game State Serialization

To allow players to save and resume their progress, I implemented a comprehensive GameState serialization system. By implementing the Serializable interface, I could capture the entire world state—including player position, inventory, level, and the individual stats of all Jokemons—into a single binary file. This system ensures that complex object graphs are preserved accurately across different sessions, providing a seamless "Save/Load" experience in a traditionally stateless console environment.

Abstract Building Architecture

The world is populated with various interactable structures, all derived from a central Building abstract class. This architecture uses polymorphism to manage different building types—such as Medical facilities, Shops, and Houses—while sharing common properties like grid coordinates and ASCII-based design templates. This modular approach makes it trivial to expand the world with new building types by simply extending the base class and overriding the interaction logic.

Modern Java: Pattern Matching for switch

To handle the diverse interactions between players and world objects, I utilized Java 21's pattern matching for switch. This feature significantly reduces boilerplate by allowing for direct type-checking and extraction within the switch statement. This makes the code for generating building descriptions or handling collision events more readable and less error-prone compared to traditional instanceof chains.

Console Engine and ANSI Rendering

The rendering engine uses ANSI escape codes to provide a 2D-like experience in a text-based terminal. By manipulating the cursor position and using specific color codes, I was able to draw a scrollable map and animated character sprites. The game loop operates on a tick-based system, processing user input from the keyboard and updating the world state before re-rendering the relevant sections of the console, ensuring a flicker-free gameplay experience.