consistent indentation

This commit is contained in:
lustlion 2022-02-26 03:56:53 +01:00
parent 42cf9cfec8
commit 1580dc3463
38 changed files with 2071 additions and 2071 deletions

View File

@ -1,17 +1,17 @@
Animation = {} Animation = {}
function Animation:New(anim_data) function Animation:New(anim_data)
local o = {} local o = {}
o.path = anim_data.path o.path = anim_data.path
o.frames = anim_data.frames o.frames = anim_data.frames
o.imgs = anim_data.imgs o.imgs = anim_data.imgs
o.subframe = 0 o.subframe = 0
o.frame = 1 o.frame = 1
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function Animation:ChangeTo(anim_data) function Animation:ChangeTo(anim_data)
@ -44,20 +44,20 @@ end
-- to linearly animate -- to linearly animate
function Animation:Animate() function Animation:Animate()
if self.frames[self.frame] ~= 0 then if self.frames[self.frame] ~= 0 then
-- try to animate -- try to animate
self.subframe = self.subframe + current_dt self.subframe = self.subframe + current_dt
if self.subframe > self.frames[self.frame] then if self.subframe > self.frames[self.frame] then
self.subframe = self.subframe - self.frames[self.frame] self.subframe = self.subframe - self.frames[self.frame]
self.frame = self.frame + 1 self.frame = self.frame + 1
end end
-- cycle -- cycle
if self.frame >= #self.frames+1 then if self.frame >= #self.frames+1 then
self.frame = self.frame - #self.frames self.frame = self.frame - #self.frames
end end
end end
end end
-- to draw the current frame -- to draw the current frame

View File

@ -2,46 +2,46 @@
-- https://love2d.org/wiki/Minimalist_Sound_Manager -- https://love2d.org/wiki/Minimalist_Sound_Manager
-- <3 -- <3
do do
-- will hold the currently playing sources -- will hold the currently playing sources
local sources = {} local sources = {}
-- check for sources that finished playing and remove them -- check for sources that finished playing and remove them
-- add to love.update -- add to love.update
function love.audio.update() function love.audio.update()
local remove = {} local remove = {}
for _,s in pairs(sources) do for _,s in pairs(sources) do
if not s:isPlaying() then if not s:isPlaying() then
remove[#remove + 1] = s remove[#remove + 1] = s
end end
end end
for i,s in ipairs(remove) do for i,s in ipairs(remove) do
sources[s] = nil sources[s] = nil
end end
end end
-- overwrite love.audio.play to create and register source if needed -- overwrite love.audio.play to create and register source if needed
local play = love.audio.play local play = love.audio.play
function love.audio.play(audio) function love.audio.play(audio)
local what = audio.path local what = audio.path
local how = audio.type local how = audio.type
local loop = audio.loop local loop = audio.loop
local src = what local src = what
if type(what) ~= "userdata" or not what:typeOf("Source") then if type(what) ~= "userdata" or not what:typeOf("Source") then
src = love.audio.newSource(what, how) src = love.audio.newSource(what, how)
src:setLooping(loop or false) src:setLooping(loop or false)
end end
play(src) play(src)
sources[src] = src sources[src] = src
return src return src
end end
-- stops a source -- stops a source
local stop = love.audio.stop local stop = love.audio.stop
function love.audio.stop(src) function love.audio.stop(src)
if not src then return end if not src then return end
stop(src) stop(src)
sources[src] = nil sources[src] = nil
end end
end end

View File

@ -1,15 +1,15 @@
Canvas = {class = "Canvas"} Canvas = {class = "Canvas"}
function Canvas:New(name) function Canvas:New(name)
local o = {} local o = {}
o.name = name o.name = name
o.width = game.width/game.scale o.width = game.width/game.scale
o.height = game.height/game.scale o.height = game.height/game.scale
o.canvas = love.graphics.newCanvas(o.width,o.height) o.canvas = love.graphics.newCanvas(o.width,o.height)
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function Canvas:Recreate() function Canvas:Recreate()
@ -19,7 +19,7 @@ end
function Canvas:Reset() function Canvas:Reset()
love.graphics.setCanvas(self.canvas) love.graphics.setCanvas(self.canvas)
love.graphics.setBlendMode("replace") love.graphics.setBlendMode("replace")
love.graphics.setColor(0,0,0,0) love.graphics.setColor(0,0,0,0)
love.graphics.rectangle( love.graphics.rectangle(
"fill", "fill",
@ -39,11 +39,11 @@ end
function Canvas:DrawingEnd() function Canvas:DrawingEnd()
love.graphics.setCanvas() love.graphics.setCanvas()
love.graphics.setBlendMode("alpha") love.graphics.setBlendMode("alpha")
love.graphics.setColor(1,1,1,1) love.graphics.setColor(1,1,1,1)
end end
function Canvas:Draw() function Canvas:Draw()
love.graphics.draw(self.canvas) love.graphics.draw(self.canvas)
end end
require "code/canvasses/darkness" require "code/canvasses/darkness"

View File

@ -2,7 +2,7 @@ Canvas.Darkness = Canvas:New("Darkness")
function Canvas.Darkness:Reset() function Canvas.Darkness:Reset()
love.graphics.setCanvas(Canvas.Darkness.canvas) love.graphics.setCanvas(Canvas.Darkness.canvas)
love.graphics.setBlendMode("replace") love.graphics.setBlendMode("replace")
love.graphics.setColor(0,0,0,0.95) love.graphics.setColor(0,0,0,0.95)
love.graphics.rectangle( love.graphics.rectangle(
"fill", "fill",

View File

@ -8,22 +8,22 @@ LoadedObjects.Hazards = {}
--[[ --[[
Collision Collision
[bool flag] isDisabled [bool flag] isDisabled
> if true used for collision > if true used for collision
[bool flag] isColliding [bool flag] isColliding
> if true, this collision is colliding > if true, this collision is colliding
[vec2 position] from - x, y [vec2 position] from - x, y
> top right corner of collision box > top right corner of collision box
[vec2 position] to - x, y [vec2 position] to - x, y
> bottom left corner of collision box > bottom left corner of collision box
[int property] width [int property] width
> width of collision box > width of collision box
[int property] height [int property] height
> height of collision box > height of collision box
--]] --]]

View File

@ -11,28 +11,28 @@ function DebugUI()
love.graphics.print("time: "..fps_total..", fps: "..fps_draw..", frametime: "..math.floor(current_dt* 1000).."ms", 10*textScale, 0*textScale, 0, textScale) love.graphics.print("time: "..fps_total..", fps: "..fps_draw..", frametime: "..math.floor(current_dt* 1000).."ms", 10*textScale, 0*textScale, 0, textScale)
love.graphics.print(--[["CPUtime: "..checkCPUTime("total")..", CPU: "..(math.floor(checkCPUTime("get")*10000)/100).."%,]] "memoryUsage: "..memoryUsage.."kB", 10*textScale, 20*textScale, 0, textScale) love.graphics.print(--[["CPUtime: "..checkCPUTime("total")..", CPU: "..(math.floor(checkCPUTime("get")*10000)/100).."%,]] "memoryUsage: "..memoryUsage.."kB", 10*textScale, 20*textScale, 0, textScale)
love.graphics.setColor(1,1,1) love.graphics.setColor(1,1,1)
-- lots of variables -- lots of variables
love.graphics.print("LoadedObjects",10*textScale,40*textScale, 0, textScale) love.graphics.print("LoadedObjects",10*textScale,40*textScale, 0, textScale)
local i = 1 local i = 1
for k, v in pairs(LoadedObjects) do for k, v in pairs(LoadedObjects) do
if type(v) == "table" then if type(v) == "table" then
love.graphics.print("<"..k.."> ".. #v,10*textScale,(40+(10*i))*textScale, 0, textScale) love.graphics.print("<"..k.."> ".. #v,10*textScale,(40+(10*i))*textScale, 0, textScale)
i = i + 1 i = i + 1
end end
end end
-- player isOnGroundCheck -- player isOnGroundCheck
love.graphics.setColor(1,0,0) love.graphics.setColor(1,0,0)
end end
function DebugColisions() function DebugColisions()
love.graphics.setScale(game.scale) love.graphics.setScale(game.scale)
-- DrawColisionTable() -- DrawColisionTable()
LoadedObjects.DrawCollisions() LoadedObjects.DrawCollisions()
end end
function DebugEntities() function DebugEntities()
love.graphics.setScale(game.scale) love.graphics.setScale(game.scale)
for _, particle in pairs(LoadedParticles) do for _, particle in pairs(LoadedParticles) do
particle:Debug() particle:Debug()
end end

View File

@ -5,61 +5,61 @@ DemoAction = nil -- Table of actions
CurrentDemoFrame = nil CurrentDemoFrame = nil
function Demo:Draw() function Demo:Draw()
if DemoRecording then if DemoRecording then
love.graphics.setColor(1,0,0,1) love.graphics.setColor(1,0,0,1)
elseif DemoPlayback then elseif DemoPlayback then
love.graphics.setColor(0,0,1,1) love.graphics.setColor(0,0,1,1)
end end
love.graphics.rectangle("line",0,0,game.width ,game.height) love.graphics.rectangle("line",0,0,game.width ,game.height)
end end
function Demo:PlaybackStart() function Demo:PlaybackStart()
DemoPlayback = true DemoPlayback = true
CurrentDemoFrame = 0 CurrentDemoFrame = 0
dofile("demos/play_demo.lua") dofile("demos/play_demo.lua")
end end
function Demo:PlaybackEnd() function Demo:PlaybackEnd()
DemoPlayback = false DemoPlayback = false
DemoAction = nil DemoAction = nil
end end
function Demo:RecordAction(action) function Demo:RecordAction(action)
if DemoRecording if DemoRecording
and action ~= nil and action ~= nil
then then
DemoFile:write("\""..action.."\",") DemoFile:write("\""..action.."\",")
end end
end end
function Demo:RecordStart() function Demo:RecordStart()
-- Make demo stuff -- Make demo stuff
os.execute( "mkdir \"./demos\"" ) os.execute( "mkdir \"./demos\"" )
DemoFile = io.open("demos/play_demo.lua", "w+") DemoFile = io.open("demos/play_demo.lua", "w+")
--DemoFile = io.open("demo/mothbackDemo_"..os.date("%Y-%m-%d_%H-%M-%S")..".lua", "w+") --DemoFile = io.open("demo/mothbackDemo_"..os.date("%Y-%m-%d_%H-%M-%S")..".lua", "w+")
DemoFile:write("main_Player.pos.x = "..main_Player.pos.x.."\n") DemoFile:write("main_Player.pos.x = "..main_Player.pos.x.."\n")
DemoFile:write("main_Player.pos.y = "..main_Player.pos.y.."\n") DemoFile:write("main_Player.pos.y = "..main_Player.pos.y.."\n")
DemoFile:write("DemoAction = {\n") DemoFile:write("DemoAction = {\n")
DemoRecording = true DemoRecording = true
CurrentDemoFrame = 1 CurrentDemoFrame = 1
end end
function Demo:RecordEnd() function Demo:RecordEnd()
DemoFile:write("}\n}") DemoFile:write("}\n}")
DemoFile:close() DemoFile:close()
DemoFile = nil DemoFile = nil
DemoRecording = false DemoRecording = false
end end
function Demo:Step() function Demo:Step()
if DemoRecording then if DemoRecording then
if CurrentDemoFrame == 1 then if CurrentDemoFrame == 1 then
DemoFile:write("\t{") DemoFile:write("\t{")
else else
DemoFile:write("},\n\t{") DemoFile:write("},\n\t{")
end end
elseif DemoPlayback then elseif DemoPlayback then
if DemoAction[CurrentDemoFrame + 1] == nil then Demo:PlaybackEnd() end if DemoAction[CurrentDemoFrame + 1] == nil then Demo:PlaybackEnd() end
end end
CurrentDemoFrame = CurrentDemoFrame + 1 CurrentDemoFrame = CurrentDemoFrame + 1
end end

View File

@ -1,6 +1,6 @@
function love.graphics.setScale(scale_x, scale_y) function love.graphics.setScale(scale_x, scale_y)
local scale_x = scale_x or 1 local scale_x = scale_x or 1
local scale_y = scale_y or scale_x local scale_y = scale_y or scale_x
love.graphics.origin() love.graphics.origin()
love.graphics.scale(scale_x,scale_y) love.graphics.scale(scale_x,scale_y)
end end

View File

@ -1,65 +1,65 @@
function EditorStep() function EditorStep()
palette = palette or false palette = palette or false
AnimateTiles() AnimateTiles()
if Keybind:CheckPressed(Keybind.editor.palette) then if Keybind:CheckPressed(Keybind.editor.palette) then
if palette then if palette then
palette = false palette = false
palette_scroll_x = nil palette_scroll_x = nil
palette_scroll_y = nil palette_scroll_y = nil
else else
palette = true palette = true
palette_scroll_x = 0 palette_scroll_x = 0
palette_scroll_y = 0 palette_scroll_y = 0
end end
end end
if love.keyboard.isDown('a',"left") then if love.keyboard.isDown('a',"left") then
Camera.pos.x = Camera.pos.x - 3*game.scale Camera.pos.x = Camera.pos.x - 3*game.scale
end end
if love.keyboard.isDown('d',"right") then if love.keyboard.isDown('d',"right") then
Camera.pos.x = Camera.pos.x + 3*game.scale Camera.pos.x = Camera.pos.x + 3*game.scale
end end
if love.keyboard.isDown("up", "w") then if love.keyboard.isDown("up", "w") then
Camera.pos.y = Camera.pos.y - 3*game.scale Camera.pos.y = Camera.pos.y - 3*game.scale
end end
if love.keyboard.isDown("down", "s") then if love.keyboard.isDown("down", "s") then
Camera.pos.y = Camera.pos.y + 3*game.scale Camera.pos.y = Camera.pos.y + 3*game.scale
end end
if palette then if palette then
if Keybind:CheckPressed(Keybind.debug.debug) then if Keybind:CheckPressed(Keybind.debug.debug) then
local next = false local next = false
local export = nil local export = nil
for k, v in pairs(tileset) do for k, v in pairs(tileset) do
if export == nil then if export == nil then
export = v export = v
end end
if next then if next then
LevelData.tileset = v LevelData.tileset = v
next = false next = false
break break
end end
if v == LevelData.tileset then if v == LevelData.tileset then
next = true next = true
end end
end end
if next then if next then
LevelData.tileset = export LevelData.tileset = export
end end
LevelGetTileData() LevelGetTileData()
LevelIndexTiles() LevelIndexTiles()
end end
end end
if Keybind:CheckPressed(Keybind.debug.reload) then if Keybind:CheckPressed(Keybind.debug.reload) then
ExportLevel("test") ExportLevel("test")
end end
if Keybind:CheckPressed(Keybind.debug.editor) then if Keybind:CheckPressed(Keybind.debug.editor) then
editor_mode = false editor_mode = false
TileCreateObjects() TileCreateObjects()
end end
end end
function EditorScroll(y) function EditorScroll(y)
@ -76,163 +76,163 @@ function EditorScroll(y)
end end
function EditorDraw() function EditorDraw()
GameworldDrawPrepare() GameworldDrawPrepare()
GameworldDrawBackground() GameworldDrawBackground()
GridDisplay() GridDisplay()
GameworldDrawForeground() GameworldDrawForeground()
GameworldDrawEnd() GameworldDrawEnd()
EditorDoEdit() EditorDoEdit()
DrawSelectingPaletteTile() DrawSelectingPaletteTile()
if palette then if palette then
EditorDoPalette() EditorDoPalette()
end end
end end
function EditorDoEdit() function EditorDoEdit()
local mouse_x = love.mouse.getX() local mouse_x = love.mouse.getX()
local mouse_y = love.mouse.getY() local mouse_y = love.mouse.getY()
local horizontal = 1+math.floor(((mouse_x/game.scale) / tileProperties.width) + (Camera.pos.x / tileProperties.width)) local horizontal = 1+math.floor(((mouse_x/game.scale) / tileProperties.width) + (Camera.pos.x / tileProperties.width))
local vertical = 1+math.floor(((mouse_y/game.scale) / tileProperties.height) + (Camera.pos.y / tileProperties.height)) local vertical = 1+math.floor(((mouse_y/game.scale) / tileProperties.height) + (Camera.pos.y / tileProperties.height))
local expand_h = 0 local expand_h = 0
local expand_v = 0 local expand_v = 0
local LevelWidth = LevelGetTileWidth() local LevelWidth = LevelGetTileWidth()
local LevelHeight = LevelGetTileHeight() local LevelHeight = LevelGetTileHeight()
if horizontal > LevelWidth then if horizontal > LevelWidth then
expand_h = horizontal-LevelWidth expand_h = horizontal-LevelWidth
elseif horizontal < 0 then elseif horizontal < 0 then
expand_h = horizontal expand_h = horizontal
end end
if vertical > LevelHeight then if vertical > LevelHeight then
expand_v = vertical-LevelHeight expand_v = vertical-LevelHeight
elseif vertical < 0 then elseif vertical < 0 then
expand_v = vertical expand_v = vertical
end end
love.graphics.print("> " .. horizontal .. ", " .. vertical .. "; " .. math.floor(mouse_x / game.scale + Camera.pos.x) .. ", " .. math.floor(mouse_y / game.scale + Camera.pos.y)) love.graphics.print("> " .. horizontal .. ", " .. vertical .. "; " .. math.floor(mouse_x / game.scale + Camera.pos.x) .. ", " .. math.floor(mouse_y / game.scale + Camera.pos.y))
love.graphics.print("> " .. LevelWidth .. "(" .. expand_h .. "), " .. LevelHeight .. "(".. expand_v .. ")", 0, 10) love.graphics.print("> " .. LevelWidth .. "(" .. expand_h .. "), " .. LevelHeight .. "(".. expand_v .. ")", 0, 10)
if not palette then if not palette then
if LevelTiles[vertical] ~= nil if LevelTiles[vertical] ~= nil
and LevelTiles[vertical][horizontal] ~= nil and LevelTiles[vertical][horizontal] ~= nil
and love.keyboard.isDown("lshift") ~= true and love.keyboard.isDown("lshift") ~= true
and love.keyboard.isDown("lctrl") ~= true and love.keyboard.isDown("lctrl") ~= true
then then
if Keybind:CheckDown(Keybind.generic.lclick) if Keybind:CheckDown(Keybind.generic.lclick)
and selecting_tile ~= nil and selecting_tile ~= nil
then then
SetTile(vertical,horizontal,selecting_tile) SetTile(vertical,horizontal,selecting_tile)
elseif Keybind:CheckDown(Keybind.generic.rclick) then elseif Keybind:CheckDown(Keybind.generic.rclick) then
SetTile(vertical,horizontal,0) SetTile(vertical,horizontal,0)
end end
LevelReloadTiles() LevelReloadTiles()
elseif Keybind:CheckPressed(Keybind.generic.lshift) then elseif Keybind:CheckPressed(Keybind.generic.lshift) then
LevelExpandCanvas(math.sign(expand_h),math.sign(expand_v)) LevelExpandCanvas(math.sign(expand_h),math.sign(expand_v))
LevelReloadTiles() LevelReloadTiles()
elseif Keybind:CheckPressed(Keybind.generic.lctrl) then elseif Keybind:CheckPressed(Keybind.generic.lctrl) then
LevelReduceCanvas(math.sign(expand_h),math.sign(expand_v)) LevelReduceCanvas(math.sign(expand_h),math.sign(expand_v))
LevelReloadTiles() LevelReloadTiles()
end end
end end
end end
function DrawSelectingPaletteTile() function DrawSelectingPaletteTile()
if selecting_tile ~= nil and selecting_tile ~= 0 then if selecting_tile ~= nil and selecting_tile ~= 0 then
local mouse_x = love.mouse.getX() local mouse_x = love.mouse.getX()
local mouse_y = love.mouse.getY() local mouse_y = love.mouse.getY()
local horizontal = math.floor(((mouse_x/game.scale) / tileProperties.width) + (Camera.pos.x / tileProperties.width)) local horizontal = math.floor(((mouse_x/game.scale) / tileProperties.width) + (Camera.pos.x / tileProperties.width))
local vertical = math.floor(((mouse_y/game.scale) / tileProperties.height) + (Camera.pos.y / tileProperties.height)) local vertical = math.floor(((mouse_y/game.scale) / tileProperties.height) + (Camera.pos.y / tileProperties.height))
local draw_x = tileProperties.width * horizontal - Camera.pos.x local draw_x = tileProperties.width * horizontal - Camera.pos.x
local draw_y = tileProperties.height * vertical - Camera.pos.y local draw_y = tileProperties.height * vertical - Camera.pos.y
love.graphics.draw( love.graphics.draw(
LevelData.tileset, LevelData.tileset,
TileIndex[selecting_tile], TileIndex[selecting_tile],
draw_x, draw_x,
draw_y draw_y
) )
end end
end end
function EditorDoPalette() function EditorDoPalette()
local width = LevelData.tileset:getPixelWidth()/tileProperties.width local width = LevelData.tileset:getPixelWidth()/tileProperties.width
local height = LevelData.tileset:getPixelHeight()/tileProperties.height local height = LevelData.tileset:getPixelHeight()/tileProperties.height
love.graphics.setColor(0,0,0,1) love.graphics.setColor(0,0,0,1)
love.graphics.rectangle( love.graphics.rectangle(
"fill", "fill",
(palette_scroll_x + 1) * (tileProperties.width+1), (palette_scroll_x + 1) * (tileProperties.width+1),
(palette_scroll_y + 1) * (tileProperties.height+1), (palette_scroll_y + 1) * (tileProperties.height+1),
1 + LevelData.tileset:getPixelWidth() * ((tileProperties.width+1) / tileProperties.width), 1 + LevelData.tileset:getPixelWidth() * ((tileProperties.width+1) / tileProperties.width),
1 + LevelData.tileset:getPixelHeight()* ((tileProperties.height+1) / tileProperties.height) 1 + LevelData.tileset:getPixelHeight()* ((tileProperties.height+1) / tileProperties.height)
) )
love.graphics.setColor(1,1,1,1) love.graphics.setColor(1,1,1,1)
local position_x = 1 local position_x = 1
local position_y = 1 local position_y = 1
for i = 1, #TileIndex-width-1 do for i = 1, #TileIndex-width-1 do
local tile_x = (palette_scroll_x + position_x) * (tileProperties.width+1) local tile_x = (palette_scroll_x + position_x) * (tileProperties.width+1)
local tile_y = (palette_scroll_y + position_y) * (tileProperties.height+1) local tile_y = (palette_scroll_y + position_y) * (tileProperties.height+1)
love.graphics.draw( love.graphics.draw(
LevelData.tileset, LevelData.tileset,
TileIndex[i], TileIndex[i],
tile_x, tile_x,
tile_y, tile_y,
0, 0,
1, 1,
1 1
) )
if Keybind:CheckDown(Keybind.generic.lclick) then if Keybind:CheckDown(Keybind.generic.lclick) then
local mouse_x = love.mouse.getX() local mouse_x = love.mouse.getX()
local mouse_y = love.mouse.getY() local mouse_y = love.mouse.getY()
if mouse_x > (tile_x) * game.scale if mouse_x > (tile_x) * game.scale
and mouse_x < (tile_x + tileProperties.width) * game.scale and mouse_x < (tile_x + tileProperties.width) * game.scale
and mouse_y > (tile_y) * game.scale and mouse_y > (tile_y) * game.scale
and mouse_y < (tile_y + tileProperties.height) * game.scale and mouse_y < (tile_y + tileProperties.height) * game.scale
then then
selecting_tile = position_x + ((position_y-1) * width) selecting_tile = position_x + ((position_y-1) * width)
love.graphics.print(selecting_tile .. " | " .. tile_x .. ", " .. tile_y, 0, 20) love.graphics.print(selecting_tile .. " | " .. tile_x .. ", " .. tile_y, 0, 20)
end end
end end
if Keybind:CheckDown(Keybind.generic.rclick) then if Keybind:CheckDown(Keybind.generic.rclick) then
selecting_tile = nil selecting_tile = nil
end end
if selecting_tile ~= nil and selecting_tile ~= 0 and i == selecting_tile then if selecting_tile ~= nil and selecting_tile ~= 0 and i == selecting_tile then
love.graphics.setColor(1,0,1,1) love.graphics.setColor(1,0,1,1)
love.graphics.rectangle( love.graphics.rectangle(
"line", "line",
tile_x, tile_x,
tile_y, tile_y,
tileProperties.width, tileProperties.width,
tileProperties.height tileProperties.height
) )
love.graphics.setColor(1,1,1,1) love.graphics.setColor(1,1,1,1)
end end
position_x = position_x + 1 position_x = position_x + 1
if position_x > width then if position_x > width then
position_x = position_x - width position_x = position_x - width
position_y = position_y + 1 position_y = position_y + 1
end end
end end
love.graphics.rectangle( love.graphics.rectangle(
"line", "line",
(palette_scroll_x + 1) * (tileProperties.width+1), (palette_scroll_x + 1) * (tileProperties.width+1),
(palette_scroll_y + 1) * (tileProperties.height+1), (palette_scroll_y + 1) * (tileProperties.height+1),
1 + LevelData.tileset:getPixelWidth() * ((tileProperties.width+1) / tileProperties.width), 1 + LevelData.tileset:getPixelWidth() * ((tileProperties.width+1) / tileProperties.width),
1 + LevelData.tileset:getPixelHeight()* ((tileProperties.height+1) / tileProperties.height) 1 + LevelData.tileset:getPixelHeight()* ((tileProperties.height+1) / tileProperties.height)
) )
end end

View File

@ -1,56 +1,56 @@
Arrow = Entity:New(x,y) Arrow = Entity:New(x,y)
function Arrow:New(x,y,rotation,speed) function Arrow:New(x,y,rotation,speed)
local o = Entity:New(x,y) local o = Entity:New(x,y)
o.type = "arrow" o.type = "arrow"
o.pos = {x = x, y = y} o.pos = {x = x, y = y}
o.speed = speed or 10 o.speed = speed or 10
o.sprite_rotation = rotation or 0 o.sprite_rotation = rotation or 0
o.vel = { o.vel = {
x = o.speed * math.cos(o.sprite_rotation), x = o.speed * math.cos(o.sprite_rotation),
y = o.speed * math.sin(o.sprite_rotation) y = o.speed * math.sin(o.sprite_rotation)
} }
o.sprite_offset = {x = 13, y = 1} o.sprite_offset = {x = 13, y = 1}
o.stuck = false o.stuck = false
o.illuminated = true o.illuminated = true
-- animations -- animations
o.body = Animation:New(animation.kupo.arrow) o.body = Animation:New(animation.kupo.arrow)
o.boxCollision = { o.boxCollision = {
from = {x = -0.5, y = -0.5}, --gameworld pixels from = {x = -0.5, y = -0.5}, --gameworld pixels
to = {x = 0.5, y = 0.5} -- gameworld pixels to = {x = 0.5, y = 0.5} -- gameworld pixels
} }
table.insert(LoadedObjects.Entities,o) table.insert(LoadedObjects.Entities,o)
o.id = #LoadedObjects.Entities o.id = #LoadedObjects.Entities
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function Arrow:DrawBackground() function Arrow:DrawBackground()
self:Draw(self.body) self:Draw(self.body)
end end
function Arrow:DoPhysics() function Arrow:DoPhysics()
if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, LoadedObjects.Collisions) then if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, LoadedObjects.Collisions) then
self.pos.x = self.pos.x + self.vel.x self.pos.x = self.pos.x + self.vel.x
else else
self.stuck = true self.stuck = true
end end
if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, LoadedObjects.Collisions) then if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, LoadedObjects.Collisions) then
self.pos.y = self.pos.y + self.vel.y self.pos.y = self.pos.y + self.vel.y
else else
self.stuck = true self.stuck = true
end end
if self.stuck then if self.stuck then
self.pos.x = self.pos.x + self.vel.x * (2/3) self.pos.x = self.pos.x + self.vel.x * (2/3)
self.pos.y = self.pos.y + self.vel.y * (2/3) self.pos.y = self.pos.y + self.vel.y * (2/3)
self.vel.x = 0 self.vel.x = 0
self.vel.y = 0 self.vel.y = 0
end end
end end

View File

@ -1,112 +1,112 @@
CursedBook = Entity:New(x,y) CursedBook = Entity:New(x,y)
function CursedBook:New(x,y) function CursedBook:New(x,y)
local o = Entity:New(x,y) local o = Entity:New(x,y)
o.type = "cursed_book" o.type = "cursed_book"
-- behaviour -- behaviour
o.pos = {x = x, y = y} o.pos = {x = x, y = y}
o.speed = 0.01 o.speed = 0.01
o.range = 20 o.range = 20
o.target = {x = x, y = y} o.target = {x = x, y = y}
o.status = 0 o.status = 0
-- 0 - sleep -- 0 - sleep
-- 1 - getting up -- 1 - getting up
-- 2 - flying -- 2 - flying
-- 3 - attack windup -- 3 - attack windup
-- 4 - attack -- 4 - attack
o.spawn_range = 100 o.spawn_range = 100
o.attack_range = 50 o.attack_range = 50
-- animations -- animations
o.body = Animation:New(animation.cursed_book.spawn) o.body = Animation:New(animation.cursed_book.spawn)
o.sprite_tint = {0.7,0.7,0.7} o.sprite_tint = {0.7,0.7,0.7}
o:centerOffset(o.body) o:centerOffset(o.body)
o:getBoundingBox(o.body) o:getBoundingBox(o.body)
-- light -- light
o.light_range = 500 o.light_range = 500
o.light = Light:New(o.pos.x,o.pos.y,o.light_range,2,HEX2RGB("#fe00d1")) o.light = Light:New(o.pos.x,o.pos.y,o.light_range,2,HEX2RGB("#fe00d1"))
table.insert(LoadedObjects.Entities,o) table.insert(LoadedObjects.Entities,o)
o.id = #LoadedObjects.Entities o.id = #LoadedObjects.Entities
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function CursedBook:Smart() function CursedBook:Smart()
self.target.x = main_Player.pos.x - main_Player.target_offset.x self.target.x = main_Player.pos.x - main_Player.target_offset.x
self.target.y = main_Player.pos.y - main_Player.target_offset.y self.target.y = main_Player.pos.y - main_Player.target_offset.y
local distance_x = self.target.x - self.pos.x local distance_x = self.target.x - self.pos.x
local distance_y = self.target.y - self.pos.y local distance_y = self.target.y - self.pos.y
local angle = GetAngleFromVector(distance_x,distance_y) local angle = GetAngleFromVector(distance_x,distance_y)
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2) local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
if self.status == 0 then if self.status == 0 then
if distance < self.spawn_range then if distance < self.spawn_range then
self.status = 1 self.status = 1
end end
elseif self.status == -1 then elseif self.status == -1 then
if distance < self.range then if distance < self.range then
self.vel.x = 0 self.vel.x = 0
self.vel.y = 0 self.vel.y = 0
else else
self.vel.x = math.cos(angle)*self.speed*distance self.vel.x = math.cos(angle)*self.speed*distance
self.vel.y = math.sin(angle)*self.speed*distance self.vel.y = math.sin(angle)*self.speed*distance
end end
elseif self.status == 2 then elseif self.status == 2 then
if distance < self.attack_range then if distance < self.attack_range then
self.status = 3 self.status = 3
end end
elseif self.status == 4 then elseif self.status == 4 then
end end
end end
function CursedBook:HandleAnimation() function CursedBook:HandleAnimation()
if self.status == 1 then if self.status == 1 then
if self.body.path == "assets/entities/cursed_book/spawn" then if self.body.path == "assets/entities/cursed_book/spawn" then
self.body.speed = 1/3 self.body.speed = 1/3
local tint = 0.7 + 0.3 * (self.body.frame-1)/self.body.frames local tint = 0.7 + 0.3 * (self.body.frame-1)/self.body.frames
self.sprite_tint = {tint,tint,tint} self.sprite_tint = {tint,tint,tint}
if self.body.frame == self.body.frames then if self.body.frame == self.body.frames then
self.status = 2 self.status = 2
self.body = self.body:ChangeTo(animation.cursed_book.flying) self.body = self.body:ChangeTo(animation.cursed_book.flying)
self.sprite_tint = {1,1,1} self.sprite_tint = {1,1,1}
--self:getBoundingBox(self.body,2,2,-2,-2) --self:getBoundingBox(self.body,2,2,-2,-2)
self:centerOffset(self.body) self:centerOffset(self.body)
end end
end end
elseif self.status == 3 then elseif self.status == 3 then
if self.body.path == "assets/entities/cursed_book/flying" then if self.body.path == "assets/entities/cursed_book/flying" then
self.body = self.body:ChangeTo(animation.cursed_book.attack_transition) self.body = self.body:ChangeTo(animation.cursed_book.attack_transition)
self.body.speed = 1/3 self.body.speed = 1/3
self:centerOffset(self.body) self:centerOffset(self.body)
if self.body.frame == self.body.frames then if self.body.frame == self.body.frames then
self.status = 4 self.status = 4
self.body = self.body:ChangeTo(animation.cursed_book.attack_loop) self.body = self.body:ChangeTo(animation.cursed_book.attack_loop)
self:centerOffset(self.body) self:centerOffset(self.body)
end end
end end
end end
self.body:Animate() self.body:Animate()
self:Draw(self.body) self:Draw(self.body)
end end
function CursedBook:DoPhysics() function CursedBook:DoPhysics()
if self.isFlying then if self.isFlying then
local random_x = math.random(-4, 4)/100 local random_x = math.random(-4, 4)/100
local random_y = math.random(-4, 4)/100 local random_y = math.random(-4, 4)/100
self.vel.x = self.vel.x + random_x self.vel.x = self.vel.x + random_x
self.vel.y = self.vel.y + random_y self.vel.y = self.vel.y + random_y
end end
-- move -- move
self:CollisionMove() self:CollisionMove()
self:LightAdjust() self:LightAdjust()
end end
function CursedBook:Debug() function CursedBook:Debug()
@ -115,5 +115,5 @@ function CursedBook:Debug()
love.graphics.circle("line", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, self.spawn_range) love.graphics.circle("line", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, self.spawn_range)
love.graphics.setColor(1,0,0) love.graphics.setColor(1,0,0)
love.graphics.circle("line", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, self.attack_range) love.graphics.circle("line", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, self.attack_range)
Entity.Debug(self) Entity.Debug(self)
end end

View File

@ -1,33 +1,33 @@
Decoration = Entity:New(x,y) Decoration = Entity:New(x,y)
function Decoration:New(x,y,animation,lightRange) function Decoration:New(x,y,animation,lightRange)
local o = Entity:New(x,y) local o = Entity:New(x,y)
o.type = "decoration" o.type = "decoration"
o.pos = {x = x, y = y} o.pos = {x = x, y = y}
-- animations -- animations
o.body = Animation:New(animation) o.body = Animation:New(animation)
o:centerOffset(o.body) o:centerOffset(o.body)
o:getBoundingBox(o.body) o:getBoundingBox(o.body)
if lightRange ~= nil then if lightRange ~= nil then
o.lightRange = lightRange o.lightRange = lightRange
o.light = Light:New(o.pos.x,o.pos.y,o.lightRange) o.light = Light:New(o.pos.x,o.pos.y,o.lightRange)
end end
table.insert(LoadedObjects.Entities,o) table.insert(LoadedObjects.Entities,o)
o.id = #LoadedObjects.Entities o.id = #LoadedObjects.Entities
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function Decoration:HandleAnimation() function Decoration:HandleAnimation()
self.body:Animate() self.body:Animate()
self:Draw(self.body) self:Draw(self.body)
end end
function Decoration:DoPhysics() function Decoration:DoPhysics()

View File

@ -1,115 +1,115 @@
Fairy = Entity:New(x,y) Fairy = Entity:New(x,y)
function Fairy:New(x,y) function Fairy:New(x,y)
local o = Entity:New(x,y) local o = Entity:New(x,y)
o.type = "fairy" o.type = "fairy"
-- behaviour -- behaviour
o.pos = {x = x, y = y} o.pos = {x = x, y = y}
o.speed = 1.4 o.speed = 1.4
o.range = 20 o.range = 20
o.vision_range = 120 o.vision_range = 120
o.target = {x = x, y = y} o.target = {x = x, y = y}
o.hover_distance = 60 o.hover_distance = 60
-- animations -- animations
o.body = Animation:New(animation.fairy.flying) o.body = Animation:New(animation.fairy.flying)
o:centerOffset(o.body) o:centerOffset(o.body)
o:getBoundingBox(o.body) o:getBoundingBox(o.body)
-- light -- light
o.light_range = 80 o.light_range = 80
o.light = Light:New(o.pos.x,o.pos.y,o.light_range,nil,HEX2RGB("#fed100")) o.light = Light:New(o.pos.x,o.pos.y,o.light_range,nil,HEX2RGB("#fed100"))
-- timer -- timer
o.particle_timer = 0 o.particle_timer = 0
o.particle_time = 5 o.particle_time = 5
table.insert(LoadedObjects.Entities,o) table.insert(LoadedObjects.Entities,o)
o.id = #LoadedObjects.Entities o.id = #LoadedObjects.Entities
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function Fairy:Smart() function Fairy:Smart()
if self:CheckVisionLine(main_Player,self.vision_range) then if self:CheckVisionLine(main_Player,self.vision_range) then
self.target.x = main_Player.pos.x + main_Player.target_offset.x self.target.x = main_Player.pos.x + main_Player.target_offset.x
self.target.y = main_Player.pos.y + main_Player.target_offset.y self.target.y = main_Player.pos.y + main_Player.target_offset.y
local below = 1 local below = 1
while not isThereObjectAt( while not isThereObjectAt(
self.target.x, self.target.x,
self.target.y + below * game.scale, self.target.y + below * game.scale,
LoadedObjects.Collisions LoadedObjects.Collisions
) do ) do
below = below + 1 below = below + 1
if below >= self.hover_distance then break end if below >= self.hover_distance then break end
end end
local top = 1 local top = 1
while not isThereObjectAt( while not isThereObjectAt(
self.target.x, self.target.x,
self.target.y - top * game.scale, self.target.y - top * game.scale,
LoadedObjects.Collisions LoadedObjects.Collisions
) do ) do
top = top + 1 top = top + 1
if top >= self.hover_distance then break end if top >= self.hover_distance then break end
end end
self.target.y = self.target.y - top + below self.target.y = self.target.y - top + below
end end
local distance_x = self.target.x - self.pos.x local distance_x = self.target.x - self.pos.x
local distance_y = self.target.y - self.pos.y local distance_y = self.target.y - self.pos.y
local angle = GetAngleFromVector(distance_x,distance_y) local angle = GetAngleFromVector(distance_x,distance_y)
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2) local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
if distance < self.range then if distance < self.range then
self.vel.x = self.vel.x * 0.9 self.vel.x = self.vel.x * 0.9
self.vel.y = self.vel.y * 0.9 self.vel.y = self.vel.y * 0.9
else else
self.vel.x = math.cos(angle)*self.speed self.vel.x = math.cos(angle)*self.speed
self.vel.y = math.sin(angle)*self.speed self.vel.y = math.sin(angle)*self.speed
end end
self.particle_timer = self.particle_timer + 1 self.particle_timer = self.particle_timer + 1
if self.particle_timer >= self.particle_time then if self.particle_timer >= self.particle_time then
self.particle_timer = 0 self.particle_timer = 0
local particle_data = { local particle_data = {
animation = animation.particle.simple, animation = animation.particle.simple,
sprite_tint = HEX2RGB("#fed100"), sprite_tint = HEX2RGB("#fed100"),
direction = angle-math.rad(180+math.random(60)-30), direction = angle-math.rad(180+math.random(60)-30),
speed = 0.8*(distance/50), speed = 0.8*(distance/50),
speed_increase = -0.01, speed_increase = -0.01,
} }
Particle:New(self.pos.x,self.pos.y,particle_data) Particle:New(self.pos.x,self.pos.y,particle_data)
end end
end end
function Fairy:HandleAnimation() function Fairy:HandleAnimation()
self.body:Animate() self.body:Animate()
--if self:isCollidingWith(main_Player) then self.sprite_tint = {1,0,0} else self.sprite_tint = {1,1,1} end --if self:isCollidingWith(main_Player) then self.sprite_tint = {1,0,0} else self.sprite_tint = {1,1,1} end
self:Draw(self.body) self:Draw(self.body)
end end
function Fairy:DoPhysics() function Fairy:DoPhysics()
local random_x = math.random(-4, 4)/10 local random_x = math.random(-4, 4)/10
local random_y = math.random(-4, 4)/10 local random_y = math.random(-4, 4)/10
self.vel.x = self.vel.x + random_x self.vel.x = self.vel.x + random_x
self.vel.y = self.vel.y + random_y self.vel.y = self.vel.y + random_y
self:CollisionMove() self:CollisionMove()
self.vel.x = 0 self.vel.x = 0
self.vel.y = 0 self.vel.y = 0
self:LightAdjust() self:LightAdjust()
end end
function Fairy:Debug() function Fairy:Debug()
Entity.Debug(self) Entity.Debug(self)
self:CheckVisionLineDebug(main_Player,self.vision_range) self:CheckVisionLineDebug(main_Player,self.vision_range)
end end

View File

@ -1,40 +1,40 @@
HookAnchor = Entity:New(x,y) HookAnchor = Entity:New(x,y)
function HookAnchor:New(x,y,hookDistance) function HookAnchor:New(x,y,hookDistance)
local o = Entity:New(x,y) local o = Entity:New(x,y)
o.type = "hook_anchor" o.type = "hook_anchor"
o.pos = {x = x, y = y} o.pos = {x = x, y = y}
o.hookDistance = hookDistance or 100 o.hookDistance = hookDistance or 100
-- animations -- animations
o.body = Animation:New(animation.fairy.flying) o.body = Animation:New(animation.fairy.flying)
o:centerOffset(o.body) o:centerOffset(o.body)
o:getBoundingBox(o.body) o:getBoundingBox(o.body)
table.insert(LoadedObjects.Entities,o) table.insert(LoadedObjects.Entities,o)
o.id = #LoadedObjects.Entities o.id = #LoadedObjects.Entities
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function HookAnchor:HandleAnimation() function HookAnchor:HandleAnimation()
self.body:Animate() self.body:Animate()
self:Draw(self.body) self:Draw(self.body)
end end
function HookAnchor:DrawBackground() function HookAnchor:DrawBackground()
Entity.DrawBackground(self) Entity.DrawBackground(self)
love.graphics.setColor(1,1,1,0) love.graphics.setColor(1,1,1,0)
love.graphics.circle( love.graphics.circle(
"fill", "fill",
-Camera.pos.x + self.pos.x, -Camera.pos.x + self.pos.x,
-Camera.pos.y + self.pos.y, -Camera.pos.y + self.pos.y,
self.hookDistance self.hookDistance
) )
end end
function HookAnchor:DoPhysics() function HookAnchor:DoPhysics()
@ -42,5 +42,5 @@ end
function Fairy:Debug() function Fairy:Debug()
Entity.Debug(self) Entity.Debug(self)
end end

View File

@ -1,161 +1,161 @@
Kupo = Entity:New(x,y) Kupo = Entity:New(x,y)
function Kupo:New(x,y) function Kupo:New(x,y)
local o = Entity:New(x,y) local o = Entity:New(x,y)
o.type = "kupo" o.type = "kupo"
o.pos = {x = x, y = y} o.pos = {x = x, y = y}
o.speed = 20 o.speed = 20
o.range = 200 o.range = 200
o.target = {x = x, y = y} o.target = {x = x, y = y}
o.sprite_offset = {x = 8, y = 5} o.sprite_offset = {x = 8, y = 5}
-- animations -- animations
o.body = Animation:New(animation.kupo.body) o.body = Animation:New(animation.kupo.body)
o.bow = Animation:New(animation.kupo.bow) o.bow = Animation:New(animation.kupo.bow)
-- bow -- bow
o.bow_flip = 1 o.bow_flip = 1
o.bow_rotation = 0 o.bow_rotation = 0
o.bow_frame = 1 o.bow_frame = 1
o.bow_subframe = 1 o.bow_subframe = 1
o.bow_aim_frame = 0 o.bow_aim_frame = 0
o.bow_speed = 1/10 o.bow_speed = 1/10
o.bow_frames = 6 o.bow_frames = 6
o.bow_extraframes = 18 o.bow_extraframes = 18
o.bow_aim_frames = 8 o.bow_aim_frames = 8
o.hostile = true o.hostile = true
o.lightRange = o.range/2 o.lightRange = o.range/2
o.light = Light:New(o.pos.x,o.pos.y,o.lightRange) o.light = Light:New(o.pos.x,o.pos.y,o.lightRange)
table.insert(LoadedObjects.Entities,o) table.insert(LoadedObjects.Entities,o)
o.id = #LoadedObjects.Entities o.id = #LoadedObjects.Entities
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function Kupo:Smart() function Kupo:Smart()
self.light.pos.x = self.pos.x-self.target_offset.x self.light.pos.x = self.pos.x-self.target_offset.x
self.light.pos.y = self.pos.y-self.target_offset.y self.light.pos.y = self.pos.y-self.target_offset.y
self.target.x = main_Player.pos.x - main_Player.target_offset.x self.target.x = main_Player.pos.x - main_Player.target_offset.x
self.target.y = main_Player.pos.y - main_Player.target_offset.y self.target.y = main_Player.pos.y - main_Player.target_offset.y
local distance_x = self.target.x - self.pos.x local distance_x = self.target.x - self.pos.x
local distance_y = self.target.y - self.pos.y local distance_y = self.target.y - self.pos.y
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2) local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
local angle = GetAngleFromVector(distance_x,distance_y) local angle = GetAngleFromVector(distance_x,distance_y)
self.draw_bow = false self.draw_bow = false
if distance <= self.range then if distance <= self.range then
if self.hostile == true then if self.hostile == true then
self.draw_bow = true self.draw_bow = true
-- fix so it can rotate from 0 to 360 -- fix so it can rotate from 0 to 360
if math.deg(self.bow_rotation - angle) < 0 then if math.deg(self.bow_rotation - angle) < 0 then
self.bow_rotation = self.bow_rotation + math.rad(360) self.bow_rotation = self.bow_rotation + math.rad(360)
end end
-- fix so it can rotate from 360 to 0 -- fix so it can rotate from 360 to 0
if math.deg(self.bow_rotation - angle) > 180 then if math.deg(self.bow_rotation - angle) > 180 then
self.bow_rotation = self.bow_rotation - math.rad(360) self.bow_rotation = self.bow_rotation - math.rad(360)
end end
-- actual rotation -- actual rotation
if self.bow_rotation < angle then if self.bow_rotation < angle then
self.bow_rotation = self.bow_rotation + math.rad(2) self.bow_rotation = self.bow_rotation + math.rad(2)
else else
self.bow_rotation = self.bow_rotation - math.rad(2) self.bow_rotation = self.bow_rotation - math.rad(2)
end end
--set in place --set in place
if math.abs(math.deg(self.bow_rotation) - math.deg(angle)) < 2 then if math.abs(math.deg(self.bow_rotation) - math.deg(angle)) < 2 then
self.bow_rotation = angle self.bow_rotation = angle
end end
-- holding tight dispersion -- also affects arrows -- holding tight dispersion -- also affects arrows
if self.bow_rotation == angle then if self.bow_rotation == angle then
self.bow_rotation = self.bow_rotation + math.rad(math.random(math.abs(math.floor(self.bow_frame-self.bow_aim_frames-self.bow_frames)/2))) self.bow_rotation = self.bow_rotation + math.rad(math.random(math.abs(math.floor(self.bow_frame-self.bow_aim_frames-self.bow_frames)/2)))
end end
-- AIMING AI -- AIMING AI
self.bow_subframe = self.bow_subframe + current_dt self.bow_subframe = self.bow_subframe + current_dt
if self.bow_subframe > self.bow_speed then if self.bow_subframe > self.bow_speed then
self.bow_subframe = self.bow_subframe - self.bow_speed self.bow_subframe = self.bow_subframe - self.bow_speed
if self.bow_frame == 3 then if self.bow_frame == 3 then
self.bow_aim_frame = self.bow_aim_frame + 1 self.bow_aim_frame = self.bow_aim_frame + 1
if self.bow_aim_frame > self.bow_aim_frames then if self.bow_aim_frame > self.bow_aim_frames then
self.bow_aim_frame = self.bow_aim_frame - self.bow_aim_frames self.bow_aim_frame = self.bow_aim_frame - self.bow_aim_frames
self.bow_frame = self.bow_frame + 1 self.bow_frame = self.bow_frame + 1
Arrow:New(self.pos.x,self.pos.y,self.bow_rotation,10) Arrow:New(self.pos.x,self.pos.y,self.bow_rotation,10)
end end
else else
self.bow_frame = self.bow_frame + 1 self.bow_frame = self.bow_frame + 1
end end
if self.bow_frame > self.bow_frames + self.bow_extraframes then if self.bow_frame > self.bow_frames + self.bow_extraframes then
self.bow_frame = self.bow_frame - self.bow_frames - self.bow_extraframes self.bow_frame = self.bow_frame - self.bow_frames - self.bow_extraframes
end end
end end
end end
else else
self.bow_frame = 6 self.bow_frame = 6
-- rest bow animation -- rest bow animation
if distance_x > 0 then if distance_x > 0 then
if self.bow_rotation > math.rad(45) then if self.bow_rotation > math.rad(45) then
self.bow_rotation = self.bow_rotation - math.rad(3) self.bow_rotation = self.bow_rotation - math.rad(3)
elseif self.bow_rotation < math.rad(45) then elseif self.bow_rotation < math.rad(45) then
self.bow_rotation = self.bow_rotation + math.rad(3) self.bow_rotation = self.bow_rotation + math.rad(3)
end end
-- set in place -- set in place
if math.abs(math.deg(self.bow_rotation) - 45) < 3 then if math.abs(math.deg(self.bow_rotation) - 45) < 3 then
self.bow_rotation = math.rad(45) self.bow_rotation = math.rad(45)
end end
self.sprite_flip.x = 1 self.sprite_flip.x = 1
else else
if self.bow_rotation > math.rad(135) then if self.bow_rotation > math.rad(135) then
self.bow_rotation = self.bow_rotation - math.rad(3) self.bow_rotation = self.bow_rotation - math.rad(3)
elseif self.bow_rotation < math.rad(135) then elseif self.bow_rotation < math.rad(135) then
self.bow_rotation = self.bow_rotation + math.rad(3) self.bow_rotation = self.bow_rotation + math.rad(3)
end end
-- set in place -- set in place
if math.abs(math.deg(self.bow_rotation) - 135) < 3 then if math.abs(math.deg(self.bow_rotation) - 135) < 3 then
self.bow_rotation = math.rad(135) self.bow_rotation = math.rad(135)
end end
self.sprite_flip.x = -1 self.sprite_flip.x = -1
end end
end end
self.angle = angle self.angle = angle
end end
function Kupo:HandleAnimation() function Kupo:HandleAnimation()
local distance_x = self.target.x - self.pos.x local distance_x = self.target.x - self.pos.x
local distance_y = self.target.y - self.pos.y local distance_y = self.target.y - self.pos.y
if distance_x > 0 then if distance_x > 0 then
self.sprite_flip.x = 1 self.sprite_flip.x = 1
else else
self.sprite_flip.x = -1 self.sprite_flip.x = -1
end end
-- flip sprite to look in the direction is moving -- flip sprite to look in the direction is moving
if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end
self.body:Animate() self.body:Animate()
self:Draw(self.body) self:Draw(self.body)
if self.draw_bow == true then if self.draw_bow == true then
self.bow:DrawFrame( self.bow:DrawFrame(
math.min(self.bow_frame,self.bow_frames), math.min(self.bow_frame,self.bow_frames),
self.pos.x + ( 8 * math.sin(self.bow_rotation)), self.pos.x + ( 8 * math.sin(self.bow_rotation)),
self.pos.y + (2 - 6 * math.cos(self.bow_rotation)), self.pos.y + (2 - 6 * math.cos(self.bow_rotation)),
self.bow_rotation self.bow_rotation
) )
end end
end end
function Kupo:DoPhysics() function Kupo:DoPhysics()
self:CollisionMove() self:CollisionMove()
end end

