audio manager, moved stuff from (removed) enums into animations, tiledata. new sfx and music enum files
This commit is contained in:
parent
cbcf90de2d
commit
2ce41d541f
Binary file not shown.
|
@ -0,0 +1,123 @@
|
|||
-- all these are linear animations, maybe in the future make proper animations?
|
||||
animation = {}
|
||||
|
||||
-- cursed book
|
||||
animation.cursed_book = {}
|
||||
animation.cursed_book.attack_loop = {
|
||||
path = "assets/entities/cursed_book/attack_loop",
|
||||
frames = 1,
|
||||
speed = 0
|
||||
}
|
||||
animation.cursed_book.attack_transition = {
|
||||
path = "assets/entities/cursed_book/attack_transition",
|
||||
frames = 5,
|
||||
speed = 1/16
|
||||
}
|
||||
animation.cursed_book.flying = {
|
||||
path = "assets/entities/cursed_book/flying",
|
||||
frames = 11,
|
||||
speed = 1/16
|
||||
}
|
||||
animation.cursed_book.spawn = {
|
||||
path = "assets/entities/cursed_book/spawn",
|
||||
frames = 5,
|
||||
speed = 0
|
||||
}
|
||||
|
||||
-- particles
|
||||
animation.particle = {}
|
||||
animation.particle.simple = {
|
||||
path = "assets/entities/particle/simple",
|
||||
frames = 4,
|
||||
speed = 1/4
|
||||
}
|
||||
|
||||
-- fairy
|
||||
animation.fairy = {}
|
||||
animation.fairy.flying = {
|
||||
path = "assets/entities/fairy/flying",
|
||||
frames = 2,
|
||||
speed = 1/30
|
||||
}
|
||||
|
||||
-- decoration
|
||||
animation.decoration = {}
|
||||
animation.decoration.candelabra = {
|
||||
path = "assets/entities/decoration/candelabra",
|
||||
frames = 8,
|
||||
speed = 1/6
|
||||
}
|
||||
|
||||
-- kupo
|
||||
animation.kupo = {}
|
||||
animation.kupo.body = {
|
||||
path = "assets/entities/kupo/kupo",
|
||||
frames = 4,
|
||||
speed = 1/8
|
||||
}
|
||||
animation.kupo.bow = {
|
||||
path = "assets/entities/kupo/kupo_bow",
|
||||
frames = 6,
|
||||
speed = 1/10
|
||||
}
|
||||
animation.kupo.arrow = {
|
||||
path = "assets/entities/kupo/kupo_arrow",
|
||||
frames = 1,
|
||||
speed = 0
|
||||
}
|
||||
|
||||
-- moth mask
|
||||
animation.moth_mask = {}
|
||||
animation.moth_mask.idle = {
|
||||
path = "assets/entities/nancy/moth_mask/idle",
|
||||
frames = 4,
|
||||
speed = 1/8
|
||||
}
|
||||
animation.moth_mask.run = {
|
||||
path = "assets/entities/nancy/moth_mask/run",
|
||||
frames = 6,
|
||||
speed = 1/8
|
||||
}
|
||||
animation.moth_mask.fall = {
|
||||
path = "assets/entities/nancy/moth_mask/fall",
|
||||
frames = 3,
|
||||
speed = 1/8
|
||||
}
|
||||
animation.moth_mask.jump = {
|
||||
path = "assets/entities/nancy/moth_mask/jump",
|
||||
frames = 3,
|
||||
speed = 1/8
|
||||
}
|
||||
|
||||
-- nancy
|
||||
animation.nancy = {}
|
||||
animation.nancy.idle = {
|
||||
path = "assets/entities/nancy/idle",
|
||||
frames = 4,
|
||||
speed = 1/8
|
||||
}
|
||||
animation.nancy.run = {
|
||||
path = "assets/entities/nancy/run",
|
||||
frames = 6,
|
||||
speed = 1/8
|
||||
}
|
||||
animation.nancy.fall = {
|
||||
path = "assets/entities/nancy/fall",
|
||||
frames = 3,
|
||||
speed = 1/8
|
||||
}
|
||||
animation.nancy.jump = {
|
||||
path = "assets/entities/nancy/jump",
|
||||
frames = 3,
|
||||
speed = 1/8
|
||||
}
|
||||
|
||||
-- animation initializer
|
||||
for _, object in pairs(animation) do
|
||||
for _, anim in pairs(object) do
|
||||
anim.imgs = {}
|
||||
for i = 1, anim.frames do
|
||||
table.insert(anim.imgs,love.graphics.newImage(anim.path..tostring(i)..".png"))
|
||||
end
|
||||
end
|
||||
end
|
143
data/enums.lua
143
data/enums.lua
|
@ -1,143 +0,0 @@
|
|||
-- animationsç
|
||||
-- all these are linear animations, maybe in the future make proper animations?
|
||||
animation = {
|
||||
cursed_book = {
|
||||
attack_loop = {
|
||||
path = "assets/entities/cursed_book/attack_loop",
|
||||
frames = 1,
|
||||
speed = 0
|
||||
},
|
||||
attack_transition = {
|
||||
path = "assets/entities/cursed_book/attack_transition",
|
||||
frames = 5,
|
||||
speed = 1/16
|
||||
},
|
||||
flying = {
|
||||
path = "assets/entities/cursed_book/flying",
|
||||
frames = 11,
|
||||
speed = 1/16
|
||||
},
|
||||
spawn = {
|
||||
path = "assets/entities/cursed_book/spawn",
|
||||
frames = 5,
|
||||
speed = 0
|
||||
}
|
||||
},
|
||||
particle = {
|
||||
simple = {
|
||||
path = "assets/entities/particle/simple",
|
||||
frames = 4,
|
||||
speed = 1/4
|
||||
}
|
||||
},
|
||||
fairy = {
|
||||
flying = {
|
||||
path = "assets/entities/fairy/flying",
|
||||
frames = 2,
|
||||
speed = 1/30
|
||||
}
|
||||
},
|
||||
decoration = {
|
||||
candelabra = {
|
||||
path = "assets/entities/decoration/candelabra",
|
||||
frames = 8,
|
||||
speed = 1/6
|
||||
}
|
||||
},
|
||||
kupo = {
|
||||
body = {
|
||||
path = "assets/entities/kupo/kupo",
|
||||
frames = 4,
|
||||
speed = 1/8
|
||||
},
|
||||
bow = {
|
||||
path = "assets/entities/kupo/kupo_bow",
|
||||
frames = 6,
|
||||
speed = 1/10
|
||||
},
|
||||
arrow = {
|
||||
path = "assets/entities/kupo/kupo_arrow",
|
||||
frames = 1,
|
||||
speed = 0
|
||||
}
|
||||
},
|
||||
moth_mask = {
|
||||
idle = {
|
||||
path = "assets/entities/nancy/moth_mask/idle",
|
||||
frames = 4,
|
||||
speed = 1/8
|
||||
},
|
||||
run = {
|
||||
path = "assets/entities/nancy/moth_mask/run",
|
||||
frames = 6,
|
||||
speed = 1/8
|
||||
},
|
||||
fall = {
|
||||
path = "assets/entities/nancy/moth_mask/fall",
|
||||
frames = 3,
|
||||
speed = 1/8
|
||||
},
|
||||
jump = {
|
||||
path = "assets/entities/nancy/moth_mask/jump",
|
||||
frames = 3,
|
||||
speed = 1/8
|
||||
}
|
||||
},
|
||||
nancy = {
|
||||
idle = {
|
||||
path = "assets/entities/nancy/idle",
|
||||
frames = 4,
|
||||
speed = 1/8
|
||||
},
|
||||
run = {
|
||||
path = "assets/entities/nancy/run",
|
||||
frames = 6,
|
||||
speed = 1/8
|
||||
},
|
||||
fall = {
|
||||
path = "assets/entities/nancy/fall",
|
||||
frames = 3,
|
||||
speed = 1/8
|
||||
},
|
||||
jump = {
|
||||
path = "assets/entities/nancy/jump",
|
||||
frames = 3,
|
||||
speed = 1/8
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- animation loader
|
||||
-- im unsure if this is too memory expensive (probably)
|
||||
-- this should go elsewhere, maybe
|
||||
for _, object in pairs(animation) do
|
||||
for _, anim in pairs(object) do
|
||||
anim.imgs = {}
|
||||
for i = 1, anim.frames do
|
||||
table.insert(anim.imgs,love.graphics.newImage(anim.path..tostring(i)..".png"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
levelProperties = {
|
||||
pos = {
|
||||
x = 0,
|
||||
y = 0
|
||||
},
|
||||
-- im unsure why there's offset at all, here
|
||||
offset = {
|
||||
x = 0,
|
||||
y = 0
|
||||
}
|
||||
}
|
||||
|
||||
tileset = {
|
||||
bricks = love.graphics.newImage("assets/tileset/bricks.png"),
|
||||
library = love.graphics.newImage("assets/tileset/library.png")
|
||||
}
|
||||
|
||||
tileProperties = {
|
||||
width = 16,
|
||||
height = 16,
|
||||
scale = 1,
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
music = {}
|
||||
music.placeholder = {
|
||||
path = "assets/music/communistmanifesto.mp3",
|
||||
type = "stream",
|
||||
loop = true
|
||||
}
|
|
@ -1,12 +1,16 @@
|
|||
-- data
|
||||
require "data/enums"
|
||||
require "data/animations"
|
||||
require "data/shaders"
|
||||
require "data/tiledata"
|
||||
require "data/music"
|
||||
require "data/sfx"
|
||||
require "data/scripts/locale"
|
||||
-- support functions
|
||||
require "data/scripts/math"
|
||||
require "data/scripts/hex"
|
||||
require "data/scripts/in_out"
|
||||
-- classes
|
||||
require "data/scripts/audio"
|
||||
require "data/scripts/entity"
|
||||
require "data/scripts/animation"
|
||||
require "data/scripts/collision"
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
-- snippet from
|
||||
-- https://love2d.org/wiki/Minimalist_Sound_Manager
|
||||
-- <3
|
||||
do
|
||||
-- will hold the currently playing sources
|
||||
local sources = {}
|
||||
|
||||
-- check for sources that finished playing and remove them
|
||||
-- add to love.update
|
||||
function love.audio.update()
|
||||
local remove = {}
|
||||
for _,s in pairs(sources) do
|
||||
if not s:isPlaying() then
|
||||
remove[#remove + 1] = s
|
||||
end
|
||||
end
|
||||
|
||||
for i,s in ipairs(remove) do
|
||||
sources[s] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- overwrite love.audio.play to create and register source if needed
|
||||
local play = love.audio.play
|
||||
function love.audio.play(audio)
|
||||
local what = audio.path
|
||||
local how = audio.type
|
||||
local loop = audio.loop
|
||||
local src = what
|
||||
if type(what) ~= "userdata" or not what:typeOf("Source") then
|
||||
src = love.audio.newSource(what, how)
|
||||
src:setLooping(loop or false)
|
||||
end
|
||||
|
||||
play(src)
|
||||
sources[src] = src
|
||||
return src
|
||||
end
|
||||
|
||||
-- stops a source
|
||||
local stop = love.audio.stop
|
||||
function love.audio.stop(src)
|
||||
if not src then return end
|
||||
stop(src)
|
||||
sources[src] = nil
|
||||
end
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
levelProperties = {
|
||||
pos = {
|
||||
x = 0,
|
||||
y = 0
|
||||
},
|
||||
-- im unsure why there's offset at all, here
|
||||
offset = {
|
||||
x = 0,
|
||||
y = 0
|
||||
}
|
||||
}
|
||||
|
||||
tileset = {
|
||||
bricks = love.graphics.newImage("assets/tileset/bricks.png"),
|
||||
library = love.graphics.newImage("assets/tileset/library.png")
|
||||
}
|
||||
|
||||
tileProperties = {
|
||||
width = 16,
|
||||
height = 16,
|
||||
scale = 1,
|
||||
}
|
20
main.lua
20
main.lua
|
@ -50,21 +50,25 @@ function love.load()
|
|||
language = "ENG"
|
||||
LocaleLoad(language)
|
||||
|
||||
main_Player = Player:New(75,50)
|
||||
|
||||
--Kupo:New(100,150)
|
||||
--Kupo:New(300,150)
|
||||
Decoration:New(200,89,animation.decoration.candelabra,80)
|
||||
Fairy:New(200,88)
|
||||
--CursedBook:New(180,68)
|
||||
|
||||
gravity = 0.2
|
||||
-- Debug and log stuff
|
||||
memoryUsage, dtcount = 0, 0
|
||||
logPrint("mothback: "..collectgarbage("count").." kB, Loading time: "..os.clock().." seconds")
|
||||
|
||||
main_Player = Player:New(75,50)
|
||||
|
||||
--Kupo:New(100,150)
|
||||
--Kupo:New(300,150)
|
||||
Decoration:New(200,89,animation.decoration.candelabra,80)
|
||||
Fairy:New(200,88)
|
||||
--CursedBook:New(180,68)
|
||||
|
||||
love.audio.play(music.placeholder)
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
-- audio update
|
||||
love.audio.update()
|
||||
-- fps counter
|
||||
if fps_second >= 1 then
|
||||
fps_second = fps_second - 1
|
||||
|
|
Loading…
Reference in New Issue