Hase und Igel

"Hase und Igel" is a extensive programming project I worked on during my 3rd semester at the FH Wedel University in Germany. The project is a full implementation of the game "Hase und Igel" using an object-oriented approach.

image

Implementation Details

The project was designed with good programming practices in mind, particularly by separating logic from the GUI.

Logic and GUI Separation

This allows for cleaner design and easier maintenance. The GUI frontend is completely independent of the game logic.

Multilingual Support

The frontend can be translated into any language because language tokens are used in the backend. A Translator object handles these tokens and provides translations, with German and English implemented by default.

Saving and Loading

Each game logic instance can create a GameData object, which acts as a wrapper for the core game information (like players and positions). This data is serialized into a JSON file using GSON, allowing for persistent game states.

JavaFX Timelines

Used to animate players as they move across the board, enhancing the user experience with smooth transitions.

Object-Oriented Design

Every in-game object has been represented as an object. This includes:

The game board is represented as an array of Field objects, where each field implements specific logic for player interactions.

Field Interface

Each field in the game implements the Field interface, which defines key interactions that can occur when a player moves on or interacts with the field.

public interface Field {
    // Get the type of the field
    FieldType getType();
    
    // Interact before the player moves to this field
    void interactBeforeMove(Player target);
    
    // Interact after the player has moved to this field
    void interactAfterMove(Player target, GameLogic game, GUIConnector gui);
    
    // Interact while the player is idling on the field
    void interactOnIdle(Player target, GameLogic game, GUIConnector gui);
    
    // Get the position of the field on the board
    int getPosition();
}

Program-Organization-Plan

image


Written: 2024-09-16