A sprite is represented as a string of characters, with each line corresponding to a row of pixels. Here’s an example of a sprite:

sprite: `
...00...
...00...
.000000.
0.0000.0
0.0000.0
..0000..
..0..0..
..0..0..
`,

Each digit is interpreted as a color (0: black, 1: white…), while spaces, tabs, and empty lines are ignored. Other characters represent transparent pixels.

In the example, the character . is used to mark empty spaces, but it could just as well be an underscore _.

Warning

In JavaScript, to create a multi-line string, we use the backtick character: `

  • On Windows: AltGr + 7 then Space
  • On Mac: £ then Space

Try to design a sprite for the player.

Tip

If need be, you can draw inspiration from this collection of sprites

Loading editor...

createGame({
  player: {
      sprite: 5,
      position: [4, 4]
  },
})