Skip to content

Flooding System

quocdat402 edited this page Oct 17, 2022 · 7 revisions

Overview

Flooding system will shrink the city overtime while you try to build resource and optimize your procution and try to save as many people as you can. There is a flooding meter indicate when the flood will start, once the flooding meter is full, the flooing will start to cover starting from left and right of map tile and the process is repeated untill the entire map is fully covered in water and the game will be over.

Technical Breakdown

Below is the code to get the tiles to be flooded. It is used under the flashTiles() void function. The key idea is to get the left and right of the island into dictionary, and then use it for the flashing tiles.

    public void flashTiles() {
        // Container to represent squares to be flooded next
        boolean[][] nextSquaresToBeFlooded = new boolean[mapHeight][mapWidth];

        // Find the furthest left and right coordinates of the island
        Pair<Integer, Integer> extremities = this.getIslandExtremities();
        int farLeft = extremities.getKey();
        int farRight = extremities.getValue();

        // Pick tiles to be flooded and flood them
        nextSquaresToBeFlooded = this.pickTilesToFlood(nextSquaresToBeFlooded, farLeft, farRight);
        this.tilesToFlood = nextSquaresToBeFlooded;
        this.updateFlashingTiles();
    }

From here, the tilesToFlood variable will be used again in the change the tiles into ocean Tiles in the flood() function.

public void flood() {
        for (int i = 0; i < mapHeight; i++) {
            for (int j = 0; j < mapWidth; j++) {
                if (tilesToFlood[i][j]) {
                    this.map[i][j] = this.getOceanChar();
                }
            }
        }
        disposeFloodedSquares();
    }

UML diagram

Table of Contents

Home

Game

Game Home

Design Influences

Gameplay Features

Style

Story

Friendly Units
Map
City
Buildings
Unit Selections

Spell

Game User Testing: Theme of Unit Selection & Spell System

UI User Testing

Tutorial

Resource Stats Display

Loading Screen Bar

Health Bars
In Game menu
  • Feature
  • User Testing:In Game Menu

Landscape Tile Design

Landscape Tile Design Feedback

Weather Design

Weather Design Feedback

Camera Movement

Enemy design

Enemy Units

Enemy AI

How Animation Works

Map Flooding

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally