From 487ac002f5c7208b2f332761eeb4ba2dbdb737a3 Mon Sep 17 00:00:00 2001 From: WesleyCSJ Date: Tue, 11 Aug 2020 22:31:35 -0300 Subject: [PATCH] Love2D 11.3 port --- conf.lua | 2 +- lib/multisource.lua | 6 +++--- lib/sti.lua | 12 ++++++------ main.lua | 4 ++-- src/assets.lua | 14 +++++++------- src/entities/TransitionScreen.lua | 2 +- src/states/Intro.lua | 2 +- src/systems/DrawBackgroundSystem.lua | 4 ++-- src/systems/SpriteSystem.lua | 4 ++-- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/conf.lua b/conf.lua index f10eca5..3dc904a 100644 --- a/conf.lua +++ b/conf.lua @@ -1,6 +1,6 @@ function love.conf(t) t.identity = nil - t.version = "0.10.1" + t.version = "11.3" t.console = false t.window.title = "Commando Kibbles" t.window.icon = nil diff --git a/lib/multisource.lua b/lib/multisource.lua index 001a2cf..c36000c 100644 --- a/lib/multisource.lua +++ b/lib/multisource.lua @@ -20,7 +20,7 @@ function MultiSource:cleanup(older_than) for instance, lastPlayed in pairs(self.instances) do local age = now - lastPlayed - if age > older_than and instance:isStopped() then + if age > older_than and not instance:isPlaying() then self.instances[instance] = nil end end @@ -28,7 +28,7 @@ end function MultiSource:getStoppedOrNewInstance() for instance in pairs(self.instances) do - if instance:isStopped() then return instance end + if not instance:isPlaying() then return instance end end return self.source:clone() end @@ -88,4 +88,4 @@ multisource.new = function(source) return setmetatable({source = source, instances = {}}, MultiSourceMt) end -return multisource \ No newline at end of file +return multisource diff --git a/lib/sti.lua b/lib/sti.lua index 907cd88..4d361d7 100644 --- a/lib/sti.lua +++ b/lib/sti.lua @@ -876,9 +876,9 @@ function Map:draw() end function Map:drawLayer(layer) - framework.setColor(255, 255, 255, 255 * layer.opacity) + framework.setColor(1, 1, 1, layer.opacity) layer:draw() - framework.setColor(255, 255, 255, 255) + framework.setColor(1, 1, 1, 1) end function Map:drawTileLayer(layer) @@ -919,10 +919,10 @@ function Map:drawObjectLayer(layer) assert(layer.type == "objectgroup", "Invalid layer type: " .. layer.type .. ". Layer must be of type: objectgroup") - local line = { 160, 160, 160, 255 * layer.opacity } - local fill = { 160, 160, 160, 255 * layer.opacity * 0.2 } - local shadow = { 0, 0, 0, 255 * layer.opacity } - local reset = { 255, 255, 255, 255 * layer.opacity } + local line = { 0.63, 0.63, 0.63, layer.opacity } + local fill = { 0.63, 0.63, 0.63, layer.opacity * 0.2 } + local shadow = { 0, 0, 0, layer.opacity } + local reset = { 1, 1, 1, layer.opacity } local function sortVertices(obj) local vertices = {{},{}} diff --git a/main.lua b/main.lua index 26869bc..61a5ae1 100644 --- a/main.lua +++ b/main.lua @@ -32,9 +32,9 @@ end function love.draw() if paused then - love.graphics.setColor(90, 90, 90, 255) + love.graphics.setColor(0.35, 0.35, 0.35, 1) love.graphics.draw(pauseCanvas, 0, 0) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) love.graphics.setFont(assets.fnt_hud) love.graphics.printf("Paused - P to Resume", love.graphics.getWidth() * 0.5 - 125, love.graphics.getHeight() * 0.4, 250, "center") else diff --git a/src/assets.lua b/src/assets.lua index 9efc2ba..bfabf1a 100644 --- a/src/assets.lua +++ b/src/assets.lua @@ -12,14 +12,14 @@ assets.img_explosion = love.graphics.newImage("assets/explosion.png") assets.img_pig = love.graphics.newImage("assets/pig.png") assets.img_spawner = love.graphics.newImage("assets/spawner.png") -assets.snd_catjump = multisource.new(love.audio.newSource("assets/catjump.wav")) -assets.snd_cannon = multisource.new(love.audio.newSource("assets/cannon.wav")) -assets.snd_thud = multisource.new(love.audio.newSource("assets/thud.wav")) -assets.snd_meow = multisource.new(love.audio.newSource("assets/meow.ogg")) -assets.snd_oink = multisource.new(love.audio.newSource("assets/oink.ogg")) -assets.snd_yay = multisource.new(love.audio.newSource("assets/yay.wav")) +assets.snd_catjump = multisource.new(love.audio.newSource("assets/catjump.wav", "static")) +assets.snd_cannon = multisource.new(love.audio.newSource("assets/cannon.wav", "static")) +assets.snd_thud = multisource.new(love.audio.newSource("assets/thud.wav", "static")) +assets.snd_meow = multisource.new(love.audio.newSource("assets/meow.ogg", "static")) +assets.snd_oink = multisource.new(love.audio.newSource("assets/oink.ogg", "static")) +assets.snd_yay = multisource.new(love.audio.newSource("assets/yay.wav", "static")) -assets.snd_music = love.audio.newSource("assets/music.ogg") +assets.snd_music = love.audio.newSource("assets/music.ogg", "stream") assets.fnt_hud = love.graphics.newFont("assets/font.ttf", 48) assets.fnt_smallhud = love.graphics.newFont("assets/font.ttf", 32) diff --git a/src/entities/TransitionScreen.lua b/src/entities/TransitionScreen.lua index 746a9aa..c40dfa8 100644 --- a/src/entities/TransitionScreen.lua +++ b/src/entities/TransitionScreen.lua @@ -18,7 +18,7 @@ end function TransitionScreen:drawHud(dt) local r1, g1, b1, a = love.graphics.getColor() - love.graphics.setColor(0, 0, 0, self.alpha * 255) + love.graphics.setColor(0, 0, 0, self.alpha) love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight()) love.graphics.setColor(r1, g1, b1, a) end diff --git a/src/states/Intro.lua b/src/states/Intro.lua index f065217..99ca220 100644 --- a/src/states/Intro.lua +++ b/src/states/Intro.lua @@ -29,7 +29,7 @@ function Intro:load() require ("src.systems.HudSystem")("hudBg"), require ("src.systems.HudSystem")("hudFg"), TransitionScreen(), - ScreenSplash(0.5, 0.2, "Cammando Kibbles"), + ScreenSplash(0.5, 0.2, "Commando Kibbles"), ScreenSplash(0, 0, "Created by bakpakin for Ludum Dare 32", 300, assets.fnt_reallysmallhud, "left", 20, 20), ScreenSplash(0.5, 0.36, "Press Space to Start", 500, assets.fnt_smallhud), ScreenSplash(0.5, 0.45, "Controls:\nMove - WASD\nRotate Cannon - Arrow Keys\nFire - Down\nToggle Fullscreen - \\\nToggle Music - M\nPause - P\nEscape - Quit", 800, assets.fnt_reallysmallhud) diff --git a/src/systems/DrawBackgroundSystem.lua b/src/systems/DrawBackgroundSystem.lua index d3ead9d..ade294e 100644 --- a/src/systems/DrawBackgroundSystem.lua +++ b/src/systems/DrawBackgroundSystem.lua @@ -1,12 +1,12 @@ local DrawBackgroundSystem = tiny.system(class "DrawBackgroundSystem") function DrawBackgroundSystem:init(r, g, b) - self.r, self.g, self.b = r, g, b + self.r, self.g, self.b = (r / 255), (g / 255), (b / 255) end function DrawBackgroundSystem:update(dt) local r1, g1, b1, a = love.graphics.getColor() - love.graphics.setColor(self.r, self.g, self.b, 255) + love.graphics.setColor(self.r, self.g, self.b, 1) love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight()) love.graphics.setColor(r1, g1, b1, a) end diff --git a/src/systems/SpriteSystem.lua b/src/systems/SpriteSystem.lua index d7482c1..0210136 100644 --- a/src/systems/SpriteSystem.lua +++ b/src/systems/SpriteSystem.lua @@ -11,7 +11,7 @@ end function SpriteSystem:postProcess(dt) self.camera:remove() - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) end function SpriteSystem:process(e, dt) @@ -19,7 +19,7 @@ function SpriteSystem:process(e, dt) local alpha = e.alpha or 1 local pos, sprite, scale, rot, offset = e.pos, e.sprite, e.scale, e.rot, e.offset local sx, sy, r, ox, oy = scale and scale.x or 1, scale and scale.y or 1, rot or 0, offset and offset.x or 0, offset and offset.y or 0 - love.graphics.setColor(255, 255, 255, math.max(0, math.min(1, alpha)) * 255) + love.graphics.setColor(1, 1, 1, math.max(0, math.min(1, alpha))) if an then an.flippedH = e.flippedH or false an.flippedV = e.flippedV or false