add collision
This commit is contained in:
parent
8baf5f06ea
commit
2427e3a504
7 changed files with 302 additions and 52 deletions
|
|
@ -143,6 +143,8 @@ pxl8.world_unload = world.unload
|
|||
pxl8.world_is_loaded = world.is_loaded
|
||||
pxl8.world_generate = world.generate
|
||||
pxl8.world_apply_textures = world.apply_textures
|
||||
pxl8.world_check_collision = world.check_collision
|
||||
pxl8.world_resolve_collision = world.resolve_collision
|
||||
pxl8.procgen_tex = world.procgen_tex
|
||||
pxl8.PROCGEN_ROOMS = world.PROCGEN_ROOMS
|
||||
pxl8.PROCGEN_TERRAIN = world.PROCGEN_TERRAIN
|
||||
|
|
|
|||
|
|
@ -95,4 +95,16 @@ function world.apply_textures(w, texture_defs)
|
|||
return result
|
||||
end
|
||||
|
||||
function world.check_collision(w, x, y, z, radius)
|
||||
local pos = ffi.new("pxl8_vec3", {x = x, y = y, z = z})
|
||||
return C.pxl8_world_check_collision(w, pos, radius)
|
||||
end
|
||||
|
||||
function world.resolve_collision(w, from_x, from_y, from_z, to_x, to_y, to_z, radius)
|
||||
local from = ffi.new("pxl8_vec3", {x = from_x, y = from_y, z = from_z})
|
||||
local to = ffi.new("pxl8_vec3", {x = to_x, y = to_y, z = to_z})
|
||||
local result = C.pxl8_world_resolve_collision(w, from, to, radius)
|
||||
return result.x, result.y, result.z
|
||||
end
|
||||
|
||||
return world
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue