diff --git a/init.lua b/init.lua index 9e12a8b..b70df31 100644 --- a/init.lua +++ b/init.lua @@ -5,6 +5,7 @@ local input = require("lib-core.input") local player = require("lib-core.player_control") local interaction = require("lib-core.interaction") local selection = require("lib-core.selection") +local command = require("lib-core.command") local demo_map = maps.load("maps/demo.map.json") maps.set_current(demo_map) @@ -41,6 +42,12 @@ selection.bind_action("lmb") selection.bind_modifier_add("mod_add") selection.bind_modifier_toggle("mod_toggle") +-- P.3.7: Command bindings (RMB → move selected units). +input.bind("rmb", { "mouse_right" }) + +command.bind_move_action("rmb") +command.bind_target_provider(function() return selection.list() end) + camera.bind_pan_keys("pan_left", "pan_right", "pan_up", "pan_down") camera.bind_pan_drag("pan_drag") camera.enable_pan_edge() @@ -60,15 +67,14 @@ local PLAYER_R, PLAYER_G, PLAYER_B = 200, 60, 80 local sign = { x = 144, y = 144, text = "Hier steht: Willkommen im Spine." } local SIGN_R, SIGN_G, SIGN_B = 220, 200, 60 --- P.3.6: 6 stones as selectables (demo for click/box-select + modifiers). --- Positions distributed across walkable map area; sizes uniform 20×20. +-- P.3.6/P.3.7: 6 stones as selectables + movable units (3 speed classes). local stones = { - { x = 64, y = 96, w = 20, h = 20, color = {120, 120, 140} }, - { x = 224, y = 96, w = 20, h = 20, color = {120, 120, 140} }, - { x = 96, y = 256, w = 20, h = 20, color = {130, 110, 100} }, - { x = 320, y = 192, w = 20, h = 20, color = {130, 110, 100} }, - { x = 192, y = 320, w = 20, h = 20, color = {140, 130, 110} }, - { x = 384, y = 256, w = 20, h = 20, color = {140, 130, 110} }, + { x = 64, y = 96, w = 20, h = 20, color = {120, 120, 140}, speed = 100 }, + { x = 224, y = 96, w = 20, h = 20, color = {120, 120, 140}, speed = 100 }, + { x = 96, y = 256, w = 20, h = 20, color = {130, 110, 100}, speed = 150 }, + { x = 320, y = 192, w = 20, h = 20, color = {130, 110, 100}, speed = 150 }, + { x = 192, y = 320, w = 20, h = 20, color = {140, 130, 110}, speed = 200 }, + { x = 384, y = 256, w = 20, h = 20, color = {140, 130, 110}, speed = 200 }, } -- P.3.5: Free-Cam-Mode state @@ -100,14 +106,21 @@ function init(ctx) end) engine.print(string.format("interaction: %d trigger(s) registered", interaction.trigger_count())) - -- P.3.6: Register each stone as selectable. + -- P.3.6/P.3.7: Register each stone as selectable AND movable. for _, s in ipairs(stones) do s.sel_handle = selection.register(function() return { x = s.x, y = s.y, w = s.w, h = s.h } end) + s.cmd_handle = command.register( + function() return { x = s.x, y = s.y } end, + function(nx, ny) s.x = nx; s.y = ny end, + s.speed + ) end engine.print(string.format("selection: %d selectables registered", selection.count_registered())) + engine.print(string.format("command: %d movable units registered", + command.count_registered())) end function render(ctx) @@ -158,6 +171,7 @@ function update(ctx, dt) -- Pan-Summation jeden Frame (keys nur wenn enabled; drag + edge always-on). camera.update(dt) selection.update(dt) + command.update(dt) if not free_cam_mode then -- Follow-cam: set_target jeden Frame -> drag/edge "drift" wird unsichtbar. diff --git a/manifest.module b/manifest.module index a1820e5..f613cea 100644 --- a/manifest.module +++ b/manifest.module @@ -11,6 +11,7 @@ {"id":"lib-core.selection","version":"0.1.0"}, {"id":"lib-core.input","version":"0.3.0"}, {"id":"lib-core.player_control","version":"0.1.0"}, - {"id":"lib-core.interaction","version":"0.1.0"} + {"id":"lib-core.interaction","version":"0.1.0"}, + {"id":"lib-core.command","version":"0.1.0"} ] }