add proper fnl modules to demo

This commit is contained in:
asrael 2025-10-06 18:14:07 -05:00
parent 9bb9fa5f5b
commit 47c4f2045c
14 changed files with 510 additions and 240 deletions

View file

@ -107,19 +107,33 @@ function pxl8.trace(msg)
end
function pxl8.key_down(key)
if type(key) == "string" then
key = string.byte(key)
end
return C.pxl8_key_down(input, key)
end
function pxl8.key_pressed(key)
if type(key) == "string" then
key = string.byte(key)
end
return C.pxl8_key_pressed(input, key)
end
function pxl8.key_released(key)
return C.pxl8_key_released(input, key)
end
function pxl8.mouse_wheel_x()
return C.pxl8_mouse_wheel_x(input)
end
function pxl8.mouse_wheel_y()
return C.pxl8_mouse_wheel_y(input)
end
function pxl8.mouse_x()
return C.pxl8_mouse_x(input)
end
function pxl8.mouse_y()
return C.pxl8_mouse_y(input)
end
function pxl8.vfx_raster_bars(bars, time)
local c_bars = ffi.new("pxl8_raster_bar[?]", #bars)
for i, bar in ipairs(bars) do
@ -363,19 +377,20 @@ function pxl8.bounds(x, y, w, h)
return ffi.new("pxl8_bounds", {x = x, y = y, w = w, h = h})
end
function pxl8.ui_window_begin(title, x, y, w, h, options)
local rect = ffi.new("pxl8_bounds", {x = x, y = y, w = w, h = h})
return C.pxl8_ui_window_begin(_pxl8_ui, title, rect, options or 0)
end
function pxl8.ui_window_end()
C.pxl8_ui_window_end(_pxl8_ui)
end
function pxl8.ui_button(label)
return C.pxl8_ui_button(_pxl8_ui, label)
end
function pxl8.ui_checkbox(label, state)
local state_ptr = ffi.new("bool[1]", state)
local changed = C.pxl8_ui_checkbox(_pxl8_ui, label, state_ptr)
return changed, state_ptr[0]
end
function pxl8.ui_indent(amount)
C.pxl8_ui_indent(_pxl8_ui, amount)
end
function pxl8.ui_label(text)
C.pxl8_ui_label(_pxl8_ui, text)
end
@ -390,4 +405,17 @@ function pxl8.ui_layout_row(item_count, widths, height)
C.pxl8_ui_layout_row(_pxl8_ui, item_count, widths_array, height)
end
function pxl8.ui_window_begin(title, x, y, w, h, options)
local rect = ffi.new("pxl8_bounds", {x = x, y = y, w = w, h = h})
return C.pxl8_ui_window_begin(_pxl8_ui, title, rect, options or 0)
end
function pxl8.ui_window_end()
C.pxl8_ui_window_end(_pxl8_ui)
end
function pxl8.ui_window_set_open(title, open)
C.pxl8_ui_window_set_open(_pxl8_ui, title, open)
end
return pxl8