summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--msgbox.lua15
1 files changed, 7 insertions, 8 deletions
diff --git a/msgbox.lua b/msgbox.lua
index 720bfab..4956d91 100644
--- a/msgbox.lua
+++ b/msgbox.lua
@@ -1,10 +1,9 @@
-local font = love.graphics.getFont()
-
+local G = love.graphics
local msgs = {}
local function add(str)
- table.insert(msgs, 1, {text=love.graphics.newText(font,str),time=10})
+ table.insert(msgs, 1, {text=G.newText(G.getFont(),str),time=10})
end
local margin_bottom = 70
@@ -12,7 +11,7 @@ local margin_bottom = 70
local function draw()
if #msgs == 0 then return end
- local W,H = love.graphics.getDimensions()
+ local W,H = G.getDimensions()
local maxw = 0
local sumh = 0
for _,msg in ipairs(msgs) do
@@ -20,15 +19,15 @@ local function draw()
maxw = math.max(maxw,text:getWidth())
sumh = sumh + text:getHeight()
end
- love.graphics.setColor(0,0,0,0.8)
- love.graphics.rectangle("fill",0,H-sumh-margin_bottom,maxw,sumh)
+ G.setColor(0,0,0,0.8)
+ G.rectangle("fill",0,H-sumh-margin_bottom,maxw,sumh)
- love.graphics.setColor(1,1,1)
+ G.setColor(1,1,1)
local cury = H
for _,msg in ipairs(msgs) do
local text = msg.text
local h = text:getHeight()
- love.graphics.draw(text,0,cury-h-margin_bottom)
+ G.draw(text,0,cury-h-margin_bottom)
cury = cury - h
end
end