MinimapComponent - UQdeco2800/2022-studio-3 GitHub Wiki
Introduction
In order to keep track of the flow of the game, the map is condensed into a small minimap at the bottom right corner of the screen. This allows users to easily take stock of the state of the game, given the size of the map, by viewing where their buildings, allied units and enemies are relative to their current view.
The Minimap is displayed through the MinimapComponent, which extends RenderComponent in order to be visualised in-game. It must currently be attached to the terrain Entity, which is currently generated in AtlantisGameArea, and should hold both a TerrainComponent and a MinimapComponent.
The Minimap component will automatically render the game map once attached, set to layer 2, so it will render on top of the player and the terrain (which are on layers 1 and 0 respectively).
Usage
Creating a Minimap Component
The Minimap Component requires the TerrainComponent's TiledMap and the current game camera to be constructed. These can both be accessed as follows:
//Create map
terrain = terrainFactory.createAtlantisTerrainComponent();
//Add minimap component
MinimapComponent minimapComponent = new MinimapComponent(terrain.getMap(), (OrthographicCamera) terrainFactory.getCameraComponent().getCamera());
This will instantiate a new MinimapComponent, loaded with the current TiledMap associated with the TerrainComponent "terrain"
Creating the terrain entity which will display the game terrain and minimap
spawnEntity(new Entity().addComponent(terrain).addComponent(minimapComponent));
Will create the desired entity, after both components have been created.
Adjusting the Minimap size
If it is desired to make the Minimap smaller or larger, while retaining it's relative scale, the "MINIMAP_SCALE" constant may be adjusted in the MinimapComponent.java class.
e.g to double the Minimap size:
/**
* Scale the Minimap in size multiplicatively
*/
private final float MINIMAP_SCALE = 2f;