Roguelike: Part 2: Every Turn Has Teeth
Add turn-based combat with attack calculations, enemy AI that chases the player, health tracking, and damage signals in GDScript.
No login required.
Turn Management
Every roguelike alternates between player and enemy turns. The code is now split across main.gd (coordinator + input), player.gd (position/HP), and enemy.gd (AI). You'll add turn state tracking and the turn switch.
Turn management controls who can act and when. That is what makes a game turn-based.
Loading game...
Click the game window to interact with it
What You'll Build
You will add enemies that take turns after the player moves. Enemies chase the player using simple AI (move toward target), attack when adjacent, and take damage from the player. Health tracking, damage calculation, and death handling turn the dungeon into an actual game with stakes.
Learning Goals
- ✓Turn sequencing: player acts, then all enemies act
- ✓Vector math for distance checks and chase direction
- ✓Signal-based health and damage communication
- ✓Enemy AI with pathfinding toward the player
- ✓Death handling with queue_free() and state cleanup
GDScript Concepts in This Part
Tips
- ✨Process enemies in a for loop after the player's turn — this keeps the turn order deterministic and easy to debug.
- ✨Use sign() on direction vectors to snap enemy movement to cardinal directions on the grid.