View File

@ -1,100 +1,100 @@
Particle = Entity:New(x,y) Particle = Entity:New(x,y)
LoadedObjects.Particles = {} LoadedObjects.Particles = {}
function Particle:New(x,y,particle_data) function Particle:New(x,y,particle_data)
local o = Entity:New(x,y) local o = Entity:New(x,y)
o.pos = {x = x, y = y} o.pos = {x = x, y = y}
o.speed = particle_data.speed or 0 o.speed = particle_data.speed or 0
o.direction = particle_data.direction or o.direction o.direction = particle_data.direction or o.direction
o.sprite_rotation = particle_data.sprite_rotation or o.sprite_rotation o.sprite_rotation = particle_data.sprite_rotation or o.sprite_rotation
o.sprite_offset = particle_data.sprite_offset or o.sprite_offset o.sprite_offset = particle_data.sprite_offset or o.sprite_offset
o.sprite_scale = particle_data.sprite_scale or o.sprite_scale o.sprite_scale = particle_data.sprite_scale or o.sprite_scale
o.sprite_tint = particle_data.sprite_tint or o.sprite_tint o.sprite_tint = particle_data.sprite_tint or o.sprite_tint
o.sprite_alpha = particle_data.sprite_alpha or o.sprite_alpha o.sprite_alpha = particle_data.sprite_alpha or o.sprite_alpha
o.sprite_alpha_base = o.sprite_alpha o.sprite_alpha_base = o.sprite_alpha
o.sprite_flip = particle_data.sprite_flip or o.sprite_flip o.sprite_flip = particle_data.sprite_flip or o.sprite_flip
o.animation_active = particle_data.animation_active or false o.animation_active = particle_data.animation_active or false
o.time = 0.5 o.time = 0.5
o.timer = 0 o.timer = 0
o.vel = { o.vel = {
x = o.speed * math.cos(o.direction), x = o.speed * math.cos(o.direction),
y = o.speed * math.sin(o.direction) y = o.speed * math.sin(o.direction)
} }
o.speed_increase = particle_data.speed_increase or 0 o.speed_increase = particle_data.speed_increase or 0
if particle_data.light ~= nil then if particle_data.light ~= nil then
o.lightRange = particle_data.light o.lightRange = particle_data.light
local flicker = particle_data.light_flicker or nil local flicker = particle_data.light_flicker or nil
local color = particle_data.light_color or nil local color = particle_data.light_color or nil
o.light = Light:New(o.pos.x,o.pos.y,o.lightRange,flicker,color) o.light = Light:New(o.pos.x,o.pos.y,o.lightRange,flicker,color)
end end
-- animations -- animations
if particle_data.animation ~= nil then if particle_data.animation ~= nil then
o.body = Animation:New(particle_data.animation) o.body = Animation:New(particle_data.animation)
o:centerOffset(o.body) o:centerOffset(o.body)
o:getBoundingBox(o.body) o:getBoundingBox(o.body)
if not o.animation_active then if not o.animation_active then
o.body.speed = 0 o.body.speed = 0
end end
end end
table.insert(LoadedObjects.Particles,o) table.insert(LoadedObjects.Particles,o)
o.id = #LoadedObjects.Particles o.id = #LoadedObjects.Particles
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function Particle:Kill() function Particle:Kill()
if self.light ~= nil then if self.light ~= nil then
self.light:Kill() self.light:Kill()
end end
if self.id ~= nil then if self.id ~= nil then
for _, e in pairs(LoadedObjects.Particles) do for _, e in pairs(LoadedObjects.Particles) do
if e.id > self.id then if e.id > self.id then
e.id = e.id - 1 e.id = e.id - 1
end end
end end
table.remove(LoadedObjects.Particles,self.id) table.remove(LoadedObjects.Particles,self.id)
end end
self = nil self = nil
end end
function Particle:HandleAnimation() function Particle:HandleAnimation()
self.timer = self.timer + current_dt self.timer = self.timer + current_dt
self.sprite_alpha = self.sprite_alpha_base*(self.time-self.timer)/self.time self.sprite_alpha = self.sprite_alpha_base*(self.time-self.timer)/self.time
if self.light ~= nil then if self.light ~= nil then
self:LightAdjust() self:LightAdjust()
self.light.range = self.lightRange * self.sprite_alpha/2 self.light.range = self.lightRange * self.sprite_alpha/2
end end
if self.sprite_alpha < 0 then self:Kill() end if self.sprite_alpha < 0 then self:Kill() end
if self.body ~= nil then if self.body ~= nil then
self.body:Animate() self.body:Animate()
self:Draw(self.body) self:Draw(self.body)
end end
end end
function Particle:DoPhysics() function Particle:DoPhysics()
-- adjust speed -- adjust speed
if self.speed_increase ~= 0 then if self.speed_increase ~= 0 then
self.speed = self.speed + self.speed_increase self.speed = self.speed + self.speed_increase
self.vel.x = self.speed * math.cos(self.direction) self.vel.x = self.speed * math.cos(self.direction)
self.vel.y = self.speed * math.sin(self.direction) self.vel.y = self.speed * math.sin(self.direction)
end end
-- move -- move
self:CollisionMove() self:CollisionMove()
end end
function Particle:Debug() function Particle:Debug()
-- draw center CYAN -- draw center CYAN
love.graphics.setColor(0,1,1) love.graphics.setColor(0,1,1)
love.graphics.circle("fill", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, 1) love.graphics.circle("fill", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, 1)
end end

View File

@ -1,316 +1,316 @@
Player = Entity:New(x,y) Player = Entity:New(x,y)
function Player:New(x,y) function Player:New(x,y)
local o = Entity:New(x,y) local o = Entity:New(x,y)
o.type = "player" o.type = "player"
-- physics -- physics
o.moveSpeed = 1.3 -- gameworld pixels o.moveSpeed = 1.3 -- gameworld pixels
o.zeroSpeed = 0.01 -- gameworld pixels o.zeroSpeed = 0.01 -- gameworld pixels
o.move_x = 0 -- gameworld pixels o.move_x = 0 -- gameworld pixels
o.airFriction = 0.01 -- gameworld pixels o.airFriction = 0.01 -- gameworld pixels
o.groundFriction = 0.3 -- gameworld pixels o.groundFriction = 0.3 -- gameworld pixels
o.jumpImpulse = 3.5 -- gameworld pixels o.jumpImpulse = 3.5 -- gameworld pixels
o.coyoteAmount = 5 -- int o.coyoteAmount = 5 -- int
o.coyoteValue = 5 -- frames o.coyoteValue = 5 -- frames
o.dashCooldownTime = 0.1 -- seconds o.dashCooldownTime = 0.1 -- seconds
o.dashCooldownTimer = 0 -- seconds o.dashCooldownTimer = 0 -- seconds
-- dash values -- dash values
o.dashTimer = 0 -- seconds o.dashTimer = 0 -- seconds
o.dashTime = 0.15 -- seconds o.dashTime = 0.15 -- seconds
o.dashDistance = 40 -- gameworld pixels o.dashDistance = 40 -- gameworld pixels
o.dashSpeed = o.dashDistance / (o.dashTime*60) -- pixels o.dashSpeed = o.dashDistance / (o.dashTime*60) -- pixels
o.dashCount = 1 -- int o.dashCount = 1 -- int
o.dashAmount = 10 -- int o.dashAmount = 10 -- int
-- hook values -- hook values
o.hookAnchor = { o.hookAnchor = {
x = nil, x = nil,
y = nil y = nil
} }
o.lightRange = 40 -- screen pixels o.lightRange = 40 -- screen pixels
-- status -- status
o.isDashing = false o.isDashing = false
o.isJumping = false o.isJumping = false
o.isHooked = false o.isHooked = false
o.isOnGround = true o.isOnGround = true
o.isOnLadder = false o.isOnLadder = false
o.canJump = true o.canJump = true
o.canFall = true o.canFall = true
o.canFriction = true o.canFriction = true
o.maskType = animation.moth_mask o.maskType = animation.moth_mask
o.anchorRespawn = { o.anchorRespawn = {
x = o.pos.x, x = o.pos.x,
y = o.pos.y y = o.pos.y
} }
-- sprite -- sprite
o.target_offset = {x = 0, y = 0} o.target_offset = {x = 0, y = 0}
o.body = Animation:New(animation.nancy.idle) o.body = Animation:New(animation.nancy.idle)
o.mask = Animation:New(animation.moth_mask.idle) o.mask = Animation:New(animation.moth_mask.idle)
o:centerOffset(o.body) o:centerOffset(o.body)
o:getBoundingBox(o.body,0,3,-1,-3) o:getBoundingBox(o.body,0,3,-1,-3)
-- lights -- lights
o.light = Light:New(o.pos.x,o.pos.y,o.lightRange) o.light = Light:New(o.pos.x,o.pos.y,o.lightRange)
table.insert(LoadedObjects.Entities,o) table.insert(LoadedObjects.Entities,o)
o.id = #LoadedObjects.Entities o.id = #LoadedObjects.Entities
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function Player:Smart() function Player:Smart()
self:LightAdjust(self.target_offset.x,self.target_offset.y) self:LightAdjust(self.target_offset.x,self.target_offset.y)
-- reset coyoteValue -- reset coyoteValue
if self.isOnGround then if self.isOnGround then
self.coyoteValue = self.coyoteAmount self.coyoteValue = self.coyoteAmount
elseif self.coyoteValue > 0 then elseif self.coyoteValue > 0 then
self.coyoteValue = self.coyoteValue - 1 self.coyoteValue = self.coyoteValue - 1
end end
if self.dashTimer <= 0 then if self.dashTimer <= 0 then
-- horizontal movement -- horizontal movement
if Keybind:CheckDown(Keybind.move.left) then if Keybind:CheckDown(Keybind.move.left) then
self.move_x = -self.moveSpeed self.move_x = -self.moveSpeed
elseif Keybind:CheckDown(Keybind.move.right) then elseif Keybind:CheckDown(Keybind.move.right) then
self.move_x = self.moveSpeed self.move_x = self.moveSpeed
end end
-- jump if on ground (coyotevalue) -- jump if on ground (coyotevalue)
if Keybind:CheckDown(Keybind.move.jump) then if Keybind:CheckDown(Keybind.move.jump) then
if self.coyoteValue > 0 then if self.coyoteValue > 0 then
self.vel.y = -self.jumpImpulse self.vel.y = -self.jumpImpulse
self.coyoteValue = 0 self.coyoteValue = 0
end end
end end
end end
-- dash timer -- dash timer
self.dashCooldownTimer = math.max(0,self.dashCooldownTimer - current_dt) self.dashCooldownTimer = math.max(0,self.dashCooldownTimer - current_dt)
-- try to dash -- try to dash
if Keybind:CheckDown(Keybind.move.dash) then if Keybind:CheckDown(Keybind.move.dash) then
if self.dashCooldownTimer == 0 if self.dashCooldownTimer == 0
and not self.isDashing and not self.isDashing
and self.dashCount > 0 then and self.dashCount > 0 then
self:Unhook() self:Unhook()
-- state player -- state player
self.isDashing = true self.isDashing = true
self.dashCount = self.dashCount - 1 self.dashCount = self.dashCount - 1
-- get dash direction -- get dash direction
local vertical = 0 local vertical = 0
if Keybind:CheckDown(Keybind.move.down) then vertical = vertical + 1 end if Keybind:CheckDown(Keybind.move.down) then vertical = vertical + 1 end
if Keybind:CheckDown(Keybind.move.up) then vertical = vertical - 1 end if Keybind:CheckDown(Keybind.move.up) then vertical = vertical - 1 end
local horizontal = 0 local horizontal = 0
if Keybind:CheckDown(Keybind.move.right) then horizontal = horizontal + 1 end if Keybind:CheckDown(Keybind.move.right) then horizontal = horizontal + 1 end
if Keybind:CheckDown(Keybind.move.left) then horizontal = horizontal - 1 end if Keybind:CheckDown(Keybind.move.left) then horizontal = horizontal - 1 end
-- if no direction, then dash forward -- if no direction, then dash forward
if horizontal == 0 and vertical == 0 then if horizontal == 0 and vertical == 0 then
horizontal = self.sprite_flip.x horizontal = self.sprite_flip.x
end end
-- set dash values -- set dash values
self.dashDirection = GetAngleFromVector(horizontal, vertical) self.dashDirection = GetAngleFromVector(horizontal, vertical)
self.dashTimer = self.dashTime self.dashTimer = self.dashTime
end end
else else
-- not dashing! -- not dashing!
self.isDashing = false self.isDashing = false
end end
if Keybind:CheckPressed(Keybind.move.hook) then if Keybind:CheckPressed(Keybind.move.hook) then
if self.isHooked then if self.isHooked then
self:Unhook() self:Unhook()
else else
local anchor = self:CheckNearest("hook_anchor",self.hookDistance) local anchor = self:CheckNearest("hook_anchor",self.hookDistance)
if anchor then if anchor then
self.isHooked = true self.isHooked = true
self.hookDistance = anchor.hookDistance self.hookDistance = anchor.hookDistance
self.hookAnchor = { self.hookAnchor = {
x = anchor.pos.x, x = anchor.pos.x,
y = anchor.pos.y y = anchor.pos.y
} }
end end
end end
end end
end end
function Player:DoPhysics() function Player:DoPhysics()
if self.dashTimer <= 0 then if self.dashTimer <= 0 then
if self.isOnGround then if self.isOnGround then
self.vel.x = self.vel.x * (1-self.groundFriction) self.vel.x = self.vel.x * (1-self.groundFriction)
else else
self.vel.x = self.vel.x * (1-self.airFriction) self.vel.x = self.vel.x * (1-self.airFriction)
end end
self.vel.y = self.vel.y * (1-self.airFriction) self.vel.y = self.vel.y * (1-self.airFriction)
if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end
end end
-- reset state -- reset state
self.canFall = true self.canFall = true
self.isOnGround = false self.isOnGround = false
-- adjust timers -- adjust timers
self.dashTimer = self.dashTimer - current_dt self.dashTimer = self.dashTimer - current_dt
-- DASH STATE -- DASH STATE
if self.dashTimer > 0 then if self.dashTimer > 0 then
self.canFall = false self.canFall = false
-- dash particle -- dash particle
local particle_data = { local particle_data = {
animation = self.body, animation = self.body,
sprite_tint = HEX2RGB("#fed100"), sprite_tint = HEX2RGB("#fed100"),
sprite_alpha = 0.5, sprite_alpha = 0.5,
sprite_flip = { sprite_flip = {
x = self.sprite_flip.x, x = self.sprite_flip.x,
y = self.sprite_flip.y y = self.sprite_flip.y
} }
} }
Particle:New(self.pos.x,self.pos.y,particle_data) Particle:New(self.pos.x,self.pos.y,particle_data)
self.dashCooldownTimer = self.dashCooldownTime self.dashCooldownTimer = self.dashCooldownTime
-- dash movement -- dash movement
self.vel.x = self.dashSpeed * math.cos(self.dashDirection) self.vel.x = self.dashSpeed * math.cos(self.dashDirection)
self.vel.y = self.dashSpeed * math.sin(self.dashDirection) self.vel.y = self.dashSpeed * math.sin(self.dashDirection)
end end
-- hook state -- hook state
if self.isHooked then if self.isHooked then
local hook = Vector(self.pos.x, self.pos.y, self.hookAnchor.x, self.hookAnchor.y) local hook = Vector(self.pos.x, self.pos.y, self.hookAnchor.x, self.hookAnchor.y)
if GetVectorValue(hook) > self.hookDistance then if GetVectorValue(hook) > self.hookDistance then
local hook_angle = GetAngleFromVector(hook[1],hook[2])-math.rad(180) local hook_angle = GetAngleFromVector(hook[1],hook[2])-math.rad(180)
if Keybind:CheckDown(Keybind.move.right) then if Keybind:CheckDown(Keybind.move.right) then
hook_angle = hook_angle - math.rad(0.05) hook_angle = hook_angle - math.rad(0.05)
self.move_x = 0 self.move_x = 0
end end
if Keybind:CheckDown(Keybind.move.left) then if Keybind:CheckDown(Keybind.move.left) then
hook_angle = hook_angle + math.rad(0.05) hook_angle = hook_angle + math.rad(0.05)
self.move_x = 0 self.move_x = 0
end end
local particle_data = { local particle_data = {
animation = self.body, animation = self.body,
sprite_tint = HEX2RGB("#fed100"), sprite_tint = HEX2RGB("#fed100"),
sprite_alpha = 0.5, sprite_alpha = 0.5,
sprite_flip = { sprite_flip = {
x = self.sprite_flip.x, x = self.sprite_flip.x,
y = self.sprite_flip.y y = self.sprite_flip.y
} }
} }
Particle:New(self.pos.x,self.pos.y,particle_data) Particle:New(self.pos.x,self.pos.y,particle_data)
local pos_x = self.hookAnchor.x + self.hookDistance * math.cos(hook_angle) local pos_x = self.hookAnchor.x + self.hookDistance * math.cos(hook_angle)
local pos_y = self.hookAnchor.y + self.hookDistance * math.sin(hook_angle) local pos_y = self.hookAnchor.y + self.hookDistance * math.sin(hook_angle)
self.vel.x = self.vel.x + pos_x - self.pos.x self.vel.x = self.vel.x + pos_x - self.pos.x
self.vel.y = self.vel.y + pos_y - self.pos.y self.vel.y = self.vel.y + pos_y - self.pos.y
self.pos.x = pos_x self.pos.x = pos_x
self.pos.y = pos_y self.pos.y = pos_y
end end
end end
if self.canFall then if self.canFall then
-- not in dash -- not in dash
self.dashTimer = 0 self.dashTimer = 0
self.vel.y = self.vel.y + gravity self.vel.y = self.vel.y + gravity
end end
-- horizontal collision -- horizontal collision
if not self:isCollidingAt(self.pos.x + self.vel.x + self.move_x, self.pos.y, LoadedObjects.Collisions) then if not self:isCollidingAt(self.pos.x + self.vel.x + self.move_x, self.pos.y, LoadedObjects.Collisions) then
self.pos.x = self.pos.x + self.vel.x + self.move_x self.pos.x = self.pos.x + self.vel.x + self.move_x
else else
self.vel.x = 0 self.vel.x = 0
end end
-- vertical collision -- vertical collision
if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, LoadedObjects.Collisions) then if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, LoadedObjects.Collisions) then
self.pos.y = self.pos.y + self.vel.y self.pos.y = self.pos.y + self.vel.y
else else
if self.vel.y > 0 then if self.vel.y > 0 then
self.isOnGround = true self.isOnGround = true
self.dashCount = self.dashAmount self.dashCount = self.dashAmount
end end
self.vel.y = 0 self.vel.y = 0
end end
-- if u collision w hazard, respawn -- if u collision w hazard, respawn
if self:isCollidingAt(self.pos.x, self.pos.y, LoadedObjects.Hazards) then if self:isCollidingAt(self.pos.x, self.pos.y, LoadedObjects.Hazards) then
self:Respawn() self:Respawn()
end end
end end
function Player:Respawn() function Player:Respawn()
self.pos.x = self.anchorRespawn.x self.pos.x = self.anchorRespawn.x
self.pos.y = self.anchorRespawn.y self.pos.y = self.anchorRespawn.y
end end
function Player:HandleAnimation() function Player:HandleAnimation()
-- flip sprite to look in the direction is moving -- flip sprite to look in the direction is moving
if self.isHooked then if self.isHooked then
if self.vel.x ~= 0 then if self.vel.x ~= 0 then
self.sprite_flip.x = math.sign(self.vel.x) self.sprite_flip.x = math.sign(self.vel.x)
end end
elseif self.move_x ~= 0 then elseif self.move_x ~= 0 then
self.sprite_flip.x = math.sign(self.move_x) self.sprite_flip.x = math.sign(self.move_x)
end end
-- animation priority -- animation priority
if self.vel.y > 1.25 then if self.vel.y > 1.25 then
self.body = self.body:ChangeTo(animation.nancy.fall) self.body = self.body:ChangeTo(animation.nancy.fall)
self.mask = self.mask:ChangeTo(self.maskType.fall) self.mask = self.mask:ChangeTo(self.maskType.fall)
elseif self.vel.y < 0 then elseif self.vel.y < 0 then
self.body = self.body:ChangeTo(animation.nancy.jump) self.body = self.body:ChangeTo(animation.nancy.jump)
self.mask = self.mask:ChangeTo(self.maskType.jump) self.mask = self.mask:ChangeTo(self.maskType.jump)
elseif self.vel.x + self.move_x ~= 0 then elseif self.vel.x + self.move_x ~= 0 then
self.body = self.body:ChangeTo(animation.nancy.run) self.body = self.body:ChangeTo(animation.nancy.run)
self.mask = self.mask:ChangeTo(self.maskType.run) self.mask = self.mask:ChangeTo(self.maskType.run)
else else
self.body = self.body:ChangeTo(animation.nancy.idle) self.body = self.body:ChangeTo(animation.nancy.idle)
self.mask = self.mask:ChangeTo(self.maskType.idle) self.mask = self.mask:ChangeTo(self.maskType.idle)
end end
-- special case: idle animation gets slower by time -- special case: idle animation gets slower by time
if self.body.anim_path == animation.nancy.idle.path then if self.body.anim_path == animation.nancy.idle.path then
if self.body.anim_speed < 0.5 then if self.body.anim_speed < 0.5 then
self.body.anim_speed = self.body.anim_speed + 0.001 self.body.anim_speed = self.body.anim_speed + 0.001
end end
end end
if self.isHooked then if self.isHooked then
love.graphics.line( love.graphics.line(
-Camera.pos.x + self.pos.x, -Camera.pos.x + self.pos.x,
-Camera.pos.y + self.pos.y, -Camera.pos.y + self.pos.y,
-Camera.pos.x + self.hookAnchor.x, -Camera.pos.x + self.hookAnchor.x,
-Camera.pos.y + self.hookAnchor.y -Camera.pos.y + self.hookAnchor.y
) )
end end
self.body:Animate() self.body:Animate()
self:Draw(self.body) self:Draw(self.body)
if self.dashCount > 0 then if self.dashCount > 0 then
self:Draw(self.mask) self:Draw(self.mask)
end end
self.move_x = 0 self.move_x = 0
end end
function Player:Unhook() function Player:Unhook()
self.isHooked = false self.isHooked = false
self.hookAnchor = nil self.hookAnchor = nil
end end

