Mini Map System - UQcsse3200/2024-studio-1 GitHub Wiki
Overview
The Minimap System is an essential component of the game, providing players with a compact, real-time view of their surroundings in a 5 x. 5 grid system. This system utilizes a secondary camera to render a scaled-down version of the game world, enhancing navigation and making it easier for player to find various rooms in the game world.It has various key components such as
- Minimap Component
- Minimap Tile
- Renderer
- Renderer Service
Minimap Component
The MinimapComponent class is the core of the minimap system. It extends RenderComponent and is basically responsible for rendering the minimap to the game screen.
Features
-
Renders a portion of the game map using a
TiledMapRenderer
-
Draws a player locator on the minimap ( as shown green is the player coordinates and the room connection keeps changing relatively as th player navigates the game )
-
Converts between tile coordinates and world positions
Main Methods
tileToWorldPosition(GridPoint2 tilePos)
- Converts tile coordinates to world positionsgetMapBounds(int layer)
- Returns the dimensions of the map layerdraw(SpriteBatch batch)
- Renders the minimap and player locator
Usage
Minimap Tile
The MinimapTile class implements TiledMapTile
and represents individual tiles on the minimap.
Key Features
- Stores texture region for the tile
- Manages tile properties such as ID and blend mode
Tilesets
The minimap uses different tile sets for Normalroom
,boss room
,Gamblingroom
and NPC shop room
to provide visual distinction to the player
-
Normal room -
-
Boss Room -
-
Shop room -
-
Overall minimap asset -
Minimap Factory
Basically its responsible for creating and managing minimap instances for different rooms in the game.
Key Features
- Creates minimap instances for different room types (Normal, Boss, Gambling, NPC Shop)
- Manages tile sets for each room type
- Handles room connections and layouts
Usage
Connection system
- The minimap uses a connection code system to determine room layouts:
- The code is a 4-digit binary string (e.g., "1101")
- Each digit represents a direction: North, South, West, East
- '1' indicates a connection, '0' indicates no connection - "1101" means the room has connections to the North, South, and West, but not to the East.
Renderer
The Renderer class manages the rendering of both the main game scene and the minimap. It utilizes two cameras:
mainCamera
: For rendering the main game world
secondaryCamera
: For rendering the minimap
renderSecondaryScene()
: Renders the minimap using the secondary camera
Implementing minimap
- Create instances of
MinimapComponent
for each area that needs a minimap. - Register the MinimapComponent with the RenderService.
- Ensure the Renderer is set up with both main and secondary cameras.
- Update the player's position on the minimap in the game loop.