core lua api is almost complete

This commit is contained in:
2019-11-08 03:30:44 +07:00
parent a13a347a23
commit 2c40a2386a
35 changed files with 767 additions and 377 deletions

View File

@@ -0,0 +1,8 @@
---@class dbgui
local dbgui = {
---@type boolean
visible = false
}
---@type dbgui
_G.the_dbgui = _G.the_dbgui or dbgui

View File

@@ -0,0 +1,17 @@
---@class debug
local debug = {
---@type fun(self: debug, message: string)
trace = function(self, message) end,
---@type fun(self: debug, message: string)
warning = function(self, message) end,
---@type fun(self: debug, message: string)
error = function(self, message) end,
---@type fun(self: debug, message: string)
fatal = function(self, message) end
}
---@type debug
_G.the_debug = _G.the_debug or debug

View File

@@ -0,0 +1,20 @@
---@class engine
local engine = {
---@type number
time = 0,
---@type number
delta_time = 0,
---@type number
frame_rate = 0,
---@type number
frame_count = 0,
---@type number
realtime_time = 0
}
---@type engine
_G.the_engine = _G.the_engine or engine

View File

@@ -0,0 +1,11 @@
---@class input
local input = {
---@type mouse
mouse = {},
---@type keyboard
keyboard = {}
}
---@type input
_G.the_input = _G.the_input or input

View File

@@ -0,0 +1,35 @@
---@class keyboard
local keyboard = {
---@type fun(self: keyboard, key : string): boolean
is_key_pressed = function(self, key) return false end,
---@type fun(self: keyboard, key : string): boolean
is_key_just_pressed = function(self, key) return false end,
---@type fun(self: keyboard, key : string): boolean
is_key_just_released = function(self, key) return false end,
---@type string
input_text = "",
---@type boolean
is_any_key_pressed = false,
---@type boolean
is_any_key_just_pressed = false,
---@type boolean
is_any_key_just_released = false,
---@type string[]
pressed_keys = {},
---@type string[]
just_pressed_keys = {},
---@type string[]
just_released_keys = {}
}
---@type keyboard
_G.the_keyboard = _G.the_keyboard or keyboard

View File

@@ -0,0 +1,38 @@
---@class mouse
local mouse = {
---@type fun(self: mouse, button : string): boolean
is_button_pressed = function(self, button) return false end,
---@type fun(self: mouse, button : string): boolean
is_button_just_pressed = function(self, button) return false end,
---@type fun(self: mouse, button : string): boolean
is_button_just_released = function(self, button) return false end,
---@type v2f
cursor_pos = v2f.zero(),
---@type v2f
scroll_delta = v2f.zero(),
---@type boolean
is_any_button_pressed = false,
---@type boolean
is_any_button_just_pressed = false,
---@type boolean
is_any_button_just_released = false,
---@type string[]
pressed_buttons = {},
---@type string[]
just_pressed_buttons = {},
---@type string[]
just_released_buttons = {}
}
---@type mouse
_G.the_mouse = _G.the_mouse or mouse

View File

@@ -0,0 +1,50 @@
---@class window
local window = {
---@type fun(self: window)
hide = function(self) end,
---@type fun(self: window)
show = function(self) end,
---@type fun(self: window)
restore = function(self) end,
---@type fun(self: window)
minimize = function(self) end,
---@type boolean
enable = true,
---@type boolean
visible = true,
---@type boolean
focused = true,
---@type boolean
minimized = true,
---@type boolean
fullscreen = false,
---@type boolean
cursor_hidden = false,
---@type v2f
real_size = v2f.zero(),
---@type v2f
virtual_size = v2f.zero(),
---@type v2f
framebuffer_size = v2f.zero(),
---@type string
title = "",
---@type boolean
should_close = false
}
---@type window
_G.the_window = _G.the_window or window