Sprites
Like everything else in Odyc.js, sprites are defined directly in code.
They’re described using strings, a bit like ASCII art.
createGame({
player: {
sprite: `
...55...
...55...
.000000.
0.0000.0
5.0000.5
..3333..
..3..3..
..0..0..
`
}
//...
})
🟦 A Simple Colored Block
If you want an element to appear as a plain colored rectangle, just assign a number that corresponds to a palette color:
sprite: 5
Drawing Sprites
Sometimes it’s easier to draw than to explain. Use the editor below to try out how sprite definitions work. On one side, you can draw; on the other, you’ll see the code string that represents your sprite.
..4.4...
..4.4.4.
..4.4.4.
4.44444.
4443434.
.444444.
..43344.
..4444..
Each line represents a row of pixels, and each character is a pixel:
- Digit (0–9): corresponds to a specific palette color (e.g.
0
for black,1
for white, etc.) - Newline: starts a new row
- Spaces, tabs, blank lines: are ignored
- Other characters: represent transparent pixels (e.g.
.
)
Note
To make your code shorter, you can use \n
instead of line breaks:
'..4.4...\n..4.4.4.\n..4.4.4.\n4.44444.'
Sprite Inspiration
Here are two useful resources for generating or browsing sprite ideas:
- Pixeltwist – an infinite stream of random sprites.
- Baxel – a growing, open collection of community-created sprites.
Note
To import a sprite from one of these sites into your game, simply right-click → copy image, then paste it into the drawing tool in the playground.