Map Tiles - UQcsse3200/2024-studio-2 GitHub Wiki

Placing Objects on Tiles

In the game, the world is built from tiles that form different regions, like the Forest Kingdom, Sky Kingdom, or Ocean Kingdom. Tiles are also used to indicate which regions have yet to be unlocked by covering the existing tiles of the areas with an overlaying tile, Fog. Each tile represents a small part of the map and can hold various objects, such as trees, obstacles, or characters.

basic tiles as follow:

1. grass tile:

grass tile

2. dynamic water tile:

water

3. sand tile:

sand tile

4. Further design and modification of the map to make the map more natural: Here is the combined display of the map. The display is composed of 3x3 tiles, with a total of six combinations. Each combination has three different configurations: one-third, two-thirds, and corner positions.

* grass around water:

grass around water 1 grass around water 2 water with grass corner

* grass around sand:

grass around sand 1 grass around sand 2 water with grass corner

* sand around grass:

sand around grass 1 sand around grass 2 grass with sand corner

* sand around water:

sand around water 1 sand around water 2 water with sand corner

* water around grass:

water around grass 1 water around grass 2 grass with water corner

* water around sand:

water around sand 1 water around sand 2 sand with water corner

**4.sky tiles

Here is the combined display of the map. The display is composed of 3x3 tiles, with a total of four combinations. Each combination has three different configurations: one-third, two-thirds

sky wiki page 1

sky wiki page 2

* fog gate: fog-gate

How to Place Objects on Specific Tiles

  1. Identify the Tile's Position:
    Tiles are located using grid coordinates (e.g., (x, y)). These coordinates map the tile’s position in the world. The tiles size and orientation (orthogonal, isometric, or hexagonal) determine how the grid coordinates are converted to world coordinates.

    GridPoint2 tilePos = new GridPoint2(5, 3);  // Example tile position
    
    
  2. Convert the Tile Position to World Position: Use the TerrainComponent to convert the grid position into the corresponding world position, which is needed to place objects correctly.

    Vector2 worldPos = terrainComponent.tileToWorldPosition(tilePos);
    
    
  3. Placing the Object: After converting the position, create the entity (e.g., a tree, obstacle, or enemy) and place it on the desired tile

    Entity tree = ObstacleFactory.createTree(); spawnEntityAt(tree, tilePos, true, false);

Handling Different Objects

Static Objects (trees, rocks)

Static objects, such as trees or rocks, are placed on tiles in a similar way by creating the object and positioning it on the map.

Entity rock = ObstacleFactory.createRock();
spawnEntityAt(rock, new GridPoint2(4, 2), true, false);

Dynamic Objects (enemies, NPCS)

Dynamic objects, such as enemies or NPCs, can also be placed on tiles. For example, placing an enemy on a tile would look like this,

GridPoint2 enemyTilePos = new GridPoint2(8, 6);  // Tile position
Entity ghost = NPCFactory.createGhost(player);  // Create the ghost entity
spawnEntityAt(ghost, enemyTilePos, true, true);  // Place the ghost

Tile and Terrain Interaction

Tiles can also affect gameplay depending on the terrain type. For example, moving onto a water tile could slow down the player's movement,

if (currentTileType == TileType.WATER) {
    playerEntity.getComponent(MovementComponent.class).setSpeed(WATER_SLOW_SPEED);
}

Testing

image

Populating Landmarks for the Map

Landmarks, such as buildings or points of interest, can be placed on the map to mark important locations. These are stored as coordinates using the Vector2 class. To add a landmark, populate the landmarks list with Vector2 positions that represent world coordinates.

public void preloadLandmarks() {
    landmarks = new ArrayList<>();
    landmarks.add(new Vector2(500, 800));  // Example
    // ADD MORE
  }

## Handling unlocked regions
To check if players have met the requirements to unlock regions and lift the fog it is checked first whether the trigger of `landBossDefeated`, `waterBossDefeated` or `airBossDefeated`.