Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+2)

Lil allows line-breaks pretty much anywhere, except inside comments (the comment always ends at the end of the line). Here’s your example, broken over lines:

list(
 list(1,1,1,1,1,1,1,1),
 list(1,0,0,0,0,0,0,1),
 list(1,0,0,0,0,0,0,1),
 list(1,0,0,0,0,0,0,1),
 list(1,0,0,0,0,0,0,1),
 list(1,0,0,0,0,0,0,1),
 list(1,1,1,1,1,1,1,1)
)

It doesn’t quite do what you want, though. Instead of making an eight-item list of eight-item lists, it makes a nine-element list where the first eight items are tile numbers, and the ninth item is a nine-element list where the first eight items are tile numbers, and the ninth item is a nine-element list…

You want something more like this:

(list 1,1,1,1,1,1,1,1),
(list 1,0,0,0,0,0,0,1),
(list 1,0,0,0,0,0,0,1),
(list 1,0,0,0,0,0,0,1),
(list 1,0,0,0,0,0,0,1),
(list 1,0,0,0,0,0,0,1),
 list 1,1,1,1,1,1,1,1

Because Lil expressions are evaluated from right to left, this starts by stringing some 1s together to make an eight-element list representing the bottom row, then makes a one-element list wrapping the bottom-row list, then joins that wrapper with the one wrapping the second-bottom row, etc.

That will definitely work, but another thing you might consider is representing the tile map with an image. It is also a rectangular array of numbers, but stored more efficiently. It can also be easier to edit - .paste[] the image onto the background of a card, and you can use Decker’s built-in editing tools to draw the level, then .copy[] it back. Or better yet, if you have a card to store each level’s data, put the tilemap on the background image, and add a “Show: None” field named bounds to mark the bounds of the tilemap within the card. If the card representing the level you want to load is called level, you can get the tilemap with level.image.copy[level.widgets.bounds.pos level.widgets.bounds.size].

(1 edit)

That's cool but the colored pixels gives me limited textures to work with for the ray cast. But, thank you for showing me how the arrays work.

(+2)

Decker will let you paint with 48 different patterns, so that’s 48 different tiles you could put in your tilemap. You can actually store any number from 0-255 in an image pixel, which is a lot more possible tiles, though you can’t easily view or edit such an image so admittedly that’s less useful.

So... Let me get this straight, I could compress each tile in the map to a pixel and write a program that could read each one and and draw the map itself? The idea is appealing, and, maybe, I can double the number of possible tiles by having the program read the pixels two at a time, or sixteen times with four pixels. If that is possible.

The thing Is that I don't know how to write a program that could read the pixels and turn that into a full map.  Maybe with an if-statement and some stored textures... I still don't know, yet.