Skip to content
chloemicah edited this page Oct 14, 2024 · 19 revisions

The terrain in the provided example game uses tiles, placed orthogonally. The game includes functionality for creating terrains in different orientations, and converting from tile positions to world-space positions.

Key Components

  • TerrainComponent: This component, when attached to an entity, can be used to create and render a terrain. This is generally done through the TerrainFactory rather than directly instantiating it.
  • TerrainFactory: Where terrains get created, by choosing the orientation and filling in the tiles. When creating the factory, the desired tile orientation can be chosen. The TerrainFactory can then be used to create all the terrains in your game.
  • TerrainLoaderComponent: This component is responsible for dynamically loading and unloading terrain chunks based on the player's position, ensuring that only the relevant sections of the terrain are rendered as the player moves through the game world.
  • TerrainTile: Represents a single tile in the terrain. This can be modified to add features like walking speed, particle effects, and sound effects.
  • GameAreaDisplay: Represents the UI ascpect of map generation. This class sets up a Minimap frame in the bottom left corner of the screen which will house the minimap. he minimap frame will change aesthetically based on what animal the player is.
  • MinimapDisplay: Responsible fot the generation of minimap representing the player and all hostile entities in the area.
  • 'MapHandler: The MapHandlerclass manages the switching and retrieval of game maps, specificallyForestGameAreaandWaterGameArea`. It allows for transitioning between maps, optionally saving the current state, and provides methods to access the current map and specific map types.

Map tiles are created for the three Kingdoms (Land, Water, and Air). Additionally, kingdom specific items have been spawned as Obstacles for the player as well as increase aesthetic appeal.

minimap 1

UML Diagram

UML

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.

Sequence Diagram

Sequence Diagram

Summary:

  • ForestGameArea: Manages the game environment, entities, and music.
  • TerrainLoaderComponent: Handles terrain loading and updates.
  • TerrainFactory: Creates terrain and renderer.
  • TerrainChunk: Represents terrain chunks, managing tiles and grids.

Orientations

Orthogonal

Isometric

Hexagonal

How to change

To change the orientation, you need to:

  • Change the TerrainOrientation in the constructor of TerrainFactory. This will likely be somewhere in the GameArea.
  • Update TerrainFactory.createTerrain() to use the tile textures you've created for your orientation. In the example game, one terrain of each type is given. Orthogonal tile textures should be square, isometric tile textures should be a 'diamond' shape, and hexagonal tiles should be... hexagonal.

Test plan

The test plan for map is detailed in Map Testing

Clone this wiki locally