the story beginns
@ -7,6 +7,7 @@ collider = HC(100)
|
|||||||
local sti = require "engine/libs/sti"
|
local sti = require "engine/libs/sti"
|
||||||
local object = require "engine/object"
|
local object = require "engine/object"
|
||||||
local ui = require "engine/ui"
|
local ui = require "engine/ui"
|
||||||
|
local story = require 'story'
|
||||||
|
|
||||||
Engine = class()
|
Engine = class()
|
||||||
|
|
||||||
@ -16,10 +17,7 @@ function Engine:__init()
|
|||||||
self.windowWidth = love.graphics.getWidth()
|
self.windowWidth = love.graphics.getWidth()
|
||||||
self.windowHeight = love.graphics.getHeight()
|
self.windowHeight = love.graphics.getHeight()
|
||||||
|
|
||||||
self.map = sti.new("assets/map")
|
story:start(self)
|
||||||
self.collision = self.map:getCollisionMap("collision")
|
|
||||||
|
|
||||||
self:initObjects()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Engine:checkObjectAnimation(key)
|
function Engine:checkObjectAnimation(key)
|
||||||
@ -76,6 +74,8 @@ function Engine:draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Engine:initObjects()
|
function Engine:initObjects()
|
||||||
|
self.objects = {}
|
||||||
|
|
||||||
self.map:addCustomLayer("object layer", 4)
|
self.map:addCustomLayer("object layer", 4)
|
||||||
|
|
||||||
local objectLayer = self.map.layers["object layer"]
|
local objectLayer = self.map.layers["object layer"]
|
||||||
@ -120,3 +120,16 @@ function Engine:debugDrawing()
|
|||||||
-- Draw Collision Map (useful for debugging)
|
-- Draw Collision Map (useful for debugging)
|
||||||
self.map:drawCollisionMap(collision)
|
self.map:drawCollisionMap(collision)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Engine:loadLevel(name)
|
||||||
|
local mapName = 'levels/' .. name
|
||||||
|
|
||||||
|
self.map = sti.new(mapName)
|
||||||
|
self.collision = self.map:getCollisionMap("collision")
|
||||||
|
|
||||||
|
self:initObjects()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Engine:showMessage(message)
|
||||||
|
ui:showMessage(message)
|
||||||
|
end
|
||||||
|
@ -15,11 +15,14 @@ ui.endLine = 1
|
|||||||
local font = love.graphics.newFont("assets/ui/font.ttf", 24)
|
local font = love.graphics.newFont("assets/ui/font.ttf", 24)
|
||||||
love.graphics.setFont(font)
|
love.graphics.setFont(font)
|
||||||
|
|
||||||
|
ui.windowWidth = love.graphics.getWidth()
|
||||||
|
ui.windowHeight = love.graphics.getHeight()
|
||||||
|
|
||||||
function ui:showMessage(message)
|
function ui:showMessage(message)
|
||||||
ui.active = true
|
ui.active = true
|
||||||
|
|
||||||
local maxLines = math.floor((ui.height - ui.border) / font:getHeight())
|
local maxLines = math.floor((ui.height - ui.border) / font:getHeight())
|
||||||
local fullLines = font:getWrap(ui.fullMessage, windowWidth - ui.border)
|
local fullLines = font:getWrap(ui.fullMessage, ui.windowWidth - ui.border)
|
||||||
|
|
||||||
ui.textLines = {}
|
ui.textLines = {}
|
||||||
|
|
||||||
@ -57,9 +60,9 @@ function ui:getMaxString(stringTail)
|
|||||||
local index = string.len(stringTail)
|
local index = string.len(stringTail)
|
||||||
local width = font:getWidth(string.sub(stringTail, 1, index))
|
local width = font:getWidth(string.sub(stringTail, 1, index))
|
||||||
|
|
||||||
local needsCutting = width > windowWidth - ui.border
|
local needsCutting = width > ui.windowWidth - ui.border
|
||||||
|
|
||||||
while width > windowWidth - ui.border do
|
while width > ui.windowWidth - ui.border do
|
||||||
width = font:getWidth(string.sub(stringTail, 1, index))
|
width = font:getWidth(string.sub(stringTail, 1, index))
|
||||||
index = index - 1
|
index = index - 1
|
||||||
end
|
end
|
||||||
@ -79,10 +82,10 @@ end
|
|||||||
function ui:draw()
|
function ui:draw()
|
||||||
if ui.active then
|
if ui.active then
|
||||||
love.graphics.setColor(255, 255, 255, 150)
|
love.graphics.setColor(255, 255, 255, 150)
|
||||||
love.graphics.rectangle("fill", 0, windowHeight - ui.height, windowWidth, ui.height)
|
love.graphics.rectangle("fill", 0, ui.windowHeight - ui.height, ui.windowWidth, ui.height)
|
||||||
|
|
||||||
love.graphics.setColor(55, 60, 60, 255)
|
love.graphics.setColor(55, 60, 60, 255)
|
||||||
love.graphics.printf(ui.fullMessage, ui.border, windowHeight - ui.height + ui.border, windowWidth - ui.border)
|
love.graphics.printf(ui.fullMessage, ui.border, ui.windowHeight - ui.height + ui.border, ui.windowWidth - ui.border)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 328 KiB After Width: | Height: | Size: 328 KiB |
Before Width: | Height: | Size: 211 KiB After Width: | Height: | Size: 211 KiB |
Before Width: | Height: | Size: 181 KiB After Width: | Height: | Size: 181 KiB |
Before Width: | Height: | Size: 254 KiB After Width: | Height: | Size: 254 KiB |
8
src/story.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
local story = {}
|
||||||
|
|
||||||
|
function story:start(engine)
|
||||||
|
engine:loadLevel('01')
|
||||||
|
engine:showMessage('Du befindest dich auf einer sturmgebeutelten Insel. Wo ist denn nur die Milch?')
|
||||||
|
end
|
||||||
|
|
||||||
|
return story
|