lua_api: accept velocity as a vector

This commit is contained in:
Zack Buhman 2026-03-21 09:32:44 -05:00 committed by fnicon
parent 352fd4352f
commit 878d925c5d
3 changed files with 6 additions and 4 deletions

View File

@ -261,7 +261,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

View File

@ -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")

View File

@ -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();