View File

@ -1,270 +1,270 @@
Entity = {class = "Entity"} Entity = {class = "Entity"}
LoadedObjects.Entities = {} LoadedObjects.Entities = {}
function Entity:New(x,y) function Entity:New(x,y)
o = {} o = {}
o.pos = {x = x, y = y} o.pos = {x = x, y = y}
o.vel = {x = 0, y = 0} o.vel = {x = 0, y = 0}
o.direction = 0 o.direction = 0
o.boxCollision = { o.boxCollision = {
from = {x = x, y = y}, from = {x = x, y = y},
to = {x = x, y = y}, to = {x = x, y = y},
} }
o.target_offset = {x = 0, y = 0} o.target_offset = {x = 0, y = 0}
o.sprite_offset = {x = 0, y = 0} o.sprite_offset = {x = 0, y = 0}
o.sprite_scale = {x = 1, y = 1} o.sprite_scale = {x = 1, y = 1}
o.sprite_rotation = math.rad(0) o.sprite_rotation = math.rad(0)
o.sprite_tint = {1,1,1} o.sprite_tint = {1,1,1}
o.sprite_alpha = 1 o.sprite_alpha = 1
o.sprite_flip = { x = 1, y = 1} o.sprite_flip = { x = 1, y = 1}
o.illuminated = false o.illuminated = false
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function Entity:CheckNearest(type,maxdistance) function Entity:CheckNearest(type,maxdistance)
local return_entity = nil local return_entity = nil
local shortest = -1 local shortest = -1
for _, entity in pairs(LoadedObjects.Entities) do for _, entity in pairs(LoadedObjects.Entities) do
if not type or entity.type == type then if not type or entity.type == type then
local distance_x = entity.pos.x - self.pos.x local distance_x = entity.pos.x - self.pos.x
local distance_y = entity.pos.y - self.pos.y local distance_y = entity.pos.y - self.pos.y
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2) local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
if not maxdistance or distance < maxdistance then if not maxdistance or distance < maxdistance then
if shortest == -1 or distance < shortest then if shortest == -1 or distance < shortest then
shortest = distance shortest = distance
return_entity = entity return_entity = entity
end end
end end
end end
end end
return return_entity return return_entity
end end
function Entity:Smart() function Entity:Smart()
end end
function Entity:Move() function Entity:Move()
self.pos.x = self.pos.x + self.vel.x self.pos.x = self.pos.x + self.vel.x
self.pos.y = self.pos.y + self.vel.y self.pos.y = self.pos.y + self.vel.y
end end
function Entity:CollisionMove() function Entity:CollisionMove()
local r = false local r = false
if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, LoadedObjects.Collisions) then if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, LoadedObjects.Collisions) then
self.pos.x = self.pos.x + self.vel.x self.pos.x = self.pos.x + self.vel.x
else else
self.vel.x = 0 self.vel.x = 0
r = true r = true
end end
if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, LoadedObjects.Collisions) then if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, LoadedObjects.Collisions) then
self.pos.y = self.pos.y + self.vel.y self.pos.y = self.pos.y + self.vel.y
else else
self.vel.y = 0 self.vel.y = 0
r = true r = true
end end
return r return r
end end
function Entity:LightAdjust(x,y) function Entity:LightAdjust(x,y)
if self.light ~= nil then if self.light ~= nil then
local x = x or 0 local x = x or 0
local y = y or 0 local y = y or 0
self.light.pos.x = self.pos.x self.light.pos.x = self.pos.x
self.light.pos.y = self.pos.y self.light.pos.y = self.pos.y
end end
end end
function Entity:Kill() function Entity:Kill()
if self.light ~= nil then if self.light ~= nil then
self.light:Kill() self.light:Kill()
end end
if self.id ~= nil then if self.id ~= nil then
for _, e in pairs(LoadedObjects.Entities) do for _, e in pairs(LoadedObjects.Entities) do
if e.id > self.id then if e.id > self.id then
e.id = e.id - 1 e.id = e.id - 1
end end
end end
table.remove(LoadedObjects.Entities,self.id) table.remove(LoadedObjects.Entities,self.id)
end end
self = nil self = nil
end end
function Entity:CheckVisionLine(entity,range) function Entity:CheckVisionLine(entity,range)
local target_x = entity.pos.x + entity.target_offset.x local target_x = entity.pos.x + entity.target_offset.x
local target_y = entity.pos.y + entity.target_offset.y local target_y = entity.pos.y + entity.target_offset.y
local distance_x = target_x - self.pos.x local distance_x = target_x - self.pos.x
local distance_y = target_y - self.pos.y local distance_y = target_y - self.pos.y
local angle = GetAngleFromVector(distance_x,distance_y) local angle = GetAngleFromVector(distance_x,distance_y)
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2) local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
local is_colliding = true local is_colliding = true
if distance < range then if distance < range then
is_colliding = false is_colliding = false
for i=1, distance, game.scale do for i=1, distance, game.scale do
if isThereObjectAt( if isThereObjectAt(
self.pos.x+math.cos(angle)*i, self.pos.x+math.cos(angle)*i,
self.pos.y+math.sin(angle)*i, self.pos.y+math.sin(angle)*i,
LoadedObjects.Collisions LoadedObjects.Collisions
) then ) then
is_colliding = true is_colliding = true
end end
end end
end end
return not is_colliding return not is_colliding
end end
function Entity:Draw(animation) function Entity:Draw(animation)
local c1, c2, c3, a = love.graphics.getColor() local c1, c2, c3, a = love.graphics.getColor()
love.graphics.setColor(self.sprite_tint[1],self.sprite_tint[2],self.sprite_tint[3],self.sprite_alpha) love.graphics.setColor(self.sprite_tint[1],self.sprite_tint[2],self.sprite_tint[3],self.sprite_alpha)
animation:Draw( animation:Draw(
self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x, self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x,
self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y, self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y,
self.sprite_rotation, self.sprite_rotation,
self.sprite_scale.x * self.sprite_flip.x, self.sprite_scale.x * self.sprite_flip.x,
self.sprite_scale.y * self.sprite_flip.y self.sprite_scale.y * self.sprite_flip.y
) )
love.graphics.setColor(c1,c2,c3,a) love.graphics.setColor(c1,c2,c3,a)
end end
function Entity:centerOffset(animation,x,y) function Entity:centerOffset(animation,x,y)
local x = x or 0 local x = x or 0
local y = y or 0 local y = y or 0
self.sprite_offset.x = animation.imgs[1]:getWidth()/2 + x self.sprite_offset.x = animation.imgs[1]:getWidth()/2 + x
self.sprite_offset.y = animation.imgs[1]:getHeight()/2 + y self.sprite_offset.y = animation.imgs[1]:getHeight()/2 + y
end end
function Entity:getBoundingBox(animation,top,left,bottom,right) function Entity:getBoundingBox(animation,top,left,bottom,right)
local left = left or 0 local left = left or 0
local right = right or 0 local right = right or 0
local top = top or 0 local top = top or 0
local bottom = bottom or 0 local bottom = bottom or 0
self.boxCollision.from.x = -animation.imgs[1]:getWidth()/2 + left self.boxCollision.from.x = -animation.imgs[1]:getWidth()/2 + left
self.boxCollision.to.x = animation.imgs[1]:getWidth()/2 + right self.boxCollision.to.x = animation.imgs[1]:getWidth()/2 + right
self.boxCollision.from.y = -animation.imgs[1]:getHeight()/2 + top self.boxCollision.from.y = -animation.imgs[1]:getHeight()/2 + top
self.boxCollision.to.y = animation.imgs[1]:getHeight()/2 + bottom self.boxCollision.to.y = animation.imgs[1]:getHeight()/2 + bottom
end end
-- returns true if theres a collision at that point. also marks collisioned tile as collision true -- returns true if theres a collision at that point. also marks collisioned tile as collision true
function Entity:isCollidingAt(x,y,object) function Entity:isCollidingAt(x,y,object)
for _, collision in pairs(object) do for _, collision in pairs(object) do
if collision.disable then if collision.disable then
-- Dont calculate if disabled -- Dont calculate if disabled
elseif x + self.boxCollision.from.x < collision.to.x elseif x + self.boxCollision.from.x < collision.to.x
and x + self.boxCollision.to.x > collision.from.x and x + self.boxCollision.to.x > collision.from.x
and y + self.boxCollision.from.y < collision.to.y and y + self.boxCollision.from.y < collision.to.y
and y + self.boxCollision.to.y > collision.from.y and y + self.boxCollision.to.y > collision.from.y
then then
collision.isColliding = true collision.isColliding = true
return true return true
end end
end end
return false return false
end end
function Entity:isCollidingWith(entity) function Entity:isCollidingWith(entity)
return self.pos.x + self.boxCollision.from.x < entity.pos.x + entity.boxCollision.to.x return self.pos.x + self.boxCollision.from.x < entity.pos.x + entity.boxCollision.to.x
and entity.pos.x + entity.boxCollision.from.x < self.pos.x + self.boxCollision.to.x and entity.pos.x + entity.boxCollision.from.x < self.pos.x + self.boxCollision.to.x
and self.pos.y + self.boxCollision.from.y < entity.pos.y + entity.boxCollision.to.y and self.pos.y + self.boxCollision.from.y < entity.pos.y + entity.boxCollision.to.y
and entity.pos.y + entity.boxCollision.from.y < self.pos.y + self.boxCollision.to.y and entity.pos.y + entity.boxCollision.from.y < self.pos.y + self.boxCollision.to.y
end end
function Entity:isCollidingAtAll(x,y) function Entity:isCollidingAtAll(x,y)
local result = false local result = false
if not result then if not result then
result = self:isCollidingAt(x,y,LoadedObjects.Platforms) result = self:isCollidingAt(x,y,LoadedObjects.Platforms)
end end
if not result then if not result then
result = self:isCollidingAt(x,y,LoadedObjects.Platforms) result = self:isCollidingAt(x,y,LoadedObjects.Platforms)
end end
if not result then if not result then
result = self:isCollidingAt(x,y,LoadedObjects.Platforms) result = self:isCollidingAt(x,y,LoadedObjects.Platforms)
end end
return result return result
end end
function Entity:CheckVisionLineDebug(entity,range) function Entity:CheckVisionLineDebug(entity,range)
local c1, c2, c3, a = love.graphics.getColor() local c1, c2, c3, a = love.graphics.getColor()
local target_x = entity.pos.x + entity.target_offset.x local target_x = entity.pos.x + entity.target_offset.x
local target_y = entity.pos.y + entity.target_offset.y local target_y = entity.pos.y + entity.target_offset.y
local distance_x = target_x - self.pos.x local distance_x = target_x - self.pos.x
local distance_y = target_y - self.pos.y local distance_y = target_y - self.pos.y
local angle = GetAngleFromVector(distance_x,distance_y) local angle = GetAngleFromVector(distance_x,distance_y)
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2) local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
if distance < range then if distance < range then
for i=1, distance, game.scale do for i=1, distance, game.scale do
if isThereObjectAt( if isThereObjectAt(
self.pos.x+math.cos(angle)*i, self.pos.x+math.cos(angle)*i,
self.pos.y+math.sin(angle)*i, self.pos.y+math.sin(angle)*i,
LoadedObjects.Collisions LoadedObjects.Collisions
) then ) then
love.graphics.setColor(1,0,0) love.graphics.setColor(1,0,0)
else else
love.graphics.setColor(0,1,0) love.graphics.setColor(0,1,0)
end end
love.graphics.line( love.graphics.line(
self.pos.x+math.cos(angle)*i-1 - Camera.pos.x, self.pos.x+math.cos(angle)*i-1 - Camera.pos.x,
self.pos.y+math.sin(angle)*i-1 - Camera.pos.y, self.pos.y+math.sin(angle)*i-1 - Camera.pos.y,
self.pos.x+math.cos(angle)*i - Camera.pos.x, self.pos.x+math.cos(angle)*i - Camera.pos.x,
self.pos.y+math.sin(angle)*i - Camera.pos.y self.pos.y+math.sin(angle)*i - Camera.pos.y
) )
end end
end end
love.graphics.setColor(c1,c2,c3,a) love.graphics.setColor(c1,c2,c3,a)
end end
function Entity:Debug() function Entity:Debug()
-- draw center GREEN -- draw center GREEN
love.graphics.setColor(0,1,0) love.graphics.setColor(0,1,0)
love.graphics.circle("fill", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, 1) love.graphics.circle("fill", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, 1)
-- draw collision box PURPLE -- draw collision box PURPLE
love.graphics.setColor(1,0,1) love.graphics.setColor(1,0,1)
love.graphics.rectangle( love.graphics.rectangle(
"line", "line",
-Camera.pos.x + self.pos.x + self.boxCollision.from.x, -Camera.pos.x + self.pos.x + self.boxCollision.from.x,
-Camera.pos.y + self.pos.y + self.boxCollision.from.y, -Camera.pos.y + self.pos.y + self.boxCollision.from.y,
-Camera.pos.x + self.pos.x + self.boxCollision.to.x -(-Camera.pos.x + self.pos.x + self.boxCollision.from.x), -Camera.pos.x + self.pos.x + self.boxCollision.to.x -(-Camera.pos.x + self.pos.x + self.boxCollision.from.x),
-Camera.pos.y + self.pos.y + self.boxCollision.to.y -(-Camera.pos.y + self.pos.y + self.boxCollision.from.y) -Camera.pos.y + self.pos.y + self.boxCollision.to.y -(-Camera.pos.y + self.pos.y + self.boxCollision.from.y)
) )
if self.target ~= nil then if self.target ~= nil then
love.graphics.line( love.graphics.line(
-Camera.pos.x + self.pos.x, -Camera.pos.x + self.pos.x,
-Camera.pos.y + self.pos.y, -Camera.pos.y + self.pos.y,
-Camera.pos.x + self.target.x, -Camera.pos.x + self.target.x,
-Camera.pos.y + self.target.y -Camera.pos.y + self.target.y
) )
end end
end end
function Entity:HandleAnimation() function Entity:HandleAnimation()
end end
function Entity:DrawBackground() function Entity:DrawBackground()
end end
require "code/entities/kupo" require "code/entities/kupo"
require "code/entities/arrow" require "code/entities/arrow"
require "code/entities/decoration" require "code/entities/decoration"
require "code/entities/player" require "code/entities/player"
require "code/entities/fairy" require "code/entities/fairy"
require "code/entities/cursed_book" require "code/entities/cursed_book"
require "code/entities/hook_anchor" require "code/entities/hook_anchor"
require "code/entities/particle" require "code/entities/particle"

