-
Notifications
You must be signed in to change notification settings - Fork 1
Map Generation
The Map for the game makes use of tiling algorithms. It is generated by dividing it into small chunks, each containing terrain tiles. These chunks are then loaded dynamically based on the player’s current location, hereby ensuring only nearby sections are generated and rendered. The tiles within each chunk are selected to fit seamlessly together, creating a coherent terrain. This approach is made to optimize performance by focusing on the areas near the player while simultaneously managing a larger, cohesive map.
The map is generated in chunks and each chunk is represented as a grid consisting of 16x16 tiles. Since the terrain is divided into multiple areas (such as forest, water, fog etc.), the tiles in each chunk are assigned according to the area type. Bitsets are used to track possible tile configurations for each cell in the chunk and iteratively selects and "collapses" tiles until the terrain is finally fully defined.
APIs
LibGDX: Game framework used for graphics, input handling, and sound.
JSON: Used to load and configure levels such as terrain types and spawn points.
Code
Game Logic: Written in Java using object-oriented principles.
Modular Architecture: Terrain, player, and item components are managed using independent classes to improve scalability.
TerrainComponent: Handles terrain rendering, tile selection, and interaction between tiles across different map areas.
TerrainFactory: Generates terrain components with customizable map types and orientations like orthogonal, isometric, or hexagonal.
TerrainChunk: Manages 16x16 terrain chunks, generates terrain tiles using entropy-based algorithms, and ensures area-specific tile placement.
Features
Chunk-Based Generation: Divides the terrain into 16x16 chunks, each handled separately to optimize loading and rendering.
Area-specific Tiles: Dynamically assigning of tiles to chunks based on their location in predefined areas (forest, water, fog, or air).
BitSet-based Tiles: Utilization of bitsets to track possible tiles for each cell, ensuring efficient generation and rendering of the terrain.
Entropy-based Tile Collapsing: Collapsing of tile options by selecting tiles with minimal entropy to ensure a coherent, structured terrain.
Dynamic Map : Continuously updating grid data and terrain based on nearby chunks.
This UML class diagram presents four main classes along with their attributes, methods, and relationships: ForestGameArea, GameArea, TerrainLoaderComponent, Component, and TerrainFactory. The UML class diagram provides a detailed description of the collaboration between ForestGameArea and TerrainFactory, showcasing how TerrainLoaderComponent is used to load terrain chunks, thereby illustrating a hierarchical system for creating and managing game areas.