How 2D parallax scrolling works, with endless layers
A parallax background is a stack of flat pictures that each follow part of the camera's movement. The one formula, scroll speeds for 15 layers, endless layers by repeating or recycling chunks, zoom parallax, Godot's built-in Parallax2D and tested code.
Paste it into Claude Code, Codex, Grok Build or any coding agent.
Copied. Want one of these every week?
The week's game techniques in one free email on Sunday, each with a prompt like this one.
# Add parallax scrolling to my game
My side-scroller's background has no sense of depth and runs out at the edges of the level. Add parallax scrolling: every layer follows its own share of the camera's movement and keeps covering the screen however far the camera goes.
Before you write code, look at my project: the engine and language, how and when the camera moves (and zooms), my background art (layers, sizes, whether they tile), and any parallax node the engine already has. Fit this into what is there instead of adding a second system. Keep my camera, my art and my draw order. If I only have one flattened background image, or no art for a layer, ask me before inventing layers.
## How it works
- Each layer has a scroll speed, the share of the camera's horizontal movement it follows on screen: 0 is glued to the screen, 1 moves with the world, above 1 is foreground.
- Each frame, after the camera has moved: `layer.x = camera_left * (1 - scroll)`, with the camera's left edge in world pixels. Vertical works the same way with its own scroll speed (often 1, or small for a sky).
- Endless layers, option A (repeat): the layer is a strip that tiles left to right, and the engine wraps it. Use the engine's built-in parallax when it has one (Godot `Parallax2D` with `repeat_size`, Phaser `setScrollFactor`).
- Endless layers, option B (recycle chunks): cut the layer into fixed-width chunks, keep only those from 2 before the view to 2 after it, free the ones that leave that range and spawn the ones that enter it. Use this for layers made of separate pieces (trees, rocks, clouds), long levels, or random content. For pieces, let a chunk index pick a piece or nothing (an empty chunk gets no sprite) instead of a slice of one strip.
- Zoom parallax (only if my camera zooms): a layer with scroll `s` grows by `1 + (zoom - 1) * s` on screen, so far layers barely grow and the foreground grows more than the world. Scale each layer by that over the camera zoom, around the screen center. Godot's `Parallax2D` grows every layer by the full zoom, so it needs this added.
- Foreground pieces (scroll above 1) should be things whose base you never see, like leaves hanging from the top or trunks running off both edges. A side-view ground (grass on top, dirt below) has nothing in front of the path for plants to stand on.
## Numbers that matter
- Example scroll speeds, back to front, from the tested scene: sky 0.03, far peaks 0.08, nearer ranges and clouds 0.10 to 0.27, hills 0.38, trees behind the player 0.6, ground 1.0, hanging canopy 1.3, trunks in front 1.6. Keep any speeds my project already has.
- A 100 px camera move slides a layer by scroll x 100 px on screen (0.27 gives 27 px, 1.45 gives 145 px).
- Chunks: 64 px wide, 2 spare on each side. For a 320 px wide view that is always exactly 10 chunks (5 fill the view, 1 for the chunk cut by the edge, 2 spare on each side). Scale the chunk width with my art and view size; the chunk width must divide the strip's width.
- Zoom 1.75x: scroll 0, 0.08, 0.27, 0.6, 1 and 1.45 grow 1.00, 1.06, 1.20, 1.45, 1.75 and 2.09x on screen.
- Recycling grows with scroll speed. Over the test run below, counted after the first 10 chunks fill the view, a layer at 0 spawns none, at 1 it spawns 124 and at 1.45 it spawns 180. 1.45 is a test value; any foreground speed works.
## Pseudo code
```
# per layer: texture (tiles left to right), scroll, chunk_width, ahead = 2
# chunks: map from chunk index to a drawn piece
function update_layer(layer, camera): # call AFTER the camera moved this frame
view_w = camera.view_width_in_world_px
cam_left = camera.center_x - view_w / 2
layer_left = cam_left * layer.scroll # layer pixel at the view's left edge
layer.x = cam_left - layer_left # = cam_left * (1 - scroll)
# with zoom: grow = 1 + (zoom - 1) * scroll, scale the layer by grow / zoom about
# the screen center, and use view_w / grow as the visible width in layer pixels
first = floor(layer_left / layer.chunk_width) - layer.ahead
last = floor((layer_left + view_w) / layer.chunk_width) + layer.ahead
for k in layer.chunks.keys():
if k < first or k > last:
free(layer.chunks[k])
remove k from layer.chunks
for k in first .. last:
if k not in layer.chunks:
u = (k * layer.chunk_width) mod layer.texture.width # always 0 or more
piece = new sprite showing texture region (u, 0, chunk_width, texture.height)
piece.local_x = k * layer.chunk_width
add piece as a child of layer
layer.chunks[k] = piece
# repeat version (no chunks): set layer.x as above and let the engine tile
# the strip, drawing enough copies to cover view_w plus a spare on each side
```
Godot: `Parallax2D` (`scroll_scale`, `repeat_size`, `repeat_times = 3`) or the chunks above with `Sprite2D.region_rect`. Unity: run the formula in `LateUpdate` on each layer. Custom engine: after the camera update, before drawing.
## Pitfalls
- Updating layers before the camera moves makes the background lag a frame and shiver. Update after the camera.
- Slow layers jitter in pixel art: a layer at 0.08 moves a whole pixel only every few frames while the ground glides. Draw at screen resolution with the art scaled up by a whole number (Godot: stretch mode `canvas_items`, integer scaling) so layers can sit between art pixels, or move everything in screen pixels.
- A layer above 1 moves faster than the camera, so it needs more spare copies or chunks than the ground. Raise them until no edge shows.
- Mirrored strips (picture plus flipped copy) show the same peak twice in a wide view.
## Check that it works
Write a small automated test if you can, otherwise a debug view that outlines each chunk.
- Move the camera 100 px to the right: layers with scroll 0, 0.08, 0.27, 0.6, 1 and 1.45 slide left on screen by 0, 8, 27, 60, 100 and 145 px (within 0.001 px).
- If the engine has a built-in parallax node, it and the chunk version put the art in the same place (within 0.01 px, modulo the strip width).
- Move the camera's center from 0 to 3,997 px and back in 7 px steps (1,144 steps): with 64 px chunks and a 320 px view, every layer always has exactly 10 chunks, no gaps, and at least 2 chunks (128 px) past both edges of the view.
- If the camera zooms: at 1.75x the growth numbers above hold, the layer pixel under the screen center stays put, and the chunks still cover the view.
- Every chunk spawned on the way out is freed on the way back. Counted after the first fill, scroll 0, 1 and 1.45 spawn 0, 124 and 180.
- Set every scroll speed to 1 and the layers move like ordinary world sprites, which is the look without parallax.
Then tell me each layer's scroll speed and where I can tweak it.
## Art it needs
Separate layers that tile left to right (sky, far ranges, hills or trees, ground, optional foreground). A strip next to its mirror image tiles, if the view is under about two strip widths.
If the SpriteCook MCP tools are available in this session, generate each layer separately in one style (for example 384 x 216), full color, no haze, transparent above the art; for the foreground, leaves hanging from the top edge and single trunks running edge to edge.
Source: SpriteCook (2D game assets made by your coding agent, for Claude, ChatGPT and Cursor)
Full guide with pictures, video and tested Godot code: https://www.spritecook.ai/blog/2d-parallax-scrolling-infinite-backgroundA parallax background looks deep, but in the engine it's a stack of flat pictures. Each one slides along with a share of the camera's movement. The far mountains follow a little of it, the ground all of it, and the leaves in front more than all of it. To make a level that never runs out of background, you either repeat each picture or keep a few pieces alive around the camera and recycle them as it moves.
Left is the scene pulled apart in a 3D view. Every layer is a flat card, the purple box is what the game camera sees, and the orange frames are pieces of the ground and the trunks being spawned ahead and freed behind. Right is what the player sees, including two zooms where each layer grows by its own amount. The art is made with SpriteCook.
One number per layer
Give every layer a scroll speed, the share of the camera's movement it follows on screen. A camera move of 100 px slides a layer with scroll speed 0.27 by 27 px on screen. At 0 a layer is glued to the screen, at 1 it moves with the world, and above 1 it rushes past like something right in front of the lens.
In code that's one line per layer, with the camera's left edge in world pixels:
layer.x = camera_left * (1 - scroll)
These are the speeds in the clip, back to front:
| Layer | Scroll speed |
|---|---|
| Sky | 0.03 |
| High clouds | 0.05 |
| Far snowy peaks | 0.08 |
| Thin clouds | 0.10 |
| Clouds among the peaks | 0.11 |
| Jagged range | 0.13 |
| Lower range | 0.19 |
| Low clouds | 0.21 |
| Cloud bank | 0.23 |
| Forested ridge | 0.27 |
| Hills | 0.38 |
| Trees behind the player | 0.6 |
| Ground the player runs on | 1.0 |
| Hanging canopy | 1.3 |
| Tree trunks in front | 1.6 |
The far layers bunch up near 0 and the gaps grow toward the front. Real depth works the same way. Something twice as far away moves half as much, so most of the speed range belongs to the few things close to you.
Foreground layers go above 1
A layer in front of the player moves faster than the ground. Here the canopy runs at 1.3 and the trunks at 1.6, so they whip past and sell the speed of the run.
What goes in front matters more than the number. With a side-view ground like this one (grass on top, a cut of dirt below), there's no ground in front of the path for anything to stand on. Bushes rooted at the bottom of the screen look like they float in front of the dirt. Pick foreground pieces whose base you never see, like leaves hanging in from the top and trunks that run off both the top and the bottom.
Repeat or recycle for endless layers
A layer has to cover the screen wherever the camera goes, and there are two ways to make sure it does.
Repeat the picture. Make each layer a strip that tiles left to right and let the engine wrap it. Godot's Parallax2D does this with repeat_size, and it's the right call for skies, mountains and other strips.
Recycle chunks. Cut the layer into chunks and keep only the ones near the camera. When a chunk falls far enough behind, free it; when the camera nears the edge, spawn the next one. That's what the orange frames in the clip are. It's the way to go when a layer is made of separate pieces (trees, rocks, clouds placed one by one), when the level is long, or when what comes next is random. For pieces, a chunk index picks a piece or nothing instead of a slice of one strip; the trunks in the clip are one trunk per chunk, with empty chunks in between that get no sprite at all.
Keep a couple of spare chunks past each edge so a piece never pops in where the player can see it. With 64 px chunks and a 320 px wide view, the layer below always has exactly 10 chunks. That's the 5 that fill the view, 1 more for the chunk cut by the edge, and 2 spare on each side. A layer only recycles as fast as it scrolls. Over the same camera run, the sky (scroll 0) never spawns a chunk, the ground (1) spawns 124 and a foreground layer at 1.45 spawns 180.
Zoom parallax
Zoom the camera and every layer usually grows by the same amount, which flattens the whole background into one picture. With real depth, the closer something is, the more it grows. Walk toward a window and the tree outside grows a lot while the mountains behind it barely change.
Give each layer its own zoom instead. A layer with scroll speed s grows by 1 + (zoom - 1) * s on screen. At a 1.75x zoom the far peaks (0.08) grow 1.06x, the trees behind the player (0.6) 1.45x, the ground 1.75x and a foreground layer at 1.45 grows 2.09x. Scale each layer by that number divided by the camera zoom, around the middle of the screen, and the camera does the rest.
Godot's Parallax2D doesn't do this. Under a 1.75x camera zoom it grows every layer 1.75x, so the chunk layer below has zoom_parallax for it. Use it for zoom punches on a hit or a landing, or a slow zoom into a cutscene. To zoom toward a point that isn't the middle of the screen, like the hero, move the camera toward that point as you zoom.
The code
Two files for Godot 4.6:
chunked_parallax_layer.gdis one layer built from chunks, the recycling version from the clip. Give it a strip texture that tiles left to right, a scroll speed and the camera.builtin_parallax.gdsets up the same layer with Godot's ownParallax2D, for when repeating is all you need and the camera doesn't zoom.
The chunk layer:
# One parallax layer built from chunks, the way the 3D view in the post shows it.
# scroll: how much of the camera's movement the layer follows on screen.
# 0 = glued to the screen (a far sky), 1 = moves with the world, above 1 = foreground.
# Only the chunks around the camera exist: `ahead` extra chunks on each side are spawned
# before they scroll into view and freed once they are that far behind.
# zoom_parallax: when the camera zooms, the layer grows by 1 + (zoom - 1) * scroll on screen,
# so far layers barely grow and foreground layers grow more than the world.
extends Node2D
@export var texture: Texture2D # a strip that tiles seamlessly left to right
@export var scroll := 0.5
@export var chunk_width := 64 # px, must divide the texture width
@export var ahead := 2 # spare chunks on each side of the view
@export var camera: Camera2D
@export var zoom_parallax := true
var chunks := {} # chunk index -> Sprite2D
var spawned := 0
var freed := 0
func _ready() -> void:
assert(texture.get_width() % chunk_width == 0, "chunk_width must divide the texture width")
func _process(_delta: float) -> void:
update_layer()
func update_layer() -> void:
var screen_w := get_viewport_rect().size.x
var zoom := camera.zoom.x
var grow := 1.0 + (zoom - 1.0) * scroll if zoom_parallax else zoom # on-screen magnification
var center := camera.get_screen_center_position()
# the layer pixel under the middle of the screen; with no zoom the layer's left edge sits at
# cam_left * scroll, so the layer slides `scroll` of the way with the camera
var mid := center.x * scroll + screen_w / 2.0 * (1.0 - scroll)
var ks := grow / zoom # the camera zoom does the rest
scale = Vector2(ks, ks)
position = Vector2(center.x - mid * ks, center.y * (1.0 - ks)) # scale about the screen center
var half := screen_w / 2.0 / grow # half the screen, in this layer's own pixels
var first := floori((mid - half) / chunk_width) - ahead
var last := floori((mid + half) / chunk_width) + ahead
for k in chunks.keys(): # free what fell behind
if k < first or k > last:
chunks[k].queue_free()
chunks.erase(k)
freed += 1
for k in range(first, last + 1): # spawn what is coming up
if not chunks.has(k):
chunks[k] = _make_chunk(k)
spawned += 1
func _make_chunk(k: int) -> Sprite2D:
var s := Sprite2D.new()
s.texture = texture
s.centered = false
s.region_enabled = true
var u := posmod(k * chunk_width, texture.get_width()) # the strip repeats
s.region_rect = Rect2(u, 0, chunk_width, texture.get_height())
s.position = Vector2(k * chunk_width, 0)
add_child(s)
return s
The built-in version:
# The same layer with Godot's built-in Parallax2D (Godot 4.3 and newer). No chunk code:
# repeat_size makes the texture wrap and repeat_times draws extra copies so the view never runs dry.
extends Node2D
func add_layer(texture: Texture2D, scroll: float) -> Parallax2D:
var layer := Parallax2D.new()
layer.scroll_scale = Vector2(scroll, 1.0) # x follows `scroll` of the camera, y follows fully
layer.repeat_size = Vector2(texture.get_width(), 0)
layer.repeat_times = 3 # copies on each side, raise it if gaps show
var sprite := Sprite2D.new()
sprite.texture = texture
sprite.centered = false
layer.add_child(sprite)
add_child(layer)
return layer
Tested in Godot 4.6, with a 320 x 180 view:
- A 100 px camera move to the right slides layers with scroll speed 0, 0.08, 0.27, 0.6, 1 and 1.45 left by 0, 8, 27, 60, 100 and 145 px on screen.
- The built-in
Parallax2Dand the chunk layer put the art in the same place, within 0.0001 px, at five camera positions. - Moving the camera's center from 0 to 3,997 px and back in 7 px steps (1,144 steps), the chunk layer always has exactly 10 chunks of 64 px, no gaps, and always reaches at least 2 chunks past both edges of the view.
- At a 1.75x camera zoom with
zoom_parallaxon, layers with scroll speed 0, 0.08, 0.27, 0.6, 1 and 1.45 grow 1.00, 1.06, 1.20, 1.45, 1.75 and 2.09x on screen. The layer pixel under the middle of the screen stays there, and the chunks still cover the whole view. - With
zoom_parallaxoff, and in the built-inParallax2D, every layer grows 1.75x. - Every chunk spawned on the way out is freed again on the way back. Counted from the start of the run (after the first 10 fill the view), scroll 0 never spawns one and scroll 0.08, 1 and 1.45 spawn 10, 124 and 180.
Other engines
These were not run, so treat them as pointers:
- Unity has no 2D parallax component. Put a script on each layer that sets
transform.position.x = cam.transform.position.x * (1 - scroll)inLateUpdate, so it runs after the camera moved. Another route is a perspective camera with the layers at real distances, which gives parallax for free, but pixel art then scales unevenly. - Phaser has it built in:
setScrollFactor(scroll)on a game object, or aTileSpritewithtilePositionX = camera.scrollX * scrollfor an endless strip. - GameMaker: tick Horizontal Tile on a background layer and set
layer_x(layer, camera_x * (1 - scroll))every step.
Common pitfalls
Updating layers before the camera moves. The layers then lag one frame behind and the whole background shivers. Update them after the camera, or let the engine's parallax node do it.
Slow layers jitter in pixel art. A layer at 0.08 moves a whole pixel only every few frames, so it steps unevenly while the ground glides. Draw at screen resolution with the art scaled up by a whole number (in Godot, stretch mode canvas_items with integer scaling) so layers can sit between art pixels, or move everything in screen pixels instead of art pixels.
Gaps at the edges. A foreground layer above 1 moves faster than the camera, so it needs more spare copies or chunks than the ground. Raise repeat_times or the spare chunk count until no edge shows.
Mirrored strips give themselves away. Mirroring a layer (the picture plus its flipped copy) is a quick way to make it tile, but in a wide view the same peak shows twice, mirrored. Make the strip wider than about two screens or draw it to tile for real.
Every layer equally bright and sharp. Parallax motion alone doesn't make the far mountains look far. Fade each layer toward the sky by how far back it sits, which is the next guide.
Where to next
- Atmospheric perspective for 2D parallax backgrounds, to make the far layers read as far away with one blend per pixel
- Eight 2D camera follow techniques, for the camera that drives every layer
- How to set up a pixel art game so it renders pixel perfect, for the scaling the jitter pitfall depends on
- 2D parallax in the Godot docs, every
Parallax2Dsetting explained - Parallax scrolling on Wikipedia, for its history in arcade and 16-bit games
Add this to your game with your coding agent
The prompt has the numbers, pseudo code, pitfalls and checks from this guide, written so your agent can fit it into your own project.
Copied. Want one of these every week?
The week's game techniques in one free email on Sunday, each with a prompt like this one.
# Add parallax scrolling to my game
My side-scroller's background has no sense of depth and runs out at the edges of the level. Add parallax scrolling: every layer follows its own share of the camera's movement and keeps covering the screen however far the camera goes.
Before you write code, look at my project: the engine and language, how and when the camera moves (and zooms), my background art (layers, sizes, whether they tile), and any parallax node the engine already has. Fit this into what is there instead of adding a second system. Keep my camera, my art and my draw order. If I only have one flattened background image, or no art for a layer, ask me before inventing layers.
## How it works
- Each layer has a scroll speed, the share of the camera's horizontal movement it follows on screen: 0 is glued to the screen, 1 moves with the world, above 1 is foreground.
- Each frame, after the camera has moved: `layer.x = camera_left * (1 - scroll)`, with the camera's left edge in world pixels. Vertical works the same way with its own scroll speed (often 1, or small for a sky).
- Endless layers, option A (repeat): the layer is a strip that tiles left to right, and the engine wraps it. Use the engine's built-in parallax when it has one (Godot `Parallax2D` with `repeat_size`, Phaser `setScrollFactor`).
- Endless layers, option B (recycle chunks): cut the layer into fixed-width chunks, keep only those from 2 before the view to 2 after it, free the ones that leave that range and spawn the ones that enter it. Use this for layers made of separate pieces (trees, rocks, clouds), long levels, or random content. For pieces, let a chunk index pick a piece or nothing (an empty chunk gets no sprite) instead of a slice of one strip.
- Zoom parallax (only if my camera zooms): a layer with scroll `s` grows by `1 + (zoom - 1) * s` on screen, so far layers barely grow and the foreground grows more than the world. Scale each layer by that over the camera zoom, around the screen center. Godot's `Parallax2D` grows every layer by the full zoom, so it needs this added.
- Foreground pieces (scroll above 1) should be things whose base you never see, like leaves hanging from the top or trunks running off both edges. A side-view ground (grass on top, dirt below) has nothing in front of the path for plants to stand on.
## Numbers that matter
- Example scroll speeds, back to front, from the tested scene: sky 0.03, far peaks 0.08, nearer ranges and clouds 0.10 to 0.27, hills 0.38, trees behind the player 0.6, ground 1.0, hanging canopy 1.3, trunks in front 1.6. Keep any speeds my project already has.
- A 100 px camera move slides a layer by scroll x 100 px on screen (0.27 gives 27 px, 1.45 gives 145 px).
- Chunks: 64 px wide, 2 spare on each side. For a 320 px wide view that is always exactly 10 chunks (5 fill the view, 1 for the chunk cut by the edge, 2 spare on each side). Scale the chunk width with my art and view size; the chunk width must divide the strip's width.
- Zoom 1.75x: scroll 0, 0.08, 0.27, 0.6, 1 and 1.45 grow 1.00, 1.06, 1.20, 1.45, 1.75 and 2.09x on screen.
- Recycling grows with scroll speed. Over the test run below, counted after the first 10 chunks fill the view, a layer at 0 spawns none, at 1 it spawns 124 and at 1.45 it spawns 180. 1.45 is a test value; any foreground speed works.
## Pseudo code
```
# per layer: texture (tiles left to right), scroll, chunk_width, ahead = 2
# chunks: map from chunk index to a drawn piece
function update_layer(layer, camera): # call AFTER the camera moved this frame
view_w = camera.view_width_in_world_px
cam_left = camera.center_x - view_w / 2
layer_left = cam_left * layer.scroll # layer pixel at the view's left edge
layer.x = cam_left - layer_left # = cam_left * (1 - scroll)
# with zoom: grow = 1 + (zoom - 1) * scroll, scale the layer by grow / zoom about
# the screen center, and use view_w / grow as the visible width in layer pixels
first = floor(layer_left / layer.chunk_width) - layer.ahead
last = floor((layer_left + view_w) / layer.chunk_width) + layer.ahead
for k in layer.chunks.keys():
if k < first or k > last:
free(layer.chunks[k])
remove k from layer.chunks
for k in first .. last:
if k not in layer.chunks:
u = (k * layer.chunk_width) mod layer.texture.width # always 0 or more
piece = new sprite showing texture region (u, 0, chunk_width, texture.height)
piece.local_x = k * layer.chunk_width
add piece as a child of layer
layer.chunks[k] = piece
# repeat version (no chunks): set layer.x as above and let the engine tile
# the strip, drawing enough copies to cover view_w plus a spare on each side
```
Godot: `Parallax2D` (`scroll_scale`, `repeat_size`, `repeat_times = 3`) or the chunks above with `Sprite2D.region_rect`. Unity: run the formula in `LateUpdate` on each layer. Custom engine: after the camera update, before drawing.
## Pitfalls
- Updating layers before the camera moves makes the background lag a frame and shiver. Update after the camera.
- Slow layers jitter in pixel art: a layer at 0.08 moves a whole pixel only every few frames while the ground glides. Draw at screen resolution with the art scaled up by a whole number (Godot: stretch mode `canvas_items`, integer scaling) so layers can sit between art pixels, or move everything in screen pixels.
- A layer above 1 moves faster than the camera, so it needs more spare copies or chunks than the ground. Raise them until no edge shows.
- Mirrored strips (picture plus flipped copy) show the same peak twice in a wide view.
## Check that it works
Write a small automated test if you can, otherwise a debug view that outlines each chunk.
- Move the camera 100 px to the right: layers with scroll 0, 0.08, 0.27, 0.6, 1 and 1.45 slide left on screen by 0, 8, 27, 60, 100 and 145 px (within 0.001 px).
- If the engine has a built-in parallax node, it and the chunk version put the art in the same place (within 0.01 px, modulo the strip width).
- Move the camera's center from 0 to 3,997 px and back in 7 px steps (1,144 steps): with 64 px chunks and a 320 px view, every layer always has exactly 10 chunks, no gaps, and at least 2 chunks (128 px) past both edges of the view.
- If the camera zooms: at 1.75x the growth numbers above hold, the layer pixel under the screen center stays put, and the chunks still cover the view.
- Every chunk spawned on the way out is freed on the way back. Counted after the first fill, scroll 0, 1 and 1.45 spawn 0, 124 and 180.
- Set every scroll speed to 1 and the layers move like ordinary world sprites, which is the look without parallax.
Then tell me each layer's scroll speed and where I can tweak it.
## Art it needs
Separate layers that tile left to right (sky, far ranges, hills or trees, ground, optional foreground). A strip next to its mirror image tiles, if the view is under about two strip widths.
If the SpriteCook MCP tools are available in this session, generate each layer separately in one style (for example 384 x 216), full color, no haze, transparent above the art; for the foreground, leaves hanging from the top edge and single trunks running edge to edge.
Source: SpriteCook (2D game assets made by your coding agent, for Claude, ChatGPT and Cursor)
Full guide with pictures, video and tested Godot code: https://www.spritecook.ai/blog/2d-parallax-scrolling-infinite-backgroundMore game techniques
All techniques
7 platformer tricks for slopes, one-way platforms, walls and crumbling blocksThe jump gets all the attention, but most platformer jank comes from what you stand on. Seven small tricks for crumbling blocks, falling blocks, one-way platforms, slopes, tight gaps, wall slides and climbing over ledges, with Celeste's numbers, tested Godot code and a prompt for each.
9 health bar tricks for a 2D game, from HP text to a bar that liesNine health bar tricks stacked on one fight, from plain HP text to a smooth drain, a damage trail, shake and flash, a heal trail, color by health, a low HP warning and a last sliver that lasts longer than it looks. With the timing numbers and tested Godot code.
