# Tower Defense

<figure><img src="https://1963719226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV8pr5EgDZn2rnTUJE8XB%2Fuploads%2FmvWAH2BfH05mV9dnC5bP%2Fimage.png?alt=media&#x26;token=a8fde438-6ac8-473b-905c-843f4f0c9f80" alt=""><figcaption></figcaption></figure>

Tower defense is a subgenre of strategy games where players protect their territory against waves of enemy attackers.

## Characteristics

***Defend!***

Use resources wisely to survive all waves of increasingly difficult enemies.

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>ENEMY WAVES</strong></td><td><p><span data-gb-custom-inline data-tag="emoji" data-code="21a9">↩️</span> Pathing</p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f538">🔸</span><span data-gb-custom-inline data-tag="emoji" data-code="1f537">🔷</span> Variety (health, number, loot, etc)<br><span data-gb-custom-inline data-tag="emoji" data-code="2795">➕</span> Increasing difficulty (type, number, etc) </p></td></tr><tr><td><strong>TOWER STRATEGY</strong></td><td><p><span data-gb-custom-inline data-tag="emoji" data-code="2716">✖️</span> Placement</p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f538">🔸</span><span data-gb-custom-inline data-tag="emoji" data-code="1f537">🔷</span> Variety (attack strength, type, size, etc)</p><p><span data-gb-custom-inline data-tag="emoji" data-code="1fa99">🪙</span> Buy towers / <span data-gb-custom-inline data-tag="emoji" data-code="1f9f1">🧱</span> Build with resources</p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f199">🆙</span> Upgrade towers</p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f513">🔓</span>Unlock new types</p></td></tr></tbody></table>

#### Keys of Success

* **Everyone Can Play -** Main player actions are placing units
* **Play for Long -** Many levels and difficulties, new releases, endless mode
* **Flexible Play Modes -** Multiplayer with humans or singleplayer with NPCs

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>NEED TO HAVE</strong></td><td><ul><li>Logic to place/spawn towers</li><li>Spawning and pathing for enemies</li><li>Varied tower types and enemies</li></ul></td></tr><tr><td><strong>NICE TO HAVE</strong></td><td><ul><li>Resource Farming <strong>-</strong> Harvest resources (building materials, currency, etc)</li><li>Research <strong>-</strong> Unlock new tower types or abilities through research</li></ul></td></tr></tbody></table>

## Game Loops

Below is a general game loop diagram for this genre. Your game's loops may vary.

<figure><img src="https://1963719226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV8pr5EgDZn2rnTUJE8XB%2Fuploads%2FG6WMI8vbmVucGM99CUA9%2Fimage.png?alt=media&#x26;token=e68d3307-5650-41c3-90b7-01c042034cf9" alt="" width="563"><figcaption></figcaption></figure>

### **Variations of Strategy**

<table data-view="cards" data-full-width="false"><thead><tr><th></th></tr></thead><tbody><tr><td><strong>Real-Time Strategy (RTS):</strong> <br>Players make decisions in real-time, managing resources and armies.</td></tr><tr><td><strong>Turn-Based Strategy (TBS):</strong> <br>Players take turns making strategic decisions and controlling units.</td></tr><tr><td><strong>4X (Explore, Expand, Exploit, Exterminate):</strong><br>Empire-building and grand strategy.</td></tr></tbody></table>

## Learn to Create It

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>GAME MAKER TEMPLATE</strong></td><td><img src="https://lh7-us.googleusercontent.com/QObImkZdhYX7cOk4jyyiqGdlC2J4oW-kBEd-Wr0jPSVlyPSt6ew4xFrqh_-p8FUTGAklUuYJrgW6_TtFpqXJqcJp_nuRHQmy_doqv9EeC_RhciW-hukTuIY6gVzxFF-bgLe0tLWG9g8FsMhTFQViY_gkrQ=s2048" alt=""></td></tr><tr><td><strong>LOGIC TO EXPLORE</strong></td><td><ul><li>Enemy waves</li><li>Gaining resources</li><li>Buying towers</li></ul></td></tr></tbody></table>

### Make it More Interesting

Consider ways to add to or change the core structure of this game type to challenge and motivate players differently.

<table data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>MAIN OBJECTIVE</strong></td><td><p>🛡️ Build enough defense to explore &#x26; loot</p><p>⚔️ Vs enemies or teams</p></td></tr><tr><td><strong>RAMP OF DIFFICULTY</strong></td><td><p>⚒️ Craft rather than buy</p><p>🎲 Randomized patterns</p></td></tr><tr><td><strong>CORE DECISIONS</strong></td><td><p>🌇 Turn based or constant</p><p>⛈️ Weather impacts</p><p>⚙️ Precise tower variations</p></td></tr></tbody></table>

> **PRACTICE: Modify the Life Jumper template to increase the fun:**
>
> * Tower abilities
> * [projectile](https://docs.sandbox.game/jp/creators/game-maker/document/behavior/projectile "mention") & [raycast](https://docs.sandbox.game/jp/creators/game-maker/document/components/raycast "mention") (varied tower [presets](https://docs.sandbox.game/jp/creators/game-maker/document/build-menus/side-bar/preset))
> * Passive/idle resource generation

### Useful Logic

* [resource-management](https://docs.sandbox.game/jp/creators/game-maker/creative-guide/experience-guide/resource-management "mention") logic (sub-genre)

## Tutorial Videos (English)

Open the Game Maker Tower Defense Template for logic included in the tutorials below.

View Tower Defense Game Jam entries in the Game Maker Gallery for examples of this genre.

### NPC Waves

{% embed url="<https://youtu.be/d8HsVhkUvTA?feature=shared>" %}

### Basic Tower, Money, Life System

{% embed url="<https://youtu.be/l1eI2QKqR1A?feature=shared>" %}

### Tower Building System

{% embed url="<https://youtu.be/gCQ0MJY3qUY?feature=shared>" %}

### Wave Counter System

{% embed url="<https://youtu.be/cp2cj-6APLU?feature=shared>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sandbox.game/jp/creators/game-maker/creative-guide/experience-guide/tower-defense.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
