aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/constants.lua2
-rw-r--r--core/map.lua3
-rw-r--r--core/notifications.lua43
3 files changed, 33 insertions, 15 deletions
diff --git a/core/constants.lua b/core/constants.lua
index 5284e6d..7077f1f 100644
--- a/core/constants.lua
+++ b/core/constants.lua
@@ -2,6 +2,8 @@ constants = {}
constants.resetBgColor = {0.15, 0.15, 0.15}
constants.resetFgColor = {1, 1, 1}
+constants.defaultFontSize = 12
+constants.defaultFont = love.graphics.newFont('assets/fonts/C800.ttf', constants.defaultFontSize)
function constants:resetColors()
love.graphics.setColor(constants.resetFgColor)
diff --git a/core/map.lua b/core/map.lua
index acbdc4a..280057a 100644
--- a/core/map.lua
+++ b/core/map.lua
@@ -5,7 +5,6 @@ Moonshine = require("libs.moonshine")
Camera = require("libs.hump.camera")
Windfield = require("libs.windfield")
require("libs.tserial")
-print(TSerial)
require("core.notifications")
local zoomFactor = 2
@@ -146,7 +145,7 @@ function Map:draw()
drawMapLayer("decorations")
love.graphics.draw(player.sprite, player.x, player.y)
drawMapLayer("foreground")
- _gameWorld:draw()
+ -- _gameWorld:draw() -- Debug Collision Draw
camera:detach()
notifications:draw()
end)
diff --git a/core/notifications.lua b/core/notifications.lua
index 05950f2..ec0a1e1 100644
--- a/core/notifications.lua
+++ b/core/notifications.lua
@@ -1,31 +1,48 @@
Class = require("libs.hump.class")
Timer = require("libs.hump.timer")
+require("core.constants")
Notifications = Class {
init = function(self, zoomFactor)
- color = {1, 0, 0, 1}
- local windowWidth, windowHeight = love.graphics.getDimensions()
+ windowWidth, windowHeight = love.graphics.getDimensions()
end,
- _message={}
+ messages={}
}
function Notifications:update(dt)
- Timer.update(dt)
+ for i,obj in pairs(self.messages) do
+ if obj.timer then
+ obj.timer:update(dt)
+ end
+ end
end
function Notifications:draw()
- if self._message then
- love.graphics.setColor(color)
- love.graphics.print(self._message, 10, wind)
+ love.graphics.setFont(constants.defaultFont)
+ local defaultY = windowHeight - 20
+ for i,obj in pairs(self.messages) do
+ love.graphics.setColor(obj.color)
+ love.graphics.print(obj.message, 10, defaultY)
+ defaultY = defaultY - 15
end
end
function Notifications:send(message)
- self._message = message
- color = {1, 0, 0, 1}
- if Timer then
- Timer.clear()
- end
- Timer.tween(5, color, {0, 0, 0, 0}, 'linear')
+ local messageItem={
+ message=message,
+ color={1, 0, 0, 1},
+ timer=nil
+ }
+ table.insert(self.messages, messageItem)
+ for i,obj in pairs(self.messages) do
+ if obj.timer==nil then
+ obj.timer = Timer.new()
+ obj.timer:tween(5, obj.color, {0, 0, 0, 0}, 'linear', function()
+ obj.timer:clear()
+ obj.timer = nil
+ table.remove(self.messages, 1)
+ end)
+ end
+ end
end
return Notifications \ No newline at end of file