Random floor tiles, why not?

Wednesday afternoon …

After watching some inauguration, I thought I’d play with the dungeon a bit more. Since the floor looks pretty good, I decided to add in all the tiles and randomize them. Here’s how that looks:


The code is pretty simple, probably needs some tuning. I’m just playing here.

local FloorSprites = {
AdjustedSprite(asset.documents.Dropbox.floor_1, p250),
AdjustedSprite(asset.documents.Dropbox.floor_2, p250),
AdjustedSprite(asset.documents.Dropbox.floor_3, p250),
AdjustedSprite(asset.documents.Dropbox.floor_4, p250),
AdjustedSprite(asset.documents.Dropbox.floor_5, p250),
AdjustedSprite(asset.documents.Dropbox.floor_6, p250),
AdjustedSprite(asset.documents.Dropbox.floor_7, p250),
AdjustedSprite(asset.documents.Dropbox.floor_8, p250),
AdjustedSprite(asset.documents.Dropbox.floor_9, p250)}

A table of 9 tiles, with:

function Tile:getSprites(pos, tiny)
    if not self.tile then
        if self:isRoom() then
            self.tile = FloorSprites[math.random(1,9)]
            self.tile = TileSprites[self.kind]
    local result = {self.tile}
    if not tiny and self:isWall() and pos.x%3 == pos.y%3 then
    return result

A quick mod to getSprites to check if there’s a cached tile and init one if not. If it’s a room tile, select a random one, otherwise just select the one in the main tile table.

That’s all there is to it. This code may want some improvement. But not for now.

Commit: Random floor tiles.

And Thursday

I’m pleased enough with the new tiles to want to do more with them. This isn’t exactly advancing game play, but the value of a good look and feel is important to my product owner, i.e. me. Here are some of the things we can do with better tiles:


3/4 View
The odd look above is often used in top-down games like ours. The trick appears to be to paint wall-like things below the boundary walls, on north walls. The tile sets I’ve acquired do include some tiles suitable for this look. I think it will be “interesting” to figure out how to get the program to make decisions about this view.
There are trap tiles. The set I plan to use today includes a pair of tiles representing an unsprung trap, and a sprung one, containing a bunch of upward pointing spikes. There is also a “button” tile, a piece of flooring that could be pressure-sensitive. We could use that to release a flood of monsters.
There are other possibly useful objects, barrels, vases, boxes, and stairs. There are several kinds of doors. These, too, offer a tricky issue for us, because my dungeon creator doesn’t really know where the doorways are, it just carves flooring in a fashion that always creates a somewhat reasonable dungeon.
A big issue before us is how to make rooms “interesting”. Right now, I just randomly sprinkle chests and monsters around. That is of limited interest, one might say. I was scanning an article last night where the dungeon creator had small layouts, 2d arrays of a few tiles in each direction, with indications of what was in the tiles. There could be walls, random items, specific items, etc.
To make a room, the game could randomly select a layout, fit it into the room, and randomly populate the layout with whatever the tile “macros” indicated. If and when we do this, I’ll try to find a link to the article. It might still be on my other iPad.

These ideas are enough to induce me to put in a full tile set, and I’ve chosen one that I think will do the job. It isn’t the one used over the past couple of days. It’s a bit darker in color and I was concerned that it might not show up well enough, but I tried it on the other iPad and I think it’ll do.

There will now be a substantial delay while I do the tedious job of moving the tiles into Codea. I may have to rename them, as the author has given them names like “Tile (31)”, which may not go down well with Codea’s assets. I’ll try one at first.

0900 begin 0911 end

one new tile

There’s my one new floor tile. The name is unfortunate:

AdjustedSprite(asset.documents.Dropbox["Tile (17).png"], p256)

I guess they’re knowable and computable, but Codea won’t even show them in its prompts, though it will find them in the viewer search. There are about 80 tiles in need of renaming, to something like “Tile_17”. Easily done on the Mac, less so on the iPad. There do seem to exist apps that can do the job. I’ll try FileBrowser by Stratospherix.


I’ve #@$@ed around with FileBrowser for too long. I could have renamed the files manually by now, or decided to live with the impossible names. Hell, I could have moved them to the Mac and back.

At this moment, I can’t make FB do much of anything. I’ve tweeted for aid. Probably I’m doing something dumb, it has good reviews.


What a gumption trap this has been. Yak shaving without a razor. I’ve moved copies of the files all around on the iPad, FB doesn’t seem to want to see them. Renaming really seems desirable, as some tiles are just plain flooring, others are special.


Did you know that the Mac has a very nice bulk rename, with replace logic? Me either. So I moved the files into Dropbox, renamed them whip whap on the Mac. I could have done that sooner.

Now for some more refined renaming, floor vs wall kind of thing.


Fantastic. An hour and 40 minutes but finally I have about 84 tiles whose names are at least somewhat mnemonic. They’re in Dropbox. I’ll copy them back to the Codea Dropbox.Assets folder and then into the app folder. This is a two-pass algorithm for some reason.

Now a quick selection of all the floor tiles and I learn something:


Some of the tiles are shaded at the top edge, and it appears that a couple have a rounded bit at the top, which I suspect is the bottom of a column. There are some “Face” tiles with columns. So for now, I need to allow only the tiles with no shadows, I think.

I’m left with only four unshaded tiles. The others can be useful but should be placed on the left or top of a room only.

local FloorSprites = {
--AdjustedSprite(asset.documents.Dropbox.Floor_13, p256),
--AdjustedSprite(asset.documents.Dropbox.Floor_14, p256),
--AdjustedSprite(asset.documents.Dropbox.Floor_15, p256),
--AdjustedSprite(asset.documents.Dropbox.Floor_16, p256),
AdjustedSprite(asset.documents.Dropbox.Floor_17, p256),
--AdjustedSprite(asset.documents.Dropbox.Floor_18, p256),
--AdjustedSprite(asset.documents.Dropbox.Floor_19, p256),
--AdjustedSprite(asset.documents.Dropbox.Floor_20, p256),
AdjustedSprite(asset.documents.Dropbox.Floor_21, p256),
AdjustedSprite(asset.documents.Dropbox.Floor_22, p256),
AdjustedSprite(asset.documents.Dropbox.Floor_23, p256)

The random selection gives me a lot more drain tiles than I’d like. We’ll want to improve that. First, let’s put in a wall tile from the same tile set.


That tile is “Wall_57” for what it’s worth. It’ll do for now. Let’s commit: New floor and wall tiles.

This has been capital T Tedious, but now I’ve got a set of tiles that I can live with and that will challenge me.

Other than learning how to rename things on the Mac, and learning not to get the FB program, I’ve not learned much. But it’s only about 1245, so I can still learn something later in the day.

See you next time?