Chuyển đến nội dung
Skillpedia
Lập trình chung6.6k · #13814

tower-defense

Skill này làm gì

Skill này hướng dẫn xây dựng game tower defense, trong đó kẻ thù đi theo một con đường và người chơi đặt tháp để chặn chúng. Nó dành cho nhà phát triển làm game phòng thủ theo đợt và cân bằng đợt cùng kinh tế.

Khi nào nên dùng

  • ✓Khi bạn đang xây dựng game tower defense, trong đó tháp tấn công kẻ thù đi theo đường.
  • ✓Khi bạn cần thiết kế thành phần và nhịp độ của các đợt quái.
  • ✓Khi bạn muốn kinh tế vàng và nâng cấp tháp có cảm giác cân bằng.

Liên kết skill

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/genres/tower-defense/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/genres/tower-defense/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tôi đang làm game tower defense. Bạn có thể thiết lập kẻ thù đi bộ trên một đường, các tháp tự bắn và một bộ sinh đợt quái không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent làm cho kẻ thù đi theo một làn hoặc một mê cung, thiết lập các đợt theo thời gian với loại kẻ thù tăng dần, và để tháp tự nhắm và bắn. Mỗi lần hạ gục kiếm được vàng, và vàng dùng để đặt và nâng cấp tháp.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Tower Defense

A playbook for tower defense — enemy pathing, wave spawning, tower targeting, and the economy that ties them together. This is a compositional skill: it orchestrates pathing, AI, and UI into a TD loop. It does not re-teach pathfinding; it defines the systems and the balance levers (DPS vs. HP vs. income) that decide whether a TD is tense or trivial.

When to use

  • Use when building a game where the player places towers that automatically attack waves of enemies following a path, spends earned currency to expand/upgrade, and loses if too many enemies leak through.
  • Use when designing wave composition/pacing, tower targeting priorities, or the gold economy.

When not to use: the player directly controls a shooter → fps-shooter. Free-form base building with needs → survival-crafting. For the pathfinding algorithm itself, use game-ai.

Core loop

Prepare (place/upgrade towers with current gold) → start the wave → enemies path toward the goal while towers auto-fire → earn gold from kills → survive the wave → repeat against a harder one. The tension is a planning puzzle: is my current DPS enough for what's coming, and can I afford the answer?

Must-have systems

  1. Enemy path — waypoint lanes, or grid + pathfinding for maze TD (refs).
  2. Wave spawner — timed, scripted sequences of enemy types with per-wave scaling.
  3. Towers — range, fire rate, damage, projectile/hitscan, splash; placement validity.
  4. Targeting — per-tower priority (first/last/closest/strongest/weakest) (refs).
  5. Economy — gold from kills + wave bonuses; tower/upgrade costs; sell refund.
  6. Lives / leak — enemies reaching the goal cost lives; 0 = game over.
  7. Wave/prep UI — lives, gold, next-wave preview, start-next-wave control.

Design knobs

Knob Effect Notes
Enemy HP growth/wave upgrade pressure Geometric ~1.1–1.2× (refs).
Income vs. HP curves difficulty Player should almost afford each wave.
Tower DPS / range / cost tower identity Cheap+wide vs. expensive+tall.
Targeting priority optimal placement Changes play more than raw stats.
Enemy variety counters one-build wins Fast / armored / flying / swarm / boss.
Leak penalty stakes Cost lives and lost bounty.
Upgrade vs. build economy strategy depth Diminishing upgrade returns.
Wave pacing tension curve Spike → breather → spike, not monotonic.

Patterns

1. Wave spawner (timed, data-driven)

# Pseudocode. A wave is data: a list of (enemy_type, count, spacing). Spawn over time.
wave = [ ("grunt", 10, 0.5), ("runner", 5, 0.3), ("tank", 2, 1.0) ]

def run_wave(wave):
    for enemy_type, count, spacing in wave:
        for _ in range(count):
            spawn_enemy(enemy_type, at=path[0])   # enter at the path start
            wait(spacing)                          # seconds between spawns (use a timer/coroutine)
    # wave clears when all spawned enemies are dead or have leaked

2. Tower targeting (filter to range, then pick by priority)

# Pseudocode. "First" (furthest along path) is the standard default for stopping leaks.
def acquire_target(tower, enemies, mode="first"):
    in_range = [e for e in enemies if distance(tower.pos, e.pos) <= tower.range]
    if not in_range: return None
    if mode == "first":    return max(in_range, key=lambda e: e.progress)   # furthest along path (stop leaks)
    if mode == "last":     return min(in_range, key=lambda e: e.progress)   # least progress (guard the entrance)
    if mode == "closest":  return min(in_range, key=lambda e: distance(tower.pos, e.pos))
    if mode == "strongest":return max(in_range, key=lambda e: e.hp)         # burn down tanks first
    if mode == "weakest":  return min(in_range, key=lambda e: e.hp)         # secure kills / last-hit bounty
    return in_range[0]

3. "Can this lane hold?" sanity check (DPS vs. HP)

# Pseudocode. One tower's damage to one enemy crossing its range.
tower_dps     = tower.damage * tower.fire_rate
time_in_range = tower.range_coverage_length / enemy.speed
Câu hỏi thường gặp

Đường đi hoạt động thế nào?

Skill bao quát làn điểm dẫn đường hoặc lưới có tìm đường cho các game kiểu mê cung.

Điều gì làm tower defense căng thẳng?

Skill nói sự căng thẳng đến từ việc lên kế hoạch xem sát thương hiện tại có đủ cho đợt tiếp theo không, và bạn có đủ tiền cho câu trả lời đó không.

Nó có bao quát chính thuật toán tìm đường không?

Không. Skill AI game bao quát thuật toán tìm đường mà skill này sử dụng.

Chi tiết

Mô tả gốc của tác giả

Build a tower defense: enemies pathing along lanes, wave spawning, towers that auto-target and fire, an economy, and lives. Use for a tower-defense/wave-defense game, or balancing waves and economy.

repo: gamedev-skills/awesome-gamedev-agent-skills

Độ phổ biến

Sao GitHub
6.6k
Vị trí xếp hạng
#13814
Giấy phép
Apache-2.0
Cập nhật
28/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự