# Depth Sorting Occlusion

> Use when sprites draw in the wrong order so characters appear in front of objects they should be behind in an isometric scene.

- **Type:** Skill
- **Install:** `agentstack add skill-0xheycat-isometric-game-skills-depth-sorting-occlusion`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [0xheycat](https://agentstack.voostack.com/s/0xheycat)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [0xheycat](https://github.com/0xheycat)
- **Source:** https://github.com/0xheycat/isometric-game-skills/tree/master/skills/depth-sorting-occlusion
- **Website:** https://0xheycat.github.io/isometric-game-skills/demo/

## Install

```sh
agentstack add skill-0xheycat-isometric-game-skills-depth-sorting-occlusion
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Depth Sorting & Occlusion

## Overview

In isometric, draw order IS depth. A character is behind a tree if its anchor tile sorts earlier. This skill gives the correct sort key and handles tall/multi-tile objects that break naive sorting.

## When to Use

- Characters render in front of trees/walls they should be behind.
- Tall or multi-tile objects sort incorrectly.
- You added objects and the layering looks wrong.

## Process

1. Give every drawable a depth key based on its anchor tile: depth = row + col.
2. Sort all objects by depth ascending before drawing.
3. For ties, break by a secondary key (e.g. y, then creation order).
4. For multi-tile objects, sort by the FRONT-most occupied tile.
5. For very tall objects, consider splitting into stackable slices.
6. Re-sort only when objects move, not every frame if static.
7. Test the classic case: walk a character around all four sides of a tree.

```js
objects.sort((a, b) => (a.row + a.col) - (b.row + b.col));
```

## Rationalizations (Stop Lying to Yourself)

| Excuse | Reality |
|---|---|
| "Painter order by y is good enough" | Pure y fails for multi-tile and tall sprites. Use anchor row+col. |
| "I will sort once at load" | Moving objects must re-sort. Sort on movement. |

## Red Flags - STOP if you catch yourself:

- Sorting by raw y instead of anchor tile.
- Multi-tile objects using their center instead of front tile.
- Characters clipping through tall buildings.

## Verification

You are NOT done until every box is checked:

- [ ] Walking around all sides of an object always sorts correctly.
- [ ] Multi-tile and tall objects occlude properly.
- [ ] Sorting updates when objects move.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [0xheycat](https://github.com/0xheycat)
- **Source:** [0xheycat/isometric-game-skills](https://github.com/0xheycat/isometric-game-skills)
- **License:** MIT
- **Homepage:** https://0xheycat.github.io/isometric-game-skills/demo/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-0xheycat-isometric-game-skills-depth-sorting-occlusion
- Seller: https://agentstack.voostack.com/s/0xheycat
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
