Skip to content
Dabby edited this page Sep 11, 2024 · 15 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 top-right corner of the screen which will eventually house the minimap in later iterations of the game (a task reserved for future sprints). The minimap frame will change aesthetically based on what kingdome the player is in.

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.

UML - I

This UML diagram shows the relationship between the GameAreaDisplay and UIComponent classes. GameAreaDisplay is a concrete class responsible for displaying game area information, such as the title, player icon, and minimap frame. It has attributes like gameAreaName, title, playerIconTexture, and minimapFrameTexture, and methods for creating the display, drawing it, and disposing of resources.

UML - II

TerrainComponent class manages the game's tiled map, rendering it with a camera and loading or unloading terrain chunks as needed. It uses the TerrainResource class to handle the game's tiles. TerrainResource stores a collection of Tile objects, which represent individual terrain units. Each Tile has a texture and directional connections defined by BitSet attributes (up, right, down, left), which manage how tiles connect to each other. The orientation of each tile is determined by the TerrainOrientation enum, which specifies four possible directions: UP, RIGHT, DOWN, and LEFT.

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.

Minimap

  • Note: The appearence and positioning of the minimap frame assets are subject to change.

minimap 1

minimap 2

minimap 3

The minimap will be housed in a different frame depending on the player's location on the map (kingdoms).

  • Since there isn't a seamless way to switch maps implemented as of sprint-2, the minimap frame changes with the animal the player chose for now.
  • This can easily be changed whenever proper progression mechanics to change kingdoms will be implemented given how GameAreaDisplay is set up.
  • The same applies to UI component positioning on the HUD.

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