144 lines
5.3 KiB
Lua
144 lines
5.3 KiB
Lua
---@meta
|
|
|
|
---@class Camera
|
|
---@field x number The x position of the Camera in world coordinates
|
|
---@field y number The y position of the Camera in world coordinates
|
|
---@field scale number The zoom level (scale) of the Camera
|
|
---@field rot number The rotation of the Camera in radians
|
|
---@field smoother fun(dx: number, dy: number, ...: any): number, number The smoothing function used for lock/window methods
|
|
Camera = {}
|
|
|
|
---@class Camera.smooth
|
|
smooth = {}
|
|
|
|
--- No smoothing - instant movement.
|
|
---@return fun(dx: number, dy: number): number, number
|
|
function smooth.none() end
|
|
|
|
--- Linear interpolation toward target at constant speed.
|
|
---@param speed number Units per second
|
|
---@return fun(dx: number, dy: number, s: number|nil): number, number
|
|
function smooth.linear(speed) end
|
|
|
|
--- Damped spring-like smoothing (exponential approach).
|
|
---@param stiffness number Higher = faster response
|
|
---@return fun(dx: number, dy: number, s: number|nil): number, number
|
|
function smooth.damped(stiffness) end
|
|
|
|
--- Sets the position the Camera is looking at.
|
|
---@param x number
|
|
---@param y number
|
|
---@return Camera
|
|
function Camera:lookAt(x, y) end
|
|
|
|
--- Moves the Camera by the given amount.
|
|
---@param dx number
|
|
---@param dy number
|
|
---@return Camera
|
|
function Camera:move(dx, dy) end
|
|
|
|
--- Returns the current position of the Camera.
|
|
---@return number x
|
|
---@return number y
|
|
function Camera:position() end
|
|
|
|
--- Rotates the Camera by the given angle (radians).
|
|
---@param phi number
|
|
---@return Camera
|
|
function Camera:rotate(phi) end
|
|
|
|
--- Sets the absolute rotation of the Camera (radians).
|
|
---@param phi number
|
|
---@return Camera
|
|
function Camera:rotateTo(phi) end
|
|
|
|
--- Multiplies the current zoom level.
|
|
---@param mul number
|
|
---@return Camera
|
|
function Camera:zoom(mul) end
|
|
|
|
--- Sets the absolute zoom level.
|
|
---@param zoom number
|
|
---@return Camera
|
|
function Camera:zoomTo(zoom) end
|
|
|
|
--- Begins drawing with this Camera applied.
|
|
---@param x number|nil Scissor x (default: 0)
|
|
---@param y number|nil Scissor y (default: 0)
|
|
---@param w number|nil Scissor width (default: screen width)
|
|
---@param h number|nil Scissor height (default: screen height)
|
|
---@param noclip boolean|nil If true, scissor is not applied
|
|
function Camera:attach(x, y, w, h, noclip) end
|
|
|
|
--- Ends drawing with this Camera and restores previous transform/scissor.
|
|
function Camera:detach() end
|
|
|
|
--- Draws a function within the Camera's transform.
|
|
---@overload fun(func: fun())
|
|
---@overload fun(x: number, y: number, w: number, h: number, func: fun())
|
|
---@overload fun(x: number, y: number, w: number, h: number, noclip: boolean, func: fun())
|
|
function Camera:draw(x, y, w, h, noclip, func) end
|
|
|
|
--- Converts world coordinates to screen/Camera coordinates.
|
|
---@param x number World x
|
|
---@param y number World y
|
|
---@param ox number|nil Offset x (default: 0)
|
|
---@param oy number|nil Offset y (default: 0)
|
|
---@param w number|nil Screen width (default: love.graphics.getWidth())
|
|
---@param h number|nil Screen height (default: love.graphics.getHeight())
|
|
---@return number screenX
|
|
---@return number screenY
|
|
function Camera:CameraCoords(x, y, ox, oy, w, h) end
|
|
|
|
--- Converts screen coordinates to world coordinates.
|
|
---@param x number Screen x
|
|
---@param y number Screen y
|
|
---@param ox number|nil Offset x (default: 0)
|
|
---@param oy number|nil Offset y (default: 0)
|
|
---@param w number|nil Screen width (default: love.graphics.getWidth())
|
|
---@param h number|nil Screen height (default: love.graphics.getHeight())
|
|
---@return number worldX
|
|
---@return number worldY
|
|
function Camera:worldCoords(x, y, ox, oy, w, h) end
|
|
|
|
--- Returns the current mouse position in world coordinates.
|
|
---@param ox number|nil Offset x (default: 0)
|
|
---@param oy number|nil Offset y (default: 0)
|
|
---@param w number|nil Screen width (default: love.graphics.getWidth())
|
|
---@param h number|nil Screen height (default: love.graphics.getHeight())
|
|
---@return number worldX
|
|
---@return number worldY
|
|
function Camera:mousePosition(ox, oy, w, h) end
|
|
|
|
--- Smoothly moves the Camera to center on x (horizontal only).
|
|
---@param x number Target world x
|
|
---@param smoother fun(dx: number, dy: number, ...: any): number, number | nil
|
|
---@param ... any Extra args passed to smoother
|
|
---@return Camera
|
|
function Camera:lockX(x, smoother, ...) end
|
|
|
|
--- Smoothly moves the Camera to center on y (vertical only).
|
|
---@param y number Target world y
|
|
---@param smoother fun(dx: number, dy: number, ...: any): number, number | nil
|
|
---@param ... any Extra args passed to smoother
|
|
---@return Camera
|
|
function Camera:lockY(y, smoother, ...) end
|
|
|
|
--- Smoothly moves the Camera to center on (x,y).
|
|
---@param x number Target world x
|
|
---@param y number Target world y
|
|
---@param smoother fun(dx: number, dy: number, ...: any): number, number | nil
|
|
---@param ... any Extra args passed to smoother
|
|
---@return Camera
|
|
function Camera:lockPosition(x, y, smoother, ...) end
|
|
|
|
--- Keeps a world point inside a screen-space window using smooth movement.
|
|
---@param x number World x to track
|
|
---@param y number World y to track
|
|
---@param x_min number Left edge of window (screen coords)
|
|
---@param x_max number Right edge of window (screen coords)
|
|
---@param y_min number Top edge of window (screen coords)
|
|
---@param y_max number Bottom edge of window (screen coords)
|
|
---@param smoother fun(dx: number, dy: number, ...: any): number, number | nil
|
|
---@param ... any Extra args passed to smoother
|
|
function Camera:lockWindow(x, y, x_min, x_max, y_min, y_max, smoother, ...) end
|