add baton and hump.timer definitions
This commit is contained in:
parent
ca8dadc90a
commit
b2c6ff5050
3 changed files with 134 additions and 2 deletions
70
def/Baton.d.lua
Normal file
70
def/Baton.d.lua
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
---@meta
|
||||
---@module 'baton'
|
||||
|
||||
---@class BatonConfig
|
||||
---@field controls table<string, string[]>
|
||||
---@field pairs table<string, string[]>
|
||||
---@field joystick? JoystickConfig
|
||||
---@field max_joysticks? integer
|
||||
---@field joystick_deadzone? number
|
||||
|
||||
---@class JoystickConfig
|
||||
---@field controls table<string, string[]>
|
||||
---@field pairs table<string, string[]>
|
||||
---@field deadzone? number
|
||||
|
||||
---@class Baton
|
||||
local Baton = {}
|
||||
|
||||
---Create a new input manager.
|
||||
---@param config BatonConfig
|
||||
---@return Baton
|
||||
function Baton.new(config) end
|
||||
|
||||
---Update the input manager. Call every frame.
|
||||
---@param dt number
|
||||
function Baton:update(dt) end
|
||||
|
||||
---Get the current value of a control.
|
||||
---Returns 1 for digital controls, -1/0/1 for analog axes.
|
||||
---@param control_name string
|
||||
---@return number
|
||||
function Baton:get(control_name) end
|
||||
|
||||
---Check if a control is currently down/pressed.
|
||||
---@param control_name string
|
||||
---@return boolean
|
||||
function Baton:down(control_name) end
|
||||
|
||||
---Check if a control was pressed this frame.
|
||||
---@param control_name string
|
||||
---@return boolean
|
||||
function Baton:pressed(control_name) end
|
||||
|
||||
---Check if a control was released this frame.
|
||||
---@param control_name string
|
||||
---@return boolean
|
||||
function Baton:released(control_name) end
|
||||
|
||||
---Get the value of a control pair (e.g., left/right).
|
||||
---Returns -1 to 1 for opposing pairs.
|
||||
---@param pair_name string
|
||||
---@return number
|
||||
function Baton:getPair(pair_name) end
|
||||
|
||||
---Check if a pair is down.
|
||||
---@param pair_name string
|
||||
---@return boolean
|
||||
function Baton:downPair(pair_name) end
|
||||
|
||||
---Check if a pair was pressed this frame.
|
||||
---@param pair_name string
|
||||
---@return boolean
|
||||
function Baton:pressedPair(pair_name) end
|
||||
|
||||
---Check if a pair was released this frame.
|
||||
---@param pair_name string
|
||||
---@return boolean
|
||||
function Baton:releasedPair(pair_name) end
|
||||
|
||||
return Baton
|
||||
59
def/Timer.d.lua
Normal file
59
def/Timer.d.lua
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
---@meta
|
||||
---@module 'hump.timer'
|
||||
|
||||
---@class Timer
|
||||
local Timer = {}
|
||||
|
||||
---Create a new timer instance.
|
||||
---@return Timer
|
||||
function Timer.new() end
|
||||
|
||||
---Update the timer. Must be called every frame.
|
||||
---@param dt number
|
||||
function Timer:update(dt) end
|
||||
|
||||
---Schedule a function to run after a delay.
|
||||
---@param delay number
|
||||
---@param func function
|
||||
---@param ... any Arguments to pass to func
|
||||
---@return function cancel_function
|
||||
function Timer:after(delay, func, ...) end
|
||||
|
||||
---Schedule a function to run every interval.
|
||||
---@param interval number
|
||||
---@param func function
|
||||
---@param ... any Arguments to pass to func
|
||||
---@return function cancel_function
|
||||
function Timer:every(interval, func, ...) end
|
||||
|
||||
---Schedule a function to run during a duration, with optional easing.
|
||||
---@param duration number
|
||||
---@param subject table
|
||||
---@param target table
|
||||
---@param easing? function
|
||||
---@param after? function
|
||||
---@return function cancel_function
|
||||
function Timer:tween(duration, subject, target, easing, after) end
|
||||
|
||||
---Cancel a scheduled timer function.
|
||||
---@param handle function The handle returned by after/every/tween
|
||||
function Timer:cancel(handle) end
|
||||
|
||||
---Clear all scheduled timers.
|
||||
function Timer:clear() end
|
||||
|
||||
---Run a function over time (tween-like, but returns handle).
|
||||
---@param duration number
|
||||
---@param func function
|
||||
---@param ... any
|
||||
---@return function cancel_function
|
||||
function Timer:during(duration, func, ...) end
|
||||
|
||||
---Run a function every frame for a duration.
|
||||
---@param duration number
|
||||
---@param func function
|
||||
---@param ... any
|
||||
---@return function cancel_function
|
||||
function Timer:script(duration, func, ...) end
|
||||
|
||||
return Timer
|
||||
7
main.lua
7
main.lua
|
|
@ -3,12 +3,15 @@ if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
|
|||
require("lldebugger").start()
|
||||
end
|
||||
|
||||
-- libraries
|
||||
-- libraries --
|
||||
---@type Object
|
||||
Object = require 'lib/classic/classic'
|
||||
---@type Baton
|
||||
Baton = require 'lib/baton/baton'
|
||||
---@type Timer
|
||||
Timer = require 'lib/hump/timer'
|
||||
|
||||
-- objects
|
||||
-- objects --
|
||||
Room = require 'obj/Room'
|
||||
|
||||
function love.load()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue