# What a Sprite Sheet Is: How a Walking Character Fits in One Image

How a grid of drawings in one image becomes a smoothly animated 2D character, and why the frame index, the clip and a delta-time timer have to line up.

> sprite sheets · 2D animation · About 8 min · Nov 2

## Key points

1. A sprite sheet is one ordinary image file holding many sprites in a grid; the file records no layout, so cell size and column count live in the engine settings or code.
2. Drawing "frame 8" never cuts the image: the draw call samples a source rectangle from the single texture, and that rectangle comes from the frame index, cell size and column count.
3. A clip is a named ordered list of cells plus loop rules; the grid supplies pictures, but you decide which cells form "walk" and which form "idle".
4. Animation speed must be driven by delta time rather than one step per game frame, or the clip plays faster on faster hardware; a timer that subtracts one step keeps leftover time so playback stays steady.
5. Packing frames into one image also cuts texture swaps, which is why a sprite sheet doubles as a texture atlas.
6. Most sprite-sheet bugs come from cells that do not divide the image evenly, per-frame trimming, inconsistent pivots, or confusing animation FPS with game frame rate.

---

A 2D character walking across the screen is not one picture sliding sideways. It is a handful of separate drawings — foot forward, foot down, foot back — shown in quick succession until your eye reads them as motion. All of those drawings usually live in a single image file, arranged in a neat grid. That file is a **sprite sheet**.

Four things have to line up for that grid to become an animated character: the **sheet** (where the pictures are stored), the **cell** (which pixels belong to one drawing), the **clip** (which drawings play in what order), and the **timing** (when to switch from one drawing to the next). Most sprite-sheet confusion comes from mixing these up, so here is the whole chain first, then each link.

| Piece | The question it answers |
|---|---|
| Sprite sheet | Where do all the pictures live? |
| Cell / source rectangle | Which pixels of the image are frame 8? |
| Clip | Which frames make up "walk", and in what order? |
| Timing | How long does each frame stay on screen? |

## One warning about the word "frame"

