funk/src/api.lua

31 lines
651 B
Lua

local api = {} -- API functions provided to games
local drawState = {color=15}
local function callGraphic(...)
local args = {...}
local name = table.remove(args,1)
love.graphics.setCanvas(scr)
pal.setColor(drawState.color)
love.graphics[name](unpack(args))
love.graphics.setCanvas()
end
local function rectfill(x,y,w,h,c)
drawState.color = c or drawState.color
return callGraphic("rectangle","fill",x,y,w,h)
end
local function rect(x,y,w,h,c)
drawState.color = c or drawState.color
return callGraphic("rectangle","line",x,y,w,h)
end
local function cls(c)
rectfill(0,0,255,243,c)
end
api.rectfill = rectfill
api.rect = rect
return api