--import media --import spritesheets local spritesheets = {} --load jsons --load player jumping spritesheets["player_jump"] = peachy.new("assets/images/spritesheets/player.json", love.graphics.newImage("assets/images/spritesheets/player.png"), "Jump") --load player walking left spritesheets["player_walk_left"] = peachy.new("assets/images/spritesheets/player.json", love.graphics.newImage("assets/images/spritesheets/player.png"), "Walk_left") --load player walking right spritesheets["player_walk_right"] = peachy.new("assets/images/spritesheets/player.json", love.graphics.newImage("assets/images/spritesheets/player.png"), "Walk_right") --load player idle spritesheets["player_idle"] = peachy.new("assets/images/spritesheets/player.json", love.graphics.newImage("assets/images/spritesheets/player.png"), "Idle") --load player dying spritesheets["player_die"] = peachy.new("assets/images/spritesheets/player.json", love.graphics.newImage("assets/images/spritesheets/player.png"), "Die") --load player DEFAULT spritesheets["player_default"] = peachy.new("assets/images/spritesheets/player.json", love.graphics.newImage("assets/images/spritesheets/player.png"), "Default") --load backgrounds local backgrounds = {} for i, file in ipairs(love.filesystem.getDirectoryItems("assets/images/backgrounds")) do if file:find(".png") then --load backgrounds print(i) backgrounds[i] = love.graphics.newImage("assets/images/backgrounds/"..file) end end --load sound effects local sound_effects = {} for i, file in ipairs(love.filesystem.getDirectoryItems("assets/sounds/effects")) do if file:find(".ogg") then --load sound effects local keyname = file:gsub(".ogg", "") sound = love.audio.newSource("assets/sounds/effects/"..file, "static") sound_effects[keyname] = {} sound_effects[keyname].volume = 1 sound_effects[keyname].timer = love.timer.getTime() sound_effects[keyname].first_play = true sound_effects[keyname].sound = sound sound_effects[keyname].duration = sound:getDuration() sound_effects[keyname].timer_min = sound:getDuration() * 2 sound_effects[keyname].play = function(self) if (love.timer.getTime() - self.timer) >= self.timer_min or self.first_play then self.timer = love.timer.getTime() self.first_play = false self.sound:setVolume(self.volume) self.sound:play() end end end end --load music local music = {} for i, file in ipairs(love.filesystem.getDirectoryItems("assets/sounds/music")) do if file:find(".ogg") then --load music music[file:sub(1, -5)] = love.audio.newSource("assets/sounds/music/"..file, "stream") end end return { spritesheets = spritesheets, backgrounds = backgrounds, sound_effects = sound_effects, music = music }