← ExekiteCONTENT HISTORY

Update to Exekite

Snapshot Nov 17, 2026 · 12:11 UTC · version 1.0.0

Collection source: downloaded plugin package.

WHAT CHANGED

First saved snapshot

No earlier snapshot is available to establish a change.

Save Exekite and check future changes in Following.

Up to 3 plugins free · no card required.

Compare saved observations

Download comparison JSON
Full technical diff · 0 changed fields
Full snapshot data
{
  "description": "For Exekite-hosted Godot games only. Godot 4 TileMapLayer + runtime-built TileSet craft. Use only when the level is an actual tile grid — painting cells in code, per-tile collision, terrains/autotiles, custom tile data, spawn-marker layers. Not needed for 3D levels or non-grid 2D scenes.",
  "included_files": [],
  "name": "tilemap",
  "skill_md_contents": "---\nname: tilemap\ndescription: \"For Exekite-hosted Godot games only. Godot 4 TileMapLayer + runtime-built TileSet craft. Use only when the level is an actual tile grid — painting cells in code, per-tile collision, terrains/autotiles, custom tile data, spawn-marker layers. Not needed for 3D levels or non-grid 2D scenes.\"\n---\n\n# TileMap / TileMapLayer\n\nGodot 4.3+ replaced the monolithic `TileMap` node with `TileMapLayer` — one node per layer, each layer painting a different facet (ground, decorations, hazards). The TileSet resource (shared across layers) holds the actual tile defs.\n\n## Layout\n\n```\nLevel (Node2D)\n├── Background (TileMapLayer)   # tile_set assigned in _ready() from _build_tileset()\n├── Ground (TileMapLayer)       # same TileSet instance — the layer with collision\n├── Decoration (TileMapLayer)   # same TileSet instance\n└── Hazards (TileMapLayer)      # its own TileSet (different tiles/physics)\n```\n\nEach `TileMapLayer` has its own `tile_map_data` (the painted layout) and shares the `tile_set` resource. Collision is per-layer-per-physics-layer; you typically enable collision on the Ground layer only.\n\n## Creating a TileSet\n\nA `TileSet` resource (`*.tres`) catalogs:\n- Source images (sprite atlases, scene tiles, terrains)\n- Per-tile metadata (collision shape, navigation, custom data)\n- Physics layers (which group of bodies tiles in this set collide with)\n- Terrain sets (auto-tile rules)\n\nThere is no editor and no source image — art here is generated in code. Build\nthe whole `TileSet` at runtime from a texture you draw yourself:\n\n```gdscript\nfunc _build_tileset(cell: int) -> TileSet:\n    # 1. Draw an atlas: one row of cells, each a flat colour. Anything you can\n    #    compute — noise, gradients, borders — works the same way.\n    var img := Image.create(cell * 3, cell, false, Image.FORMAT_RGBA8)\n    var colours := [Color(0.25, 0.5, 0.25), Color(0.4, 0.3, 0.2), Color(0.2, 0.2, 0.3)]\n    for i in colours.size():\n        img.fill_rect(Rect2i(i * cell, 0, cell, cell), colours[i])\n\n    var src := TileSetAtlasSource.new()\n    src.texture = ImageTexture.create_from_image(img)\n    src.texture_region_size = Vector2i(cell, cell)\n    for i in colours.size():\n        src.create_tile(Vector2i(i, 0))\n\n    var ts := TileSet.new()\n    ts.tile_size = Vector2i(cell, cell)\n    ts.add_source(src, 0)\n    return ts\n```\n\nGive solid tiles collision on the same source, in code:\n\n```gdscript\n    ts.add_physics_layer(0)\n    var data := src.get_tile_data(Vector2i(0, 0), 0)\n    var half := cell / 2.0\n    data.add_collision_polygon(0)\n    data.set_collision_polygon_points(0, 0, PackedVector2Array([\n        Vector2(-half, -half), Vector2(half, -half), Vector2(half, half), Vector2(-half, half),\n    ]))\n```\n\nBuild the TileSet once and assign the same instance to every layer in `_ready()` (cache it in a static var or pass it in) — layers share by reference.\n\n## Painting tiles\n\nProgrammatically:\n```gdscript\n@onready var ground: TileMapLayer = $Ground\n\nfunc _ready() -> void:\n    # Paint a 10x1 row of grass (atlas coords (0,0)) at world cells (0..9, 5):\n    for x in range(10):\n        ground.set_cell(Vector2i(x, 5), 0, Vector2i(0, 0))\n    # Erase a cell:\n    ground.set_cell(Vector2i(3, 5), -1)\n```\n\n`set_cell(coords, source_id, atlas_coords, alternative_tile_id)`. `source_id = -1` means \"erase\". `source_id` matches the source you added to the TileSet.\n\n## Collision\n\nThe Ground layer with a physics layer assigned will register collision shapes per painted tile. The collision shape is part of the tile's metadata in the TileSet — the `add_collision_polygon` code above.\n\nCharacterBody2D bodies with the right collision mask collide naturally — no extra setup beyond layer/mask matching.\n\n## Terrain (autotile / wang tiles)\n\nTerrain sets let you draw \"ground\" without picking individual corner/edge tiles — Godot picks the right tile based on neighbors.\n\nNo inspector here — build the terrain set in code on the same TileSet:\n\n```gdscript\nts.add_terrain_set()\nts.set_terrain_set_mode(0, TileSet.TERRAIN_MODE_MATCH_CORNERS_AND_SIDES)\nts.add_terrain(0)\nts.set_terrain_name(0, 0, \"Grass\")\n\n# Per tile: declare its terrain and which sides/corners match (\"grass\" bits).\nvar data := src.get_tile_data(Vector2i(0, 0), 0)\ndata.terrain_set = 0\ndata.terrain = 0\ndata.set_terrain_peering_bit(TileSet.CELL_NEIGHBOR_TOP_SIDE, 0)  # repeat per covered bit\n\n# Then paint by terrain instead of picking atlas coords per cell:\nground.set_cells_terrain_connect(cells, 0, 0)\n```\n\nGodot picks the matching tile based on the peering bitmask.\n\n## Custom data layers (per-tile metadata)\n\nA TileSet can declare custom data layers — typed metadata on each tile. Read at runtime:\n\n```gdscript\n# Declare the layer on the TileSet in code, then stamp values onto tiles:\nts.add_custom_data_layer()\nts.set_custom_data_layer_name(0, \"damage\")\nts.set_custom_data_layer_type(0, TYPE_INT)\nsrc.get_tile_data(Vector2i(2, 0), 0).set_custom_data(\"damage\", 10)\n\nfunc _on_player_entered_cell(coords: Vector2i) -> void:\n    var data := ground.get_cell_tile_data(coords)\n    if not data: return\n    var dmg := data.get_custom_data(\"damage\") as int\n    if dmg > 0:\n        player.take_damage(dmg)\n```\n\nUseful for \"this tile is a checkpoint\", \"this tile slows the player to 0.5×\", etc.\n\n## World-to-cell, cell-to-world\n\n```gdscript\nvar cell := ground.local_to_map(ground.to_local(player.global_position))\nvar world_pos := ground.to_global(ground.map_to_local(Vector2i(3, 5)))\n```\n\n`local_to_map` is the inverse of `map_to_local`. They use the layer's local coordinate system, not global.\n\n## Spawning entities from tilemap data\n\nA pattern: paint markers in a \"Spawns\" TileMapLayer; on level start, iterate the cells and instance entities at their positions, then clear the markers.\n\n```gdscript\n@onready var spawns: TileMapLayer = $Spawns\nconst COIN := preload(\"res://scenes/coin.tscn\")\nconst ENEMY := preload(\"res://scenes/enemy.tscn\")\n\nfunc _ready() -> void:\n    for cell in spawns.get_used_cells():\n        var atlas := spawns.get_cell_atlas_coords(cell)\n        var pos := spawns.to_global(spawns.map_to_local(cell))\n        if atlas == Vector2i(0, 0):\n            spawn(COIN, pos)\n        elif atlas == Vector2i(1, 0):\n            spawn(ENEMY, pos)\n    spawns.clear()\n\nfunc spawn(scene: PackedScene, pos: Vector2) -> void:\n    var inst := scene.instantiate()\n    inst.position = to_local(pos)  # this parent owns the instance's local transform\n    add_child(inst)\n```\n\n## Performance notes\n\n- `TileMapLayer` is fast — millions of cells render fine. Don't over-optimize.\n- Distinct TileMapLayers with the same TileSet share GPU resources; cheap to add.\n- For huge worlds, use chunking (multiple TileMapLayers, each covering one region; load/unload by player position).\n\n## Anti-patterns\n\n- One `TileMapLayer` painting both ground (with collision) and decoration (no collision). Split into two layers — collision is per-layer.\n- Painting collision shapes on every tile when only some are solid. Solid tiles get a shape; \"grass\" tiles get nothing.\n- Hardcoding tile coordinates (`set_cell(Vector2i(3, 5), 0, Vector2i(2, 1))`) instead of using terrains for terrain. Painting via terrain is faster and adapts to neighbor changes.\n- Querying `get_cell_tile_data` every frame for every player tile when a signal-on-enter would do.\n- Storing per-instance state on tiles (e.g. \"this coin tile is collected\"). Tiles are static; spawn entities for stateful things.\n"
}

SHA-256 of public snapshot: 6976fa25cf0ca9d0f35aa01ac40ac56bc271b8089bee38277309ea02c0bb961f