In [the game-loop article](https://eulore.ai/articles/game-loop-57422ff7), a frame was one pass through the loop: read input, update, draw. Here a frame means one still drawing of a character. These are unrelated clocks, and the gap between them is where animation bugs come from — a game running at 144 FPS does not play your walk cycle 144 times a second.

## What a sprite sheet actually is

A **sprite** is a small rectangular image drawn at a position in the world. A sprite sheet is one image file — an ordinary PNG, nothing special about the format — that contains many sprites, usually in a regular grid.

Say the sheet is 192×128 pixels and each cell is 32×32. That gives 6 columns and 4 rows: 24 cells in one file, enough for a walk cycle, an idle, a jump, and some leftovers. Nothing inside the PNG records that layout. The file is only pixels; the knowledge that cells are 32 wide and there are 6 per row lives in your project settings or in code. (Some art pipelines ship a separate data file, often JSON, listing each sprite's rectangle by name — that is the exception, not the rule.)

## The image is never actually cut

This is the mechanism people miss. When a game draws "frame 8" of a sprite sheet, it does not slice the file, save 24 images, or copy pixels around. The sheet sits in memory as one texture, and the draw call is told two things: which rectangle of that texture to read, and where to put it.

Engines expose this at different levels, but it is the same operation underneath. MonoGame asks you to pass a source rectangle to every sprite draw [3]. Unity's Sprite Editor "slice" step records a rectangle for each sprite in the texture, then draws those rectangles as individual sprites [2]. Godot does it through a frame index: put the sheet in a `Sprite2D`, set the horizontal and vertical frame counts, and `frame` selects a cell [1].

Once you know the cell size and the number of columns, the rectangle for any frame index is pure arithmetic. With cells $w \times h$ and $C$ columns:

$$\text{col} = i \bmod C \qquad \text{row} = \left\lfloor \frac{i}{C} \right\rfloor \qquad x = \text{col}\cdot w \qquad y = \text{row}\cdot h$$

For the 192×128 sheet with 32×32 cells and 6 columns, frame 8 gives $\text{col} = 8 \bmod 6 = 2$, $\text{row} = \lfloor 8/6 \rfloor = 1$, so the rectangle starts at $x = 64$, $y = 32$ and covers pixels 64–95 across and 32–63 down. Frame 7 is the last one in the first row; frame 8 begins a new row at the same left edge.

One caveat on that formula: it counts rows from the top of the image. Most 2D engines number cells left to right, top to bottom, but rectangle coordinates themselves may be measured from the bottom-left corner (Unity's sprite Y values are), so check which origin your API uses before writing the math by hand. Sheets also sometimes have padding between cells, which the engine's slicing settings exist to describe [2].

## A clip gives the cells meaning

Cells by themselves are just pictures. A **clip** — Godot calls it an animation inside a `SpriteFrames` resource — is a named list of cells plus playback rules: `walk` = frames 0–5, `jump` = 6–9, `idle` = 12–13, and whether the clip loops or holds its last frame [4].

That list is what your game logic switches between. When the player presses right, you tell the sprite "play walk"; when they stop, "play idle". Which cells form which clip is your choice when slicing — the grid gives you 24 cells, but nothing in the image says the first six are a walk cycle.

## The timing: animation speed is not game speed

Here is the bug almost everyone writes first. You draw the current cell, then advance the index once per game frame:

```
cell_index += 1
```

That is the pixel-per-frame mistake from the game-loop article wearing different clothes. At 60 FPS, a 6-frame walk cycle finishes in a tenth of a second and repeats — a frantic blur. At 30 FPS the same code plays it at half the speed. Animation speed is tied to hardware again.

The fix is the same idea: measure time in seconds, not loop iterations.

```python
cell_index = 0
cell_timer = 0.0
anim_fps  = 10                 # sprite frames per second
clip      = [0, 1, 2, 3, 4, 5] # cells of the sheet, in order

def update(delta):
    cell_timer += delta
    step = 1.0 / anim_fps
    while cell_timer >= step:
        cell_timer -= step
        cell_index = (cell_index + 1) % len(clip)
    draw(sheet, cell_rect(clip[cell_index]))
```

Three details matter. `anim_fps` belongs to the artwork, not the display: 10 sprite frames per second means each drawing stays up for 0.1 seconds no matter how fast the loop runs — on a 60 FPS game, that is six loop frames per drawing. The `% len(clip)` wraps the index back to the start, which is what makes the clip loop. And the timer subtracts one step instead of resetting to zero, so leftover time carries into the next go; without that, a clip would drift slightly faster or slower than intended.

The `while` rather than `if` covers the rarer case where one long frame — a level load, a hitch — spans two or more sprite frames, so the animation catches up instead of falling behind.

## Making one, converting one, cutting one back up

To make a sprite sheet, draw each pose inside the same grid — a 32×32 grid means every pose is drawn in a 32×32 square with the character consistently placed — then export the whole grid as one PNG. Aseprite or Photoshop can show the grid; free web tools will pack frames for you.

Frames also arrive from other places. If you have an animated GIF, a **gif to sprite sheet** converter lays its frames into rows a game engine can read. If you only have a sheet and need individual files, a **sprite sheet cutter** splits the grid back into separate images. And if the engine can slice on import — Unity's Sprite Editor offers grid-by-cell-size and grid-by-cell-count slicing with offset, padding and pivot settings [2] — you can skip splitting entirely and keep one file.

## Why pack them into one file at all?

Convenience is only half the reason. Every time a renderer draws with a different texture than the previous draw, it pays a cost to swap textures; enough swaps per frame and the CPU becomes the bottleneck [3]. Sprites sharing one texture can be submitted together in a single batch. So the same file does two jobs: it stores an animation's frames, and it doubles as a **texture atlas** — one image holding many graphics so they can be drawn efficiently. The two names describe nearly the same object with different intent: "sprite sheet" is what animators say about a character's frames, "atlas" is what renderers say about any packed image.

## What usually goes wrong

- **The grid does not divide evenly.** 192 pixels wide with 32-pixel cells is exactly 6 columns. Off by one pixel and each frame drifts slightly relative to the last, so the character seems to wobble as the clip loops.
- **Frames were trimmed to their visible content.** Some exporters crop away transparent margins per frame; the drawings are then different sizes and the character jumps between positions. Keep a fixed cell size with transparent padding inside it.
- **The pivot is inconsistent.** Placement and rotation reference a pivot point; if one frame's pivot is at the feet and another's at the centre, the sprite shudders when it turns.
- **The row order is assumed.** Index-to-rectangle math assumes a specific scan order. A sheet exported column by column will look scrambled under the formula above.
- **Animation FPS was confused with game FPS.** The most common cause of "my animation is too fast".

## What to hand an AI coding tool

The sheet is data, so an AI tool cannot guess your layout. Give it the numbers: the image file, the cell size in pixels, the number of columns, which cells form each clip, each clip's playback speed, and whether it loops. Something like: "`hero.png`, 32×32 cells, 6 columns. `walk` = cells 0–5 at 10 FPS looping, `idle` = cells 12–13 at 6 FPS looping. Advance with delta time." That sentence plus the file is enough for correct drawing code, and it removes the guesswork that produces jitter, drifting grids and animations that run at monitor speed.

From there, the cell is just a rectangle, the clip is just a list, and the timing is just delta time again — three small pieces that turn a static image into a character that walks.

## Mind map

```mermaid
flowchart LR
  S["Sprite sheet: one PNG, many cells"] --> C["Cell / source rectangle: which pixels"]
  C --> I["Frame index: cell number"]
  I --> CL["Clip: named frame list plus loop rule"]
  CL --> T["Timer: animation FPS driven by delta time"]
  T --> D["Draw one cell per time step"]
  D --> A["Animated character"]
  S --> B["One texture: fewer swaps, batched draws"]
  B --> P["Doubles as a texture atlas"]
```

## Glossary

- Sprite：a small rectangular image drawn at a position in the game world; it has no animation of its own, it is just one picture.
- Sprite sheet：many sprite images packed into one ordinary image file, usually in a grid, so a character's whole set of pictures is one file.
- Cell and source rectangle：one square of the grid, described as pixel coordinates; drawing samples that rectangle and the file itself is never sliced.
- Frame index：the cell's number in the sheet; with cell size and column count it determines the source rectangle.
- Clip：a named, ordered list of cells plus loop rules, which the engine plays as a switchable action such as walk or idle.
- Animation FPS：how many sprite pictures appear per second, a property of the artwork that is independent of the game's own frame rate.
- Texture atlas：an image packing many graphics together so drawing can share one texture; a sprite sheet usually serves this role too.

## Sources

1. [Godot: 2D sprite animation tutorial — individual images versus one sprite sheet, and slicing a sheet by horizontal and vertical frame counts](https://docs.godotengine.org/en/stable/tutorials/2d/2d_sprite_animation.html)
2. [Unity Manual: Sprite Editor slicing — grid by cell size or cell count, offset, padding, pivot and trim](https://docs.unity3d.com/6000.2/Documentation/Manual/sprite/sprite-editor/automatic-slicing.html)
3. [MonoGame: Optimizing texture rendering — texture atlases, source rectangles and texture swaps](https://docs.monogame.net/articles/tutorials/building_2d_games/07_optimizing_texture_rendering/index.html)
4. [Godot: AnimatedSprite2D class reference — SpriteFrames, frame index, frame progress and speed scale](https://docs.godotengine.org/en/stable/classes/class_animatedsprite2d.html)

---

Original article: https://eulore.ai/articles/sprite-sheet-e157bf9f

> **Eulore** · Start small. Go deep.
>
> Eulore is an AI learning tool built around connected articles, each a 5–10 minute read. Ask questions as you go and help shape what comes next. That’s how this article was created.
>
> Start your own series → https://eulore.ai
