From 86b7ce4b36532504d27980c7bfeaf6f3be5dfea0 Mon Sep 17 00:00:00 2001 From: Axel Meyer Date: Sat, 9 May 2026 20:09:28 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20P.0.lib.render=20integration=20?= =?UTF-8?q?=E2=80=94=20render=20hook=20+=20tile=20colors=20+=20lib-core.re?= =?UTF-8?q?nder=20dep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/tiles/demo_tilemap.tilemap.json | 4 ++-- init.lua | 16 +++++++++------- manifest.module | 5 ++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/assets/tiles/demo_tilemap.tilemap.json b/assets/tiles/demo_tilemap.tilemap.json index bd6c2ca..a5381d2 100644 --- a/assets/tiles/demo_tilemap.tilemap.json +++ b/assets/tiles/demo_tilemap.tilemap.json @@ -2,7 +2,7 @@ "id": "demo_tilemap", "tile_size": 32, "tiles": [ - {"id": "grass", "walkable": true}, - {"id": "stone", "walkable": false} + {"id": "grass", "walkable": true, "color": [110, 170, 80]}, + {"id": "stone", "walkable": false, "color": [120, 120, 120]} ] } diff --git a/init.lua b/init.lua index 403fe31..7c3e898 100644 --- a/init.lua +++ b/init.lua @@ -1,14 +1,13 @@ -local maps = require("lib-core.maps") +local maps = require("lib-core.maps") +local r_lib = require("lib-core.render") --- inline stubs (extract in P.0.lib.{render,camera,input,player_control,actor,interaction}) -local render = { hello = function() return "render stub" end } +-- inline stubs (extract in P.0.lib.{camera,input,player_control,actor,interaction}) local camera = { hello = function() return "camera stub" end } local input = { hello = function() return "input stub" end } local player_control = { hello = function() return "player_control stub" end } local actor = { hello = function() return "actor stub" end } local interaction = { hello = function() return "interaction stub" end } --- Load + activate the demo map (P.0.lib.maps slice) local demo_map = maps.load("maps/demo.map.json") maps.set_current(demo_map) @@ -18,22 +17,25 @@ local TARGET_FRAMES = 60 function init(ctx) engine.print("spine-prototype init: maps loaded") engine.print("inline stubs loaded: " - .. render.hello() .. ", " .. camera.hello() .. ", " .. input.hello() .. ", " .. player_control.hello() .. ", " .. actor.hello() .. ", " .. interaction.hello()) - local size = maps.size() engine.print(string.format("map size: %dx%d", size.w, size.h)) - local corner = maps.tile_at(0, 0) local interior = maps.tile_at(5, 5) engine.print("tile at (0,0): " .. corner.id) engine.print("tile at (5,5): " .. interior.id) engine.print("walkable at (0,0): " .. tostring(maps.is_walkable(0, 0))) engine.print("walkable at (5,5): " .. tostring(maps.is_walkable(5, 5))) + engine.print(string.format("render: %d tiles per frame", size.w * size.h)) +end + +function render(ctx) + engine.render.clear_color(engine.render.rgb(20, 20, 30)) + r_lib.draw_map() end function update(ctx, dt) diff --git a/manifest.module b/manifest.module index f3a3dd5..677d0a1 100644 --- a/manifest.module +++ b/manifest.module @@ -4,5 +4,8 @@ "kind": "module", "api": "^0.1", "entry_point": "init.lua", - "deps": [{"id":"lib-core.maps","version":"0.1.0"}] + "deps": [ + {"id":"lib-core.maps","version":"0.1.0"}, + {"id":"lib-core.render","version":"0.1.0"} + ] }