itch.io is community of indie game creators and players

Devlogs

Design: Level loading

Pico Lazy Farm
A downloadable game for Windows, macOS, and Linux

In this article I'd like to talk about how I stored the levels in Lazy Farm and Toy Box Pipe.

The map memory in PICO-8 is a matrix of 128 x 32 tiles or 128 x 64 tiles if you take half of the sprite memory. This is not a lot of space if we don't use it wisely.  For example, in the Jelpi demo there is a single short level and it already takes almost all the space available.

Lazy Farm is a sokoban-like game with single-screen puzzles. In PICO-8 the screen is 16x16 tiles so the map memory would be filled with 32 o 64 levels.

Most of the puzzles only use a small fraction of the screen and I had in mind to publish the game with more than 100 levels so using a slice of 16x16 for each of them would be a waste of memory.

At the end I decided to use a similar approach to the texture packing used in 3D games: I placed the level as tight as possible only storing the parts that are used in the gameplay.

Here you can see that a single screen can hold 4 packaged levels.

I created an array that holds the information for each level in the following format:

{
   name = "Level 1-1",
   -- Top left corner of the level
   x0 = 0,
   y0 = 16,
   -- Lower right corner
   x1 = 5,
   y1 = 20,
}

For convenience I left the top-left screen blank. When a level is loaded a fill this area with an empty brown tile and then I copy the tiles from level one by one in the center of the screen. This is so the level rendering function is just a call to "map()".

The actual code for Lazy Farm is bit more complicated because I have to check some special tiles that need to be converted into entities. You can take a look at the implementation by opening the cart in the PICO-8 editor or in the BBS.

Files

  • Game manual (PDF) 1 MB
    Dec 07, 2019
  • Lazy Farm (web version) 406 kB
    Dec 07, 2019
  • Lazy Farm for Windows 958 kB
    Dec 07, 2019
  • Lazy Farm for Linux 530 kB
    Dec 07, 2019
  • Lazy Farm for Mac 3.8 MB
    Dec 07, 2019
  • Lazy Farm for Raspberry Pi 745 kB
    Dec 07, 2019
  • Everything in a single zip file 7 MB
    Dec 07, 2019
Download Pico Lazy Farm
Leave a comment