View File

@ -1,24 +1,24 @@
function GameStep() function GameStep()
SetCollisionFlags() SetCollisionFlags()
if menu_type == "no" then if menu_type == "no" then
for _, particle in pairs(LoadedParticles) do for _, particle in pairs(LoadedParticles) do
particle:Smart() particle:Smart()
end end
for _, enty in pairs(LoadedObjects.Entities) do for _, enty in pairs(LoadedObjects.Entities) do
enty:Smart() enty:Smart()
end end
end end
for _, particle in pairs(LoadedObjects.Particles) do for _, particle in pairs(LoadedObjects.Particles) do
particle:DoPhysics() particle:DoPhysics()
end end
for _, enty in pairs(LoadedObjects.Entities) do for _, enty in pairs(LoadedObjects.Entities) do
enty:DoPhysics() enty:DoPhysics()
end end
AnimateTiles() AnimateTiles()
Camera:positionCenterAt(main_Player.pos.x, main_Player.pos.y) Camera:positionCenterAt(main_Player.pos.x, main_Player.pos.y)
--camera:positionAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height) --camera:positionAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height)
if Keybind:CheckPressed(Keybind.debug.debug) then if Keybind:CheckPressed(Keybind.debug.debug) then
if debug then if debug then
@ -38,8 +38,8 @@ function GameStep()
end end
if Keybind:CheckPressed(Keybind.debug.reload) then if Keybind:CheckPressed(Keybind.debug.reload) then
MenuClear() MenuClear()
menu_type = "dialog" menu_type = "dialog"
MenuInit("dialog",DialogSequence.Example) MenuInit("dialog",DialogSequence.Example)
end end
@ -49,50 +49,50 @@ function GameStep()
if Keybind:CheckPressed(Keybind.debug.recording) then if Keybind:CheckPressed(Keybind.debug.recording) then
if DemoRecording then if DemoRecording then
Demo:RecordEnd() Demo:RecordEnd()
else else
Demo:RecordStart() Demo:RecordStart()
end end
end end
if Keybind:CheckPressed(Keybind.debug.playback) then if Keybind:CheckPressed(Keybind.debug.playback) then
if DemoPlayback then if DemoPlayback then
Demo:PlaybackEnd() Demo:PlaybackEnd()
else else
Demo:PlaybackStart() Demo:PlaybackStart()
end end
end end
end end
function GameDraw() function GameDraw()
-- prepare -- prepare
GameworldDrawPrepare() GameworldDrawPrepare()
GameWorldUpdateLights() GameWorldUpdateLights()
-- background -- background
GameworldDrawBackground() GameworldDrawBackground()
GameworldDrawLights() GameworldDrawLights()
GameworldDrawEntitiesBackground() GameworldDrawEntitiesBackground()
-- foreground -- foreground
GameworldDrawForeground() GameworldDrawForeground()
GameworldDrawParticles() GameworldDrawParticles()
GameworldDrawEntities() GameworldDrawEntities()
if LevelData.properties.darkness then if LevelData.properties.darkness then
GameworldDrawDarkness() GameworldDrawDarkness()
end end
-- end -- end
GameworldDrawEnd() GameworldDrawEnd()
-- hud -- hud
textScale = 1 textScale = 1
-- debug -- debug
if debug then DebugUI() end if debug then DebugUI() end
if debug_collision then if debug_collision then
DebugColisions() DebugColisions()
DebugEntities() DebugEntities()
end end
end end

View File

