Add API with basic rectangle functions

This commit is contained in:
Robert Miles 2018-07-23 16:05:40 -04:00
parent 803a008054
commit 58f82fec83
1 changed files with 23 additions and 0 deletions

23
src/api.lua Normal file
View File

@ -0,0 +1,23 @@
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 api.rectfill(x,y,w,h,c)
drawState.color = c or drawState.color
return callGraphic("rectangle","fill",x,y,w,h)
end
local function api.rect(x,y,w,h,c)
drawState.color = c or drawState.color
return callGraphic("rectangle","line",x,y,w,h)
end
return api