From 3cd0a1f8aeda88d279579502b84d59ef9620e8b9 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Sat, 21 Mar 2026 09:32:44 -0500 Subject: [PATCH] lua_api: accept velocity as a vector --- game/love_src/src/world/top_down_race/system/velocity.lua | 4 +++- game/main.lua | 2 +- game/src/lua_api.cpp | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/game/love_src/src/world/top_down_race/system/velocity.lua b/game/love_src/src/world/top_down_race/system/velocity.lua index 587468a..826ef2c 100644 --- a/game/love_src/src/world/top_down_race/system/velocity.lua +++ b/game/love_src/src/world/top_down_race/system/velocity.lua @@ -328,7 +328,9 @@ function system:draw() local image = e["race.image"].data.image local origin = e["race.image"].data.origin --draw(velocity, x, y, sx, sy, angle, image, origin) - test.set_sphere(x, y, angle) + local vx = 0 + local vy = 0 + test.set_sphere(x, y, vx, vy) end end diff --git a/game/main.lua b/game/main.lua index a8f247b..d23d7a2 100644 --- a/game/main.lua +++ b/game/main.lua @@ -33,7 +33,7 @@ void update(float time); void draw_quad(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); - void set_sphere(float x, float y, float angle); + void set_sphere(float x, float y, float vx, float vy); ]] local source_path = love.filesystem.getSource() test = ffi.load(source_path .. "/test.so") diff --git a/game/src/lua_api.cpp b/game/src/lua_api.cpp index 9c026fd..36bf311 100644 --- a/game/src/lua_api.cpp +++ b/game/src/lua_api.cpp @@ -45,10 +45,10 @@ void draw_quad(int x1, int y1, int x2, int y2, x3, y3, x4, y4); } -void set_sphere(float x, float y, float angle) +void set_sphere(float x, float y, float vx, float vy) { XMVECTOR unit = XMVectorSet(1, 0, 0, 0); // the angle==0 unit vector - view::state.forward = -XMVector3TransformNormal(unit, XMMatrixRotationZ(angle)); + view::state.forward = XMVector3Normalize(XMVectorSet(vx, vy, 0, 0)); view::state.normal = view::get_normal(); view::state.direction = view::get_direction(); -- 2.49.0