the story beginns

This commit is contained in:
Sebastian Hugentobler 2014-05-21 11:36:02 +02:00
parent 8d21db47f1
commit 203f111b8a
8 changed files with 33 additions and 9 deletions

View File

@ -7,6 +7,7 @@ collider = HC(100)
local sti = require "engine/libs/sti"
local object = require "engine/object"
local ui = require "engine/ui"
local story = require 'story'
Engine = class()
@ -16,10 +17,7 @@ function Engine:__init()
self.windowWidth = love.graphics.getWidth()
self.windowHeight = love.graphics.getHeight()
self.map = sti.new("assets/map")
self.collision = self.map:getCollisionMap("collision")
self:initObjects()
story:start(self)
end
function Engine:checkObjectAnimation(key)
@ -76,6 +74,8 @@ function Engine:draw()
end
function Engine:initObjects()
self.objects = {}
self.map:addCustomLayer("object layer", 4)
local objectLayer = self.map.layers["object layer"]
@ -120,3 +120,16 @@ function Engine:debugDrawing()
-- Draw Collision Map (useful for debugging)
self.map:drawCollisionMap(collision)
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

View File

@ -15,11 +15,14 @@ ui.endLine = 1
local font = love.graphics.newFont("assets/ui/font.ttf", 24)
love.graphics.setFont(font)
ui.windowWidth = love.graphics.getWidth()
ui.windowHeight = love.graphics.getHeight()
function ui:showMessage(message)
ui.active = true
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 = {}
@ -57,9 +60,9 @@ function ui:getMaxString(stringTail)
local index = string.len(stringTail)
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))
index = index - 1
end
@ -79,10 +82,10 @@ end
function ui:draw()
if ui.active then
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.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

View File

Before

Width:  |  Height:  |  Size: 328 KiB

After

Width:  |  Height:  |  Size: 328 KiB

View File

Before

Width:  |  Height:  |  Size: 211 KiB

After

Width:  |  Height:  |  Size: 211 KiB

View File

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 181 KiB

View File

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 254 KiB

8
src/story.lua Normal file
View 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