0:01 / 0:30
Playback speed

Tileset

Choose one tile from the strip. When its turn comes, count how many places light up in the level.

#TilesAndWorldsSNES era#Tile

The collection of tiles a level is painted from.

Think of it as a paintbox. The whole level only ever uses the handful of tiles in the set, so memory stays small and the art stays consistent.

Code

src/demos/tileset.goose
namespace tileset_lesson;
import stage;
import std;
import math;

export "tileset" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
    let kind = (time / 1.3) as i64 % 4;
    artwork("valley");
    rect(0, 0, W, H, "rgba(26,43,55,0.43)");
    draw_map(cell_count(), kind);
    for i in cell_count() {
        if cell_kind(i) == kind {
            box(cell_x(i) * 8, MY + cell_y(i) * 8, 8, 8, MAG);
        }
    }
    rect(4, 4, 84, 24, INK);
    for i in 4 {
        tile_image(i, 8 + i * 20, 8, 2);
        if i == kind {
            box(7 + i * 20, 7, 18, 18, MAG);
        }
    }
}

Stage drawing helpers · All demos on GitHub

Comments

No comments yet.