@ -1,21 +1,21 @@
function GameworldDrawPrepare() function GameworldDrawPrepare()
if game_resize then if game_resize then
Camera.height = game.height Camera.height = game.height
Camera.width = game.width Camera.width = game.width
Canvas.Darkness:Recreate() Canvas.Darkness:Recreate()
end end
pcr, pcg, pcb, pca = love.graphics.getColor() pcr, pcg, pcb, pca = love.graphics.getColor()
love.graphics.setScale(game.scale,game.scale) love.graphics.setScale(game.scale,game.scale)
love.graphics.setColor(1,1,1,1) love.graphics.setColor(1,1,1,1)
end end
function GameworldDrawEnd() function GameworldDrawEnd()
love.graphics.setColor(pcr, pcg, pcb, pca) love.graphics.setColor(pcr, pcg, pcb, pca)
pcr, pcg, pcb, pca = nil, nil, nil, nil pcr, pcg, pcb, pca = nil, nil, nil, nil
end end
function GameworldDrawBackground() function GameworldDrawBackground()
-- obscure a bit -- obscure a bit
love.graphics.setColor(0.7,0.7,0.7) love.graphics.setColor(0.7,0.7,0.7)
for i = 1, #LevelTiles do for i = 1, #LevelTiles do
for j = 1, #LevelTiles[i] do for j = 1, #LevelTiles[i] do
@ -35,32 +35,32 @@ function GameworldDrawBackground()
end end
function GameworldDrawParticles() function GameworldDrawParticles()
love.graphics.setColor(0.7,0.7,0.7) love.graphics.setColor(0.7,0.7,0.7)
for _, particle in pairs(LoadedObjects.Particles) do for _, particle in pairs(LoadedObjects.Particles) do
particle:HandleAnimation() particle:HandleAnimation()
end end
end end
function GameworldDrawEntitiesBackground() function GameworldDrawEntitiesBackground()
for _, enty in pairs(LoadedObjects.Entities) do for _, enty in pairs(LoadedObjects.Entities) do
enty:DrawBackground() enty:DrawBackground()
end end
end end
function GameworldDrawEntities() function GameworldDrawEntities()
love.graphics.setColor(0.7,0.7,0.7) love.graphics.setColor(0.7,0.7,0.7)
for _, enty in pairs(LoadedObjects.Entities) do for _, enty in pairs(LoadedObjects.Entities) do
enty:HandleAnimation() enty:HandleAnimation()
end end
end end
function GameworldDrawForeground() function GameworldDrawForeground()
love.graphics.setColor(1,1,1) love.graphics.setColor(1,1,1)
for i = 1, #LevelTiles do for i = 1, #LevelTiles do
for j = 1, #LevelTiles[i] do for j = 1, #LevelTiles[i] do
if LevelTiles[i][j].id ~= 0 then if LevelTiles[i][j].id ~= 0 then
local depth = TileData[LevelTiles[i][j].id].depth local depth = TileData[LevelTiles[i][j].id].depth
DrawTile( DrawTile(
LevelTiles[i][j], LevelTiles[i][j],
tileProperties.scale * j * tileProperties.width + tileProperties.scale * (levelProperties.offset.x - tileProperties.width) - Camera.pos.x, tileProperties.scale * j * tileProperties.width + tileProperties.scale * (levelProperties.offset.x - tileProperties.width) - Camera.pos.x,
@ -74,53 +74,53 @@ function GameworldDrawForeground()
end end
function GameworldDrawDarkness() function GameworldDrawDarkness()
Canvas.Darkness:Reset() Canvas.Darkness:Reset()
Canvas.Darkness:DrawingStart() Canvas.Darkness:DrawingStart()
love.graphics.setBlendMode("replace") love.graphics.setBlendMode("replace")
love.graphics.setColor(0,0,0,0) love.graphics.setColor(0,0,0,0)
for _, light in pairs(LoadedObjects.Lights) do for _, light in pairs(LoadedObjects.Lights) do
if light.range ~= 0 then if light.range ~= 0 then
local position = { local position = {
x = (light.pos.x - Camera.pos.x) / game.scale, x = (light.pos.x - Camera.pos.x) / game.scale,
y = (light.pos.y - Camera.pos.y) / game.scale y = (light.pos.y - Camera.pos.y) / game.scale
} }
local range = (light.range + light.flicker) / game.scale local range = (light.range + light.flicker) / game.scale
love.graphics.circle( love.graphics.circle(
"fill", "fill",
position.x, position.x,
position.y, position.y,
range range
) )
end end
end end
Canvas.Darkness:DrawingEnd() Canvas.Darkness:DrawingEnd()
Canvas.Darkness:Draw() Canvas.Darkness:Draw()
end end
function GameworldDrawLights() function GameworldDrawLights()
for _, light in pairs(LoadedObjects.Lights) do for _, light in pairs(LoadedObjects.Lights) do
if light.range ~= 0 then if light.range ~= 0 then
love.graphics.setColor(light.color[1],light.color[2],light.color[3],1) love.graphics.setColor(light.color[1],light.color[2],light.color[3],1)
Shader.RadiusGradient:send("pos_x",- Camera.pos.x + light.pos.x) Shader.RadiusGradient:send("pos_x",- Camera.pos.x + light.pos.x)
Shader.RadiusGradient:send("pos_y",- Camera.pos.y + light.pos.y) Shader.RadiusGradient:send("pos_y",- Camera.pos.y + light.pos.y)
Shader.RadiusGradient:send("range",light.range) Shader.RadiusGradient:send("range",light.range)
Shader.RadiusGradient:send("scale",game.scale) Shader.RadiusGradient:send("scale",game.scale)
love.graphics.setShader(Shader.RadiusGradient) love.graphics.setShader(Shader.RadiusGradient)
love.graphics.circle( love.graphics.circle(
"fill", "fill",
- Camera.pos.x + light.pos.x, - Camera.pos.x + light.pos.x,
- Camera.pos.y + light.pos.y, - Camera.pos.y + light.pos.y,
light.range light.range
) )
love.graphics.setShader() love.graphics.setShader()
end end
end end
end end
function GameWorldUpdateLights() function GameWorldUpdateLights()
for _, light in pairs(LoadedObjects.Lights) do for _, light in pairs(LoadedObjects.Lights) do
light:Flicker() light:Flicker()
end end
end end

View File

@ -10,7 +10,7 @@ function HEX2RGB(color)
end end
function HEX2DEX(hex) function HEX2DEX(hex)
if hex == "0" then return 0 if hex == "0" then return 0
elseif hex == "1" then return 1 elseif hex == "1" then return 1
elseif hex == "2" then return 2 elseif hex == "2" then return 2
elseif hex == "3" then return 3 elseif hex == "3" then return 3

View File

@ -20,7 +20,7 @@ function ExportLevel(levelname, filename)
logPrint("- properties") logPrint("- properties")
exportFile:write("\n properties = {") exportFile:write("\n properties = {")
exportFile:write("\n darkness = true") exportFile:write("\n darkness = true")
exportFile:write("\n },") exportFile:write("\n },")
logPrint("- tiles") logPrint("- tiles")
@ -53,30 +53,30 @@ end
-- Source https://stackoverflow.com/a/11130774 -- Source https://stackoverflow.com/a/11130774
function scandir(directory) function scandir(directory)
local i, t, popen = 0, {}, io.popen local i, t, popen = 0, {}, io.popen
local pfile = popen('ls "'..directory..'"') local pfile = popen('ls "'..directory..'"')
for filename in pfile:lines() do for filename in pfile:lines() do
i = i + 1 i = i + 1
t[i] = filename t[i] = filename
end end
pfile:close() pfile:close()
return t return t
end end
--[[ --[[
return { return {
name = "level1", name = "level1",
tileset = tileset.library, tileset = tileset.library,
tiles = { tiles = {
{13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13}, {13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 5,25,26, 6,25,26, 7, 0, 5,25,26, 7, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 5,25,26, 6,25,26, 7, 0, 5,25,26, 7, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 5,49,50, 6,49,50, 7, 0, 5,49,50, 7, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 5,49,50, 6,49,50, 7, 0, 5,49,50, 7, 0, 0, 0, 0, 0, 0},
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
}, },
objects = {} objects = {}
} }
]] ]]
if logging then if logging then

View File

@ -18,95 +18,95 @@ Keybind.editor = {}
Keybind.generic = {} Keybind.generic = {}
function Keybind:CheckDown(action) function Keybind:CheckDown(action)
if DemoPlayback then if DemoPlayback then
for _, demo_action in pairs(DemoAction[CurrentDemoFrame]) do for _, demo_action in pairs(DemoAction[CurrentDemoFrame]) do
if demo_action == action.demo then if demo_action == action.demo then
return true return true
end end
end end
return false return false
else else
for _, keyname in pairs(action.keys) do for _, keyname in pairs(action.keys) do
local check = false local check = false
if type(keyname) == "string" then if type(keyname) == "string" then
check = love.keyboard.isDown(keyname) check = love.keyboard.isDown(keyname)
else else
check = love.mouse.isDown(keyname) check = love.mouse.isDown(keyname)
end end
if check then if check then
if action.demo ~= nil then if action.demo ~= nil then
Demo:RecordAction(action.demo) Demo:RecordAction(action.demo)
end end
return true return true
end end
end end
return false return false
end end
end end
function Keybind:CheckPressed(action) function Keybind:CheckPressed(action)
if Keybind:CheckDown(action) then if Keybind:CheckDown(action) then
if not action.pressed then if not action.pressed then
action.pressed = true action.pressed = true
return true return true
end end
else else
action.pressed = nil action.pressed = nil
end end
return false return false
end end
function Keybind:CheckCollision(cat, key) function Keybind:CheckCollision(cat, key)
for _, action in pairs(cat) do for _, action in pairs(cat) do
for _, keyname in pairs(action.keys) do for _, keyname in pairs(action.keys) do
if key == keyname then return true end if key == keyname then return true end
end end
end end
return false return false
end end
function Keybind:AddKey(action, key) function Keybind:AddKey(action, key)
table.insert(action.keys, key) table.insert(action.keys, key)
end end
function Keybind:ChangeKey(action, position, key) function Keybind:ChangeKey(action, position, key)
action.keys[position] = key action.keys[position] = key
end end
function Keybind:RemoveKeys(action) function Keybind:RemoveKeys(action)
action.keys = {} action.keys = {}
end end
function Keybind:Default() function Keybind:Default()
--Menu --Menu
Keybind.menu.pause.keys = {"escape"} Keybind.menu.pause.keys = {"escape"}
Keybind.menu.confirm.keys = {"z", "space", 1} Keybind.menu.confirm.keys = {"z", "space", 1}
--Move --Move
Keybind.move.left.keys = {"left", "a"} Keybind.move.left.keys = {"left", "a"}
Keybind.move.right.keys = {"right", "d"} Keybind.move.right.keys = {"right", "d"}
Keybind.move.up.keys = {"up", "w"} Keybind.move.up.keys = {"up", "w"}
Keybind.move.down.keys = {"down", "s"} Keybind.move.down.keys = {"down", "s"}
Keybind.move.jump.keys = {"z", "space"} Keybind.move.jump.keys = {"z", "space"}
Keybind.move.hook.keys = {"x", 1} Keybind.move.hook.keys = {"x", 1}
Keybind.move.dash.keys = {"c", 2} Keybind.move.dash.keys = {"c", 2}
--Debug --Debug
Keybind.debug.debug = { keys = {"f1"}} Keybind.debug.debug = { keys = {"f1"}}
Keybind.debug.reposition = { keys = {"f2"}} Keybind.debug.reposition = { keys = {"f2"}}
Keybind.debug.reload = { keys = {"f3"}} Keybind.debug.reload = { keys = {"f3"}}
Keybind.debug.editor = { keys = {"f4"}} Keybind.debug.editor = { keys = {"f4"}}
Keybind.debug.recording = { keys = {"f5"}} Keybind.debug.recording = { keys = {"f5"}}
Keybind.debug.playback = { keys = {"f6"}} Keybind.debug.playback = { keys = {"f6"}}
-- Editor -- Editor
Keybind.editor.palette = { keys = {"tab"}} Keybind.editor.palette = { keys = {"tab"}}
-- Generic -- Generic
Keybind.generic.lclick = { keys = {1}} Keybind.generic.lclick = { keys = {1}}
Keybind.generic.rclick = { keys = {2}} Keybind.generic.rclick = { keys = {2}}
Keybind.generic.lshift = { keys = {"lshift"}} Keybind.generic.lshift = { keys = {"lshift"}}
Keybind.generic.lctrl = { keys = {"lctrl"}} Keybind.generic.lctrl = { keys = {"lctrl"}}
end end
-- Set default values at start -- Set default values at start

View File

@ -262,7 +262,7 @@ function TileOptimizeObjects()
local n = 1 local n = 1
local check = true local check = true
while check do while check do
check = false check = false
if LevelTiles[i][j+n] ~= nil if LevelTiles[i][j+n] ~= nil
and TileData[LevelTiles[i][j+n].id] ~= nil and TileData[LevelTiles[i][j+n].id] ~= nil
then then
@ -279,7 +279,7 @@ function TileOptimizeObjects()
local m = 1 local m = 1
local check = true local check = true
while check do while check do
check = false check = false
local checkline = true local checkline = true
-- for as long as line, check -- for as long as line, check
for l = 0, n-1 do for l = 0, n-1 do

View File

@ -1,5 +1,5 @@
function LocaleLoad(ISO639) function LocaleLoad(ISO639)
local ISO639 = ISO639 or "ENG" local ISO639 = ISO639 or "ENG"
dofile("data/locale/"..ISO639..".lua") dofile("data/locale/"..ISO639..".lua")
dofile("data/dialog_sequences.lua") dofile("data/dialog_sequences.lua")
end end

View File

@ -1,21 +1,21 @@
function math.sign(x) function math.sign(x)
if x<0 then if x<0 then
return -1 return -1
elseif x>0 then elseif x>0 then
return 1 return 1
else else
return 0 return 0
end end
end end
function Vector(init_x, init_y, final_x, final_y) function Vector(init_x, init_y, final_x, final_y)
local distance_x = final_x - init_x local distance_x = final_x - init_x
local distance_y = final_y - init_y local distance_y = final_y - init_y
return {distance_x, distance_y} return {distance_x, distance_y}
end end
function GetVectorValue(vector) function GetVectorValue(vector)
return math.sqrt(vector[1] ^ 2 + vector[2] ^ 2) return math.sqrt(vector[1] ^ 2 + vector[2] ^ 2)
end end
function GetAngleFromVector(x,y) function GetAngleFromVector(x,y)

View File

@ -1,146 +1,146 @@
function MenuDraw(menu) function MenuDraw(menu)
local font = love.graphics.getFont() local font = love.graphics.getFont()
love.graphics.setFont(LocaleFont) love.graphics.setFont(LocaleFont)
-- reset scale -- reset scale
love.graphics.setScale() love.graphics.setScale()
if menu == "pause" then if menu == "pause" then
MenuDrawPauseScreen() MenuDrawPauseScreen()
elseif menu == "dialog" then elseif menu == "dialog" then
MenuDrawDialog() MenuDrawDialog()
end end
for _, element in pairs(UIElement) do for _, element in pairs(UIElement) do
element:Draw() element:Draw()
end end
love.graphics.setFont(font) love.graphics.setFont(font)
end end
function MenuDrawPauseScreen() function MenuDrawPauseScreen()
-- Parameters -- Parameters
local pauseWidth = 640 local pauseWidth = 640
local pauseHeight = 480 local pauseHeight = 480
local pauseX = (game.width/2)-(pauseWidth/2) local pauseX = (game.width/2)-(pauseWidth/2)
local pauseY = (game.height/2)-(pauseHeight/2) local pauseY = (game.height/2)-(pauseHeight/2)
local mouse_x, mouse_y = love.mouse.getPosition() local mouse_x, mouse_y = love.mouse.getPosition()
-- Base items -- Base items
love.graphics.setColor(0,0,0,0.3) love.graphics.setColor(0,0,0,0.3)
love.graphics.rectangle("fill", 0, 0, game.width, game.height) love.graphics.rectangle("fill", 0, 0, game.width, game.height)
love.graphics.setColor(1,1,1,1) love.graphics.setColor(1,1,1,1)
love.graphics.rectangle("fill", pauseX, pauseY, pauseWidth, pauseHeight) love.graphics.rectangle("fill", pauseX, pauseY, pauseWidth, pauseHeight)
end end
function MenuDrawDialog() function MenuDrawDialog()
end end
function MenuStep(menu) function MenuStep(menu)
-- first get mouse -- first get mouse
local mouse_x, mouse_y = love.mouse.getPosition() local mouse_x, mouse_y = love.mouse.getPosition()
for _, element in pairs(UIElement) do for _, element in pairs(UIElement) do
if element.type == "Button" then if element.type == "Button" then
element:checkMouse(mouse_x, mouse_y) element:checkMouse(mouse_x, mouse_y)
elseif element.type == "Dialog" then elseif element.type == "Dialog" then
element:checkConfirm() element:checkConfirm()
end end
end end
if menu == 0 then if menu == 0 then
elseif menu == "pause" then elseif menu == "pause" then
MenuStepPauseScreen() MenuStepPauseScreen()
elseif menu == "dialog" then elseif menu == "dialog" then
MenuStepDialog() MenuStepDialog()
end end
end end
function MenuStepPauseScreen() function MenuStepPauseScreen()
if PauseResume:getVariable() == true then if PauseResume:getVariable() == true then
PauseResume = nil PauseResume = nil
PauseOptions = nil PauseOptions = nil
PauseExit = nil PauseExit = nil
MenuExit() MenuExit()
elseif PauseExit:getVariable() == true then elseif PauseExit:getVariable() == true then
love.event.quit() love.event.quit()
end end
end end
function MenuStepDialog() function MenuStepDialog()
if DialogContainer.value >= DialogContainer.target_value then if DialogContainer.value >= DialogContainer.target_value then
DialogContainer = nil DialogContainer = nil
MenuExit() MenuExit()
end end
end end
function MenuClear() function MenuClear()
for _, element in pairs(UIElement) do for _, element in pairs(UIElement) do
element = nil element = nil
end end
UIElement = {} UIElement = {}
end end
function MenuExit(to) function MenuExit(to)
MenuClear() MenuClear()
local to = to or "no" local to = to or "no"
menu_type = to menu_type = to
end end
function MenuInit(menu,parameter) function MenuInit(menu,parameter)
-- main menu -- main menu
if menu == "pause" then if menu == "pause" then
MenuInitPauseScreen() MenuInitPauseScreen()
elseif menu == "dialog" then elseif menu == "dialog" then
if parameter == nil then if parameter == nil then
parameter = DialogSequence.Example parameter = DialogSequence.Example
end end
MenuInitDialog(parameter) MenuInitDialog(parameter)
end end
end end
function MenuInitDialog(parameter) function MenuInitDialog(parameter)
DialogContainer = interfaceDialog:New() DialogContainer = interfaceDialog:New()
DialogContainer:loadSequence(parameter) DialogContainer:loadSequence(parameter)
end end
function MenuInitPauseScreen() function MenuInitPauseScreen()
local buttonStandard = {width = 200, height = 30, separation = 10} local buttonStandard = {width = 200, height = 30, separation = 10}
-- elements -- elements
PauseResume = interfaceButton:New( PauseResume = interfaceButton:New(
game.width/2, game.width/2,
game.height/2-buttonStandard.height-buttonStandard.separation, game.height/2-buttonStandard.height-buttonStandard.separation,
buttonStandard.width, buttonStandard.width,
buttonStandard.height, buttonStandard.height,
{false,true}, {false,true},
1, 1,
{ {
text = Locale.ui.pause_screen_resume, text = Locale.ui.pause_screen_resume,
color = {0,0,0.5}, color = {0,0,0.5},
color2 = {1,1,1} color2 = {1,1,1}
} }
) )
PauseOptions = interfaceButton:New( PauseOptions = interfaceButton:New(
game.width/2, game.width/2,
game.height/2, game.height/2,
buttonStandard.width, buttonStandard.width,
buttonStandard.height, buttonStandard.height,
{false,true}, {false,true},
1, 1,
{ {
text = Locale.ui.pause_screen_options, text = Locale.ui.pause_screen_options,
color = {0,0,0.5}, color = {0,0,0.5},
color2 = {1,1,1} color2 = {1,1,1}
} }
) )
PauseExit = interfaceButton:New( PauseExit = interfaceButton:New(
game.width/2, game.width/2,
game.height/2+buttonStandard.height+buttonStandard.separation, game.height/2+buttonStandard.height+buttonStandard.separation,
buttonStandard.width, buttonStandard.width,
buttonStandard.height, buttonStandard.height,
{false,true}, {false,true},
1, 1,
{ {
text = Locale.ui.pause_screen_exit, text = Locale.ui.pause_screen_exit,
color = {0,0,0.5}, color = {0,0,0.5},
color2 = {1,1,1} color2 = {1,1,1}
} }
) )
end end

View File

@ -7,7 +7,7 @@ function LoadedObjects.DrawCollisions()
end end
for _, platform in pairs(LoadedObjects.Platforms) do for _, platform in pairs(LoadedObjects.Platforms) do
if platform.disable == true then platform:Draw(2) end if platform.disable == true then platform:Draw(2) end
if platform.disable == false then platform:Draw(1) end if platform.disable == false then platform:Draw(1) end
end end
@ -37,7 +37,7 @@ function isThereObjectAt(x,y,objectType)
end end
function isThereCollisionAt(x,y) function isThereCollisionAt(x,y)
if x >= 0 and x < #CollisionTable if x >= 0 and x < #CollisionTable
and y >= 0 and y < #CollisionTable[0] then and y >= 0 and y < #CollisionTable[0] then
return CollisionTable[math.floor(y)][math.floor(x)] return CollisionTable[math.floor(y)][math.floor(x)]
end end

View File

@ -1,50 +1,50 @@
Particle = Entity:New(x,y) Particle = Entity:New(x,y)
function Particle:New(x,y,particle_data) function Particle:New(x,y,particle_data)
local o = Entity:New(x,y) local o = Entity:New(x,y)
o.pos = {x = x, y = y} o.pos = {x = x, y = y}
o.speed = particle_data.speed or 0 o.speed = particle_data.speed or 0
o.direction = particle_data.direction or o.direction o.direction = particle_data.direction or o.direction
o.sprite_rotation = particle_data.sprite_rotation or o.sprite_rotation o.sprite_rotation = particle_data.sprite_rotation or o.sprite_rotation
o.sprite_offset = particle_data.sprite_offset or o.sprite_offset o.sprite_offset = particle_data.sprite_offset or o.sprite_offset
o.sprite_scale = particle_data.sprite_scale or o.sprite_scale o.sprite_scale = particle_data.sprite_scale or o.sprite_scale
o.sprite_tint = particle_data.sprite_tint or o.sprite_tint o.sprite_tint = particle_data.sprite_tint or o.sprite_tint
o.sprite_alpha = particle_data.sprite_alpha or o.sprite_alpha o.sprite_alpha = particle_data.sprite_alpha or o.sprite_alpha
o.sprite_alpha_base = o.sprite_alpha o.sprite_alpha_base = o.sprite_alpha
o.sprite_flip = particle_data.sprite_flip or o.sprite_flip o.sprite_flip = particle_data.sprite_flip or o.sprite_flip
o.animation_active = particle_data.animation_active or false o.animation_active = particle_data.animation_active or false
o.time = 0.5 o.time = 0.5
o.timer = 0 o.timer = 0
o.vel = { o.vel = {
x = o.speed * math.cos(o.direction), x = o.speed * math.cos(o.direction),
y = o.speed * math.sin(o.direction) y = o.speed * math.sin(o.direction)
} }
if particle_data.light ~= nil then if particle_data.light ~= nil then
o.lightRange = particle_data.light o.lightRange = particle_data.light
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange) o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
end end
-- animations -- animations
o.body = Animation:New(particle_data.animation) o.body = Animation:New(particle_data.animation)
o:centerOffset(o.body) o:centerOffset(o.body)
if not o.animation_active then if not o.animation_active then
o.body.speed = 0 o.body.speed = 0
end end
table.insert(LoadedParticles,o) table.insert(LoadedParticles,o)
o.id = #LoadedParticles o.id = #LoadedParticles
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function Particle:Kill() function Particle:Kill()
if self.light ~= nil then if self.light ~= nil then
@ -62,21 +62,21 @@ function Particle:Kill()
end end
function Particle:HandleAnimation() function Particle:HandleAnimation()
self.body:Animate() self.body:Animate()
self.timer = self.timer + current_dt self.timer = self.timer + current_dt
self.sprite_alpha = self.sprite_alpha_base*(self.time-self.timer)/self.time self.sprite_alpha = self.sprite_alpha_base*(self.time-self.timer)/self.time
if self.light ~= nil then if self.light ~= nil then
self.light.range = self.lightRange * self.sprite_alpha/2 self.light.range = self.lightRange * self.sprite_alpha/2
end end
if self.sprite_alpha < 0 then self:Kill() end if self.sprite_alpha < 0 then self:Kill() end
self:Draw(self.body) self:Draw(self.body)
end end
function Particle:DoPhysics() function Particle:DoPhysics()
if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, objects.collisions) then if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, objects.collisions) then
self.pos.x = self.pos.x + self.vel.x self.pos.x = self.pos.x + self.vel.x
end end
if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, objects.collisions) then if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, objects.collisions) then
self.pos.y = self.pos.y + self.vel.y self.pos.y = self.pos.y + self.vel.y
end end
end end

View File

@ -1,8 +1,8 @@
UIElement = {} UIElement = {}
function AddElement(self) function AddElement(self)
table.insert(UIElement,self) table.insert(UIElement,self)
self.id = #UIElement self.id = #UIElement
end end
require "code/ui/button" require "code/ui/button"

View File

