This commit is contained in:
2026-03-07 17:45:10 +03:00
parent c388614674
commit 674e03349d
6 changed files with 41 additions and 17 deletions

View File

@@ -67,23 +67,6 @@ function actor_player:action_update()
end
end
-- TODO: remove
function vec3_magnitude(_x, _y, _z)
return math.sqrt(_x * _x + _y * _y + _z * _z)
end
function vec3_normalize(_x, _y, _z)
local mag = vec3_magnitude(_x, _y, _z)
if mag == 0 then return 0, 0, 0 end
return _x / mag, _y / mag, _z / mag
end
function vec3_cross(_x1, _y1, _z1, _x2, _y2, _z2)
return _y1 * _z2 - _y2 * _z1,
_z1 * _x2 - _z2 * _x1,
_x1 * _y2 - _x2 * _y1
end
function actor_player:update_player_movement(dt)
local movement = self:get_movement()
local speed = 4.0

View File

@@ -1,6 +1,7 @@
-- Game initialization script
-- загружаем скрипты
load_script("mathlib.lua")
load_script("game_utils.lua")
load_script("game_hud.lua")
load_script("game_object.lua")

17
data/scripts/mathlib.lua Normal file
View File

@@ -0,0 +1,17 @@
-- math library
function vec3_magnitude(_x, _y, _z)
return math.sqrt(_x * _x + _y * _y + _z * _z)
end
function vec3_normalize(_x, _y, _z)
local mag = vec3_magnitude(_x, _y, _z)
if mag == 0 then return 0, 0, 0 end
return _x / mag, _y / mag, _z / mag
end
function vec3_cross(_x1, _y1, _z1, _x2, _y2, _z2)
return _y1 * _z2 - _y2 * _z1,
_z1 * _x2 - _z2 * _x1,
_x1 * _y2 - _x2 * _y1
end