# World of Chaos : Dungeon and Knowledge

First level should be a very hard wave defense where you need to lose, but the difficulty go higher until the player cannot defend it anymore.

Add effect for item drop or mob drop for rarity with special sound and effect for legendary one.

___

 ## 1. Game Overview

 - Name-> World of Chaos : Dungeon and Knowledge

 - Genre-> Real-time Survival Base-Builder & Defense with Sandbox Construction, Tech-Tree Progression, Wave Survival, Dungeon-Crawl
 - Platform-> Desktop (Windows, Linux)
 - Perspective-> 2D Top-Down, Tile-Based
 - Core Experience-> Fast-paced, responsive building + combat (akin to MOBA/RTS), layered loops reward both planning (base, tech) and moment-to-moment skill (aim, positioning).

___

 ## 2. High-Level Concept

 - MVP Vision:

	 - Sandbox Build Mode: Place walls, turrets, resource-gatherers on a grid.

	 - Defense Loop: Survive waves of enemies attacking your base.

	 - Round Survival Loop: Fixed-arena rounds with escalating difficulty.

	 - Dungeon Crawl Loop: Enter procedural dungeon, defeat boss; failure sends boss to assault your base in next wave.



 - USP (Unique Selling Points):

	 - Four interlocking loops: your dungeon success directly impacts base defense.

	 - Deep tech-tree: unlock new defenses, units, dungeon skills.

	 - Responsive, omnidirectional movement & aiming—skill matters.

___

 ## 3. Core Gameplay Mechanics

 - Movement & Combat:
	 - 8-directional movement.
	 - real-time aiming with mouse.
	 - instant feedback on attacks & blocks.
 - Building:
	 - Grid-snapping placement.
	 - rotate/flip tiles.
	 - undo/redo.
	 - resource cost preview.
 - Resources:
	 - Wood, Stone, Metal.
	 - gathered via structures or dungeon pickups.
 - Tech Tree:
	 - Multi-branch:
		 - Base Defense.
		 - Resource Efficiency.
		 - Dungeon Skills.
		 - Elite Units.
 - Enemy Waves:
	 - Scripted + procedural mix.
	 - includes fast scouts, heavy brutes, flying units.
 - Dungeon:
	 - Procedural rooms.
	 - puzzles.
	 - minibosses.
	 - culminates in boss fight with unique mechanics.

___

 ## 4. Game Loops

 - Sandbox Build (Persistent): Place/upgrade structures; plan defenses.

 - Defense Wave (Dynamic): Enemies pathfind toward base; survive until timer.

 - Round Survival (Arena): Fixed map, randomized spawn points; earn bonus resources per round.

 - Dungeon Crawl: Voluntary loop—risk vs. reward. Dungeon boss grants tech unlock on success; on failure, boss invades next wave.

 - Opinion: Prioritize implementing the Defense Wave & Sandbox Build first—they form the spine of player engagement. Then layer in Round Survival. Dungeon Crawl can initially be a single hand-crafted level to prove the loop.

___

 ## 5. MVP Feature List

 - A. Core Systems (Week 1–3)

	 - Tilemap rendering & collision (raylib tilemap module)

	 - Player movement/aim/shoot

	 - Basic enemy AI (pathfinding to base)

 - B. Building & Resources (Week 4–6)

	 - Place/destroy grid-aligned buildings

	 - Resource spawn & collection

 - C. Wave Defense Loop (Week 7–9)

	 - Wave spawner, UI timer, win/lose conditions

 - D. Tech Tree UI & Data (Week 10–11)

	- Data-driven tech nodes, unlock logic, simple UI

 - E. Round Survival & Score (Week 12–13)

 - F. Dungeon Prototype (Week 14–16)

___

 ## 6. Tech-Tree Design

```
        [Resource Efficiency]──┐
                               ├─[Advanced Turrets]──[Energy Shield]
        [Base Armor]───────────┘                      │
                                                      ├─[Boss Summon Tech]
        [Trap Mastery]─────────┐                      │
                               ├─[Dungeon Vision]─────┘
        [Spellcraft]───────────┘
```

 - Node Details:

	 - Cost in tech-points (earned per wave/dungeon).

	 - Prerequisites enforce meaningful choices.

	 - Strong opinion: cap tech depth to 15–20 nodes for MVP.

___

 ## 7. Systems Architecture

 - Language: C99

 - Engine: raylib (windowing, input, 2D rendering, audio)

 - Modules:

```
        tilemap.c/h (grid, pathfinding)

        player.c/h (movement, input)

        entity.c/h (enemies, projectiles)

        buildings.c/h (construction, upgrades)

        waves.c/h (spawn logic)

        dungeon.c/h (room gen, boss logic)

        tech.c/h (tech-tree data & UI)

        ui.c/h (HUD, menus)
```

 - Data: JSON or simple CSV for wave definitions, tech nodes, tile properties.

___

## 8. Controls & UI

 - Controls:

	 - WASD or arrows: Move

	 - Mouse: Aim & shoot

	 - 1–5: Hotkeys for building types

	 - T: Open Tech Tree

	 - Esc: Menu/Pause

 - UI Layout:

	 - Top-center: Wave timer & round

	 - Bottom-left: Resource counters

	 - Bottom-right: Build hotkeys

	 - Center-right: Tech-tree button

___

## 9. Art & Audio (MVP)

 - Art Style: Simple, high-contrast tiles; clear readability over detail.

 - Animations: 4-frame loops for player/enemies.

 - Audio:
	 - Looping ambient track

	 - SFX: construction, shooting, enemy death

 - Opinion: Defer polish art until gameplay is locked; use placeholders but ensure clarity.

___

## 10. Success Metrics & KPIs

 - Playtest Goal: Survive at least 5 waves with basic defenses.

 - Performance: Stable 60 FPS on moderate hardware (Intel i5, integrated GPU).

 - Engagement: Test loop—players should face meaningful choices every 30 s.

___

## 11. Risks & Mitigations

```
	Risk->Mitigation:

Pathfinding stalls on large maps->Limit map size; use A* with node caching
Feature creep (dungeon complexity)->Lock dungeon to 3 room types for MVP
Balancing tech-tree overpowered->Data-driven values; expose easy tuning parameters
```

___

## 12. Roadmap & Milestones

 - Prototype (Weeks 1–3): Movement, tilemap, enemy pathfind.

 - Alpha (Weeks 4–9): Building, resources, first 3 waves.

 - Beta (Weeks 10–14): Tech tree, survival rounds, basic dungeon.

 - MVP Release (Week 16): All loops functional; placeholder assets.

___

## 13. Next Steps

 - Review GDD—prioritize any missing “must-have.”

 - Scaffold C modules & basic raylib window.

 - Implement tilemap + player movement immediately.

 - Schedule weekly playtest to validate loops.

___

## how it started

I give myself 2 mounth to finish this project, the roadmap can be seen in roguelike_projecct_roadmap.md

the point is to challenge myself to finish a simple commercial game

```c
typedef struct {
	int height, width;
	float rotation;
}	obstacle_hitbox;
```
___

## idea

- base building and defense (kinda more like terraria)
- dungeon exploration
- wave survival
- exploration ?
- hand crafted world no procedural (only dungeon using presets parts)
- using advanced shader using normal texture and depth of object top down 2D

- load level from tiled xml
- use tile in a 3D world, but only one layer with cartoon texture

___

### refs art:

- https://www.youtube.com/watch?v=R6vQ9VmMz2w
- https://www.youtube.com/watch?v=YVUPgiyB6iM
- https://www.youtube.com/watch?v=HsOKwUwL1bE