@ -3,99 +3,99 @@ interfaceButton = {type = "Button"}
-- centered buttons -- centered buttons
function interfaceButton:New(x,y,w,h,table_values,value,style) function interfaceButton:New(x,y,w,h,table_values,value,style)
o = {} o = {}
o.pos = { o.pos = {
x = x, x = x,
y = y y = y
} }
o.size = { o.size = {
w = w, w = w,
h = h h = h
} }
o.values = table_values or {false,true} o.values = table_values or {false,true}
o.value = value or 1 o.value = value or 1
o.target_variable = o.values[o.value] o.target_variable = o.values[o.value]
o.clicked = false o.clicked = false
o.style = { o.style = {
text = style.text or nil, text = style.text or nil,
color = style.color or {1,1,1}, color = style.color or {1,1,1},
color2 = style.color2 or {0,0,0}, color2 = style.color2 or {0,0,0},
--color3 = style.color3 or style.color2 or {0,0,0}, --color3 = style.color3 or style.color2 or {0,0,0},
alpha = style.alpha or 1, alpha = style.alpha or 1,
scale = style.scale or 1, scale = style.scale or 1,
scale_x = style.scale_x or 1, scale_x = style.scale_x or 1,
scale_y = style.scale_y or 1, scale_y = style.scale_y or 1,
scale_proportion = 1 scale_proportion = 1
} }
o.style.unselected = { o.style.unselected = {
scale_proportion = o.style.scale_proportion scale_proportion = o.style.scale_proportion
} }
o.style.selected = { o.style.selected = {
scale_proportion = 1.5 scale_proportion = 1.5
} }
AddElement(o) AddElement(o)
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function interfaceButton:getVariable() function interfaceButton:getVariable()
return self.target_variable return self.target_variable
end end
function interfaceButton:checkMouse(mouse_x, mouse_y) function interfaceButton:checkMouse(mouse_x, mouse_y)
if not self.clicked if not self.clicked
and mouse_x < self.pos.x + self.size.w/2 and mouse_x < self.pos.x + self.size.w/2
and mouse_x > self.pos.x - self.size.w/2 and mouse_x > self.pos.x - self.size.w/2
and mouse_y < self.pos.y + self.size.h/2 and mouse_y < self.pos.y + self.size.h/2
and mouse_y > self.pos.y - self.size.h/2 then and mouse_y > self.pos.y - self.size.h/2 then
self.style.scale_proportion = o.style.selected.scale_proportion self.style.scale_proportion = o.style.selected.scale_proportion
if love.mouse.isDown(1) then if love.mouse.isDown(1) then
self.clicked = true self.clicked = true
self.value = self.value + 1 self.value = self.value + 1
if self.value > #self.values then if self.value > #self.values then
self.value = 1 self.value = 1
end end
self.target_variable = self.values[self.value] self.target_variable = self.values[self.value]
end end
elseif not love.mouse.isDown(1) then elseif not love.mouse.isDown(1) then
self.style.scale_proportion = o.style.unselected.scale_proportion self.style.scale_proportion = o.style.unselected.scale_proportion
self.clicked = false self.clicked = false
end end
end end
function interfaceButton:Draw() function interfaceButton:Draw()
local c1, c2, c3, a = love.graphics.getColor() local c1, c2, c3, a = love.graphics.getColor()
love.graphics.setColor(self.style.color[1],self.style.color[2],self.style.color[3],self.style.alpha) love.graphics.setColor(self.style.color[1],self.style.color[2],self.style.color[3],self.style.alpha)
love.graphics.rectangle( love.graphics.rectangle(
"fill", "fill",
self.pos.x-(self.size.w/2)*self.style.scale_x*self.style.scale_proportion, self.pos.x-(self.size.w/2)*self.style.scale_x*self.style.scale_proportion,
self.pos.y-(self.size.h/2)*self.style.scale_y*self.style.scale_proportion, self.pos.y-(self.size.h/2)*self.style.scale_y*self.style.scale_proportion,
self.size.w *self.style.scale_x*self.style.scale_proportion, self.size.w *self.style.scale_x*self.style.scale_proportion,
self.size.h *self.style.scale_y*self.style.scale_proportion) self.size.h *self.style.scale_y*self.style.scale_proportion)
love.graphics.setColor(self.style.color2[1],self.style.color2[2],self.style.color2[3],self.style.alpha) love.graphics.setColor(self.style.color2[1],self.style.color2[2],self.style.color2[3],self.style.alpha)
love.graphics.rectangle( love.graphics.rectangle(
"line", "line",
self.pos.x-(self.size.w/2)*self.style.scale_x*self.style.scale_proportion, self.pos.x-(self.size.w/2)*self.style.scale_x*self.style.scale_proportion,
self.pos.y-(self.size.h/2)*self.style.scale_y*self.style.scale_proportion, self.pos.y-(self.size.h/2)*self.style.scale_y*self.style.scale_proportion,
self.size.w *self.style.scale_x*self.style.scale_proportion, self.size.w *self.style.scale_x*self.style.scale_proportion,
self.size.h *self.style.scale_y*self.style.scale_proportion) self.size.h *self.style.scale_y*self.style.scale_proportion)
if self.style.text ~= nil then if self.style.text ~= nil then
love.graphics.print(self.style.text,self.pos.x,self.pos.y) love.graphics.print(self.style.text,self.pos.x,self.pos.y)
else else
love.graphics.print(tostring(self.target_variable),self.pos.x,self.pos.y) love.graphics.print(tostring(self.target_variable),self.pos.x,self.pos.y)
end end
love.graphics.setColor(c1,c2,c3,a) love.graphics.setColor(c1,c2,c3,a)
end end

View File

@ -2,96 +2,96 @@ interfaceDialog = {type = "Dialog"}
-- dialog boxes -- dialog boxes
function interfaceDialog:New(style) function interfaceDialog:New(style)
o = {} o = {}
o.pos = { o.pos = {
x = 0, x = 0,
y = game.height*80/100 y = game.height*80/100
} }
o.size = { o.size = {
w = game.width, w = game.width,
h = game.height*20/100 h = game.height*20/100
} }
o.value = 0 o.value = 0
o.target_value = 0 o.target_value = 0
local style = {} local style = {}
o.style = { o.style = {
content = style.content or nil, content = style.content or nil,
color = style.color or {1,1,1}, color = style.color or {1,1,1},
color2 = style.color2 or {0,0,0}, color2 = style.color2 or {0,0,0},
--color3 = style.color3 or style.color2 or {0,0,0}, --color3 = style.color3 or style.color2 or {0,0,0},
alpha = style.alpha or 1, alpha = style.alpha or 1,
scale = style.scale or 1, scale = style.scale or 1,
scale_x = style.scale_x or 1, scale_x = style.scale_x or 1,
scale_y = style.scale_y or 1, scale_y = style.scale_y or 1,
scale_proportion = 1 scale_proportion = 1
} }
AddElement(o) AddElement(o)
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function interfaceDialog:updateContents() function interfaceDialog:updateContents()
if self.value < self.target_value then if self.value < self.target_value then
self.contents = self.sequence[self.value] self.contents = self.sequence[self.value]
if self.contents[1] == nil then self.contents[1] = "" end if self.contents[1] == nil then self.contents[1] = "" end
if self.contents[2] == nil then self.contents[2] = "" end if self.contents[2] == nil then self.contents[2] = "" end
if self.contents[3] == nil then self.contents[3] = "" end if self.contents[3] == nil then self.contents[3] = "" end
end end
end end
function interfaceDialog:loadSequence(sequence) function interfaceDialog:loadSequence(sequence)
self.sequence = sequence self.sequence = sequence
self.value = 1 self.value = 1
self.target_value = 1+#sequence self.target_value = 1+#sequence
self:updateContents() self:updateContents()
end end
function interfaceDialog:checkConfirm() function interfaceDialog:checkConfirm()
if not self.clicked then if not self.clicked then
if love.mouse.isDown(1) then if love.mouse.isDown(1) then
self.clicked = true self.clicked = true
self.value = self.value + 1 self.value = self.value + 1
logPrint("Dialog: "..self.value.." of "..self.target_value) logPrint("Dialog: "..self.value.." of "..self.target_value)
self:updateContents() self:updateContents()
end end
elseif not love.mouse.isDown(1) then elseif not love.mouse.isDown(1) then
self.clicked = false self.clicked = false
end end
end end
function interfaceDialog:Draw() function interfaceDialog:Draw()
local c1, c2, c3, a = love.graphics.getColor() local c1, c2, c3, a = love.graphics.getColor()
love.graphics.setColor(self.style.color[1],self.style.color[2],self.style.color[3],self.style.alpha) love.graphics.setColor(self.style.color[1],self.style.color[2],self.style.color[3],self.style.alpha)
love.graphics.rectangle( love.graphics.rectangle(
"fill", "fill",
self.pos.x*self.style.scale_x*self.style.scale_proportion, self.pos.x*self.style.scale_x*self.style.scale_proportion,
self.pos.y*self.style.scale_y*self.style.scale_proportion, self.pos.y*self.style.scale_y*self.style.scale_proportion,
self.size.w*self.style.scale_x*self.style.scale_proportion, self.size.w*self.style.scale_x*self.style.scale_proportion,
self.size.h*self.style.scale_y*self.style.scale_proportion) self.size.h*self.style.scale_y*self.style.scale_proportion)
love.graphics.setColor(self.style.color2[1],self.style.color2[2],self.style.color2[3],self.style.alpha) love.graphics.setColor(self.style.color2[1],self.style.color2[2],self.style.color2[3],self.style.alpha)
love.graphics.rectangle( love.graphics.rectangle(
"line", "line",
self.pos.x*self.style.scale_x*self.style.scale_proportion, self.pos.x*self.style.scale_x*self.style.scale_proportion,
self.pos.y*self.style.scale_y*self.style.scale_proportion, self.pos.y*self.style.scale_y*self.style.scale_proportion,
self.size.w*self.style.scale_x*self.style.scale_proportion, self.size.w*self.style.scale_x*self.style.scale_proportion,
self.size.h*self.style.scale_y*self.style.scale_proportion) self.size.h*self.style.scale_y*self.style.scale_proportion)
if self.contents ~= nil then if self.contents ~= nil then
love.graphics.printf(self.contents[2],self.pos.x+10,self.pos.y+(self.size.h/2),100,"left") love.graphics.printf(self.contents[2],self.pos.x+10,self.pos.y+(self.size.h/2),100,"left")
love.graphics.printf(self.contents[1],self.pos.x+(self.size.w/2),self.pos.y+(self.size.h/2),100,"center") love.graphics.printf(self.contents[1],self.pos.x+(self.size.w/2),self.pos.y+(self.size.h/2),100,"center")
love.graphics.printf(self.contents[3],self.pos.x+(self.size.w)-10,self.pos.y+(self.size.h/2),100,"right") love.graphics.printf(self.contents[3],self.pos.x+(self.size.w)-10,self.pos.y+(self.size.h/2),100,"right")
else else
love.graphics.printf("ERROR",self.pos.x+(self.size.w/2),self.pos.y+(self.size.h/2),100,"center") love.graphics.printf("ERROR",self.pos.x+(self.size.w/2),self.pos.y+(self.size.h/2),100,"center")
end end
love.graphics.setColor(c1,c2,c3,a) love.graphics.setColor(c1,c2,c3,a)
end end

View File

@ -1,7 +1,7 @@
DialogSequence = {} DialogSequence = {}
DialogSequence.Example = { DialogSequence.Example = {
{Locale.dialogue.example[1],Locale.name.fairy}, {Locale.dialogue.example[1],Locale.name.fairy},
{Locale.dialogue.example[2],Locale.name.chaos}, {Locale.dialogue.example[2],Locale.name.chaos},
{Locale.dialogue.example[3],Locale.name.life} {Locale.dialogue.example[3],Locale.name.life}
} }

View File

@ -2,7 +2,7 @@ return {
name = "test", name = "test",
tileset = tileset.library, tileset = tileset.library,
properties = { properties = {
darkness = true darkness = true
}, },
tiles = { tiles = {
{ 1, 4, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, { 1, 4, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},

View File

@ -1,6 +1,6 @@
music = {} music = {}
music.placeholder = { music.placeholder = {
path = "assets/music/communistmanifesto.mp3", path = "assets/music/communistmanifesto.mp3",
type = "stream", type = "stream",
loop = true loop = true
} }

View File

@ -1,23 +1,23 @@
Shader = {} Shader = {}
Shader.RadiusGradient = love.graphics.newShader[[ Shader.RadiusGradient = love.graphics.newShader[[
uniform float pos_x; uniform float pos_x;
uniform float pos_y; uniform float pos_y;
uniform float range; uniform float range;
uniform float scale; uniform float scale;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
vec4 pixel = Texel(texture, texture_coords );//This is the current pixel color vec4 pixel = Texel(texture, texture_coords );//This is the current pixel color
float distance_x = pos_x - screen_coords.x / scale; float distance_x = pos_x - screen_coords.x / scale;
float distance_y = pos_y - screen_coords.y / scale; float distance_y = pos_y - screen_coords.y / scale;
float distance = sqrt( pow(distance_x,2) + pow(distance_y,2) ) ; float distance = sqrt( pow(distance_x,2) + pow(distance_y,2) ) ;
if (distance < range){ if (distance < range){
float alpha = 1-(5*distance/range); float alpha = 1-(5*distance/range);
if (pixel.a > alpha){ if (pixel.a > alpha){
pixel.a = alpha; pixel.a = alpha;
} }
} }
return pixel * color * color; return pixel * color * color;
} }
]] ]]

View File

@ -1,349 +1,349 @@
local properties = {} local properties = {}
properties[1] = { properties[1] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[2] = { properties[2] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[3] = { properties[3] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[4] = { properties[4] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[5] = { properties[5] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[6] = { properties[6] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[7] = { properties[7] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[8] = { properties[8] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[9] = { properties[9] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[10] = { properties[10] = {
type = "half_bottom", type = "half_bottom",
depth = "foreground" depth = "foreground"
} }
properties[11] = { properties[11] = {
type = "half_bottom", type = "half_bottom",
depth = "foreground" depth = "foreground"
} }
properties[12] = { properties[12] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[13] = { properties[13] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[14] = { properties[14] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[15] = { properties[15] = {
type = "half_right", type = "half_right",
depth = "foreground" depth = "foreground"
} }
properties[16] = { properties[16] = {
type = "half_left", type = "half_left",
depth = "foreground" depth = "foreground"
} }
properties[17] = { properties[17] = {
type = "half_bottom", type = "half_bottom",
depth = "foreground" depth = "foreground"
} }
properties[18] = { properties[18] = {
type = "half_top", type = "half_top",
depth = "foreground" depth = "foreground"
} }
properties[19] = { properties[19] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[20] = { properties[20] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[21] = { properties[21] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[22] = { properties[22] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[23] = { properties[23] = {
type = "half_top", type = "half_top",
depth = "foreground" depth = "foreground"
} }
properties[24] = { properties[24] = {
type = "half_top", type = "half_top",
depth = "foreground" depth = "foreground"
} }
properties[25] = { properties[25] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[26] = { properties[26] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[27] = { properties[27] = {
type = "ramp2_bot_right_half", type = "ramp2_bot_right_half",
depth = "foreground" depth = "foreground"
} }
properties[28] = { properties[28] = {
type = "ramp2_bot_right_whole", type = "ramp2_bot_right_whole",
depth = "foreground" depth = "foreground"
} }
properties[29] = { properties[29] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[30] = { properties[30] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[31] = { properties[31] = {
type = "ramp2_bot_left_whole", type = "ramp2_bot_left_whole",
depth = "foreground" depth = "foreground"
} }
properties[32] = { properties[32] = {
type = "ramp2_bot_left_half", type = "ramp2_bot_left_half",
depth = "foreground" depth = "foreground"
} }
properties[33] = { properties[33] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[34] = { properties[34] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[35] = { properties[35] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[36] = { properties[36] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[37] = { properties[37] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[38] = { properties[38] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[39] = { properties[39] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[40] = { properties[40] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[41] = { properties[41] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[42] = { properties[42] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[43] = { properties[43] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[44] = { properties[44] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[45] = { properties[45] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[46] = { properties[46] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[47] = { properties[47] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[48] = { properties[48] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[49] = { properties[49] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[50] = { properties[50] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[51] = { properties[51] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[52] = { properties[52] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[53] = { properties[53] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[54] = { properties[54] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[55] = { properties[55] = {
type = "empty", type = "empty",
depth = "foreground", depth = "foreground",
light = 60 light = 60
} }
properties[56] = { properties[56] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[57] = { properties[57] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[58] = { properties[58] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[59] = { properties[59] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[60] = { properties[60] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[61] = { properties[61] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[62] = { properties[62] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[63] = { properties[63] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[64] = { properties[64] = {
type = "empty", type = "empty",
depth = "foreground" depth = "foreground"
} }
properties[65] = { properties[65] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[66] = { properties[66] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[67] = { properties[67] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[68] = { properties[68] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[119] = { properties[119] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
return properties return properties

View File

@ -1,94 +1,94 @@
local properties = {} local properties = {}
properties[1] = { properties[1] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[2] = { properties[2] = {
type = "emtpy", type = "emtpy",
depth = "foreground" depth = "foreground"
} }
properties[3] = { properties[3] = {
type = "emtpy", type = "emtpy",
depth = "foreground" depth = "foreground"
} }
properties[4] = { properties[4] = {
type = "emtpy", type = "emtpy",
depth = "foreground" depth = "foreground"
} }
properties[5] = { properties[5] = {
type = "emtpy", type = "emtpy",
depth = "background" depth = "background"
} }
properties[6] = { properties[6] = {
type = "emtpy", type = "emtpy",
depth = "background" depth = "background"
} }
properties[7] = { properties[7] = {
type = "emtpy", type = "emtpy",
depth = "background" depth = "background"
} }
properties[13] = { properties[13] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[14] = { properties[14] = {
type = "whole", type = "whole",
depth = "foreground" depth = "foreground"
} }
properties[25] = { properties[25] = {
overlay = {17,19,21,23}, overlay = {17,19,21,23},
type = "emtpy", type = "emtpy",
depth = "background" depth = "background"
} }
properties[26] = { properties[26] = {
overlay = {18,20,22,24}, overlay = {18,20,22,24},
type = "emtpy", type = "emtpy",
depth = "background" depth = "background"
} }
properties[37] = { properties[37] = {
overlay = {29,31,33,35,41,43,45,47}, overlay = {29,31,33,35,41,43,45,47},
type = "emtpy", type = "emtpy",
depth = "background" depth = "background"
} }
properties[38] = { properties[38] = {
overlay = {30,32,34,36,42,44,46,48}, overlay = {30,32,34,36,42,44,46,48},
type = "emtpy", type = "emtpy",
depth = "background" depth = "background"
} }
properties[49] = { properties[49] = {
overlay = {53,55,57,59}, overlay = {53,55,57,59},
type = "emtpy", type = "emtpy",
depth = "background" depth = "background"
} }
properties[50] = { properties[50] = {
overlay = {54,56,58,60}, overlay = {54,56,58,60},
type = "emtpy", type = "emtpy",
depth = "background" depth = "background"
} }
properties[61] = { properties[61] = {
type = "bottom_hazard", type = "bottom_hazard",
depth = "foreground" depth = "foreground"
} }
properties[62] = { properties[62] = {
type = "top_hazard", type = "top_hazard",
depth = "foreground" depth = "foreground"
} }
return properties return properties