# Pixel Tower Defense

像素塔防

A 20-level tower-defense game for M5Stack Tab5, with every pixel and sound generated in code.

面向 M5Stack Tab5 的 20 关像素塔防，画面与声音全部由代码生成。

- id: pixel-tower-defense
- author: andjiang0083
- repository: https://github.com/andjiang0083/pixel-tower-defense
- license: MIT
- shape: wide
- scenes: games, art
- boards: M5Stack Tab5 (ESP32-P4)
- browser_playable: yes
- preview: Interactive replay
- html: https://esp32gallery.com/projects/pixel-tower-defense/
- html_zh: https://esp32gallery.com/zh/projects/pixel-tower-defense/
- json: https://esp32gallery.com/data/catalog/projects/pixel-tower-defense.json

## Hardware

M5Stack Tab5 with a 1280 × 720 touchscreen. A source-based desktop simulator exists in the repository.

带 1280 × 720 触屏的 M5Stack Tab5。项目仓库包含基于同一份源码的桌面模拟器。

## English

```
Twenty levels of build-a-maze tower defence on the M5Stack Tab5's 1280×720 touch panel, with five tower types, nine enemy kinds including air units and healers, and nine boss abilities — up to two bosses per level. The rule that shapes everything is that no asset files exist at all: the 5×7 Latin font is 95 hand-written bitmaps, the 16×16 Chinese glyphs are generated from the game's own string table, sound effects are synthesised square waves and LFSR noise at build time, and every sprite is a stack of rectangles. Maps come from a Python layout tool, and difficulty moves through buildable space rather than bigger numbers. A PC simulator compiles the real sources and plays all twenty levels under 370 assertions. Flash with PlatformIO, or erase-flash first and then write the merged image at offset 0x0.
```

## 中文

```
一块 M5Stack Tab5 上打塔防：1280×720 触屏，20 关，路径从右边缘通向基地，五种塔各升三级，敌人有九类，包括直飞基地的空中单位和会治疗的小怪，九个 Boss 能力，每关最多两个 Boss。项目立了条硬规矩——不带任何素材文件：5×7 拉丁字体是 95 个手写位图，16×16 中文字形由脚本按字符串表现生成，音效在构建时用方波和噪声合成，所有画面都是 fillRect 堆出来的。地图由 Python 脚本生成，难度靠可建造空间而不是数值。PC 模拟器把固件源码编进去跑完 20 关，370 项断言；烧录前务必先 erase-flash，再写 0x0 的合并镜像。
```
