From 22aa2f19480f21abca02b6f23b1ecfa96336d803 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 11 May 2018 22:33:44 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Updated=20code=20to=20work=20with=20l=C3=B6?= =?UTF-8?q?ve2d=2011.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/push.lua | 127 ++++++++++++++++++++----------- main.lua | 7 +- src/Dependencies.lua | 24 +++--- src/battle/BattleSprite.lua | 4 +- src/constants.lua | 2 +- src/gui/Panel.lua | 8 +- src/gui/ProgressBar.lua | 14 ++-- src/states/game/BattleState.lua | 22 +++--- src/states/game/FadeInState.lua | 6 +- src/states/game/FadeOutState.lua | 6 +- src/states/game/StartState.lua | 14 ++-- 11 files changed, 139 insertions(+), 95 deletions(-) diff --git a/lib/push.lua b/lib/push.lua index 0e0709a..0452669 100644 --- a/lib/push.lua +++ b/lib/push.lua @@ -1,12 +1,15 @@ --- push.lua v0.2 +-- push.lua v0.3 --- Copyright (c) 2017 Ulysse Ramage +-- Copyright (c) 2018 Ulysse Ramage -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +local love11 = love.getVersion() == 11 +local getDPI = love11 and love.window.getDPIScale or love.window.getPixelScale + local push = { - + defaults = { fullscreen = false, resizable = false, @@ -14,13 +17,10 @@ local push = { highdpi = true, canvas = true } - + } setmetatable(push, push) ---TODO: rendering resolution? ---TODO: clean up code - function push:applySettings(settings) for k, v in pairs(settings) do self["_" .. k] = v @@ -38,12 +38,12 @@ function push:setupScreen(WWIDTH, WHEIGHT, RWIDTH, RHEIGHT, settings) self:applySettings(self.defaults) --set defaults first self:applySettings(settings) --then fill with custom settings - - love.window.setMode( self._RWIDTH, self._RHEIGHT, { + + love.window.setMode(self._RWIDTH, self._RHEIGHT, { fullscreen = self._fullscreen, resizable = self._resizable, highdpi = self._highdpi - } ) + }) self:initValues() @@ -62,25 +62,29 @@ function push:setupScreen(WWIDTH, WHEIGHT, RWIDTH, RHEIGHT, settings) end function push:setupCanvas(canvases) - table.insert(canvases, { name = "_render" }) --final render + table.insert(canvases, { name = "_render", private = true }) --final render self._canvas = true self.canvases = {} for i = 1, #canvases do - self.canvases[i] = { - name = canvases[i].name, - shader = canvases[i].shader, - canvas = love.graphics.newCanvas(self._WWIDTH, self._WHEIGHT) - } + push:addCanvas(canvases[i]) end return self end +function push:addCanvas(params) + table.insert(self.canvases, { + name = params.name, + private = params.private, + shader = params.shader, + canvas = love.graphics.newCanvas(self._WWIDTH, self._WHEIGHT) + }) +end function push:setCanvas(name) if not self._canvas then return true end - return love.graphics.setCanvas( self:getCanvasTable(name).canvas ) + return love.graphics.setCanvas(self:getCanvasTable(name).canvas) end function push:getCanvasTable(name) for i = 1, #self.canvases do @@ -98,34 +102,29 @@ function push:setShader(name, shader) end function push:initValues() - self._PSCALE = self._highdpi and love.window.getPixelScale() or 1 - + self._PSCALE = (not love11 and self._highdpi) and getDPI() or 1 + self._SCALE = { x = self._RWIDTH/self._WWIDTH * self._PSCALE, y = self._RHEIGHT/self._WHEIGHT * self._PSCALE } - + if self._stretched then --if stretched, no need to apply offset self._OFFSET = {x = 0, y = 0} else local scale = math.min(self._SCALE.x, self._SCALE.y) if self._pixelperfect then scale = math.floor(scale) end - + self._OFFSET = {x = (self._SCALE.x - scale) * (self._WWIDTH/2), y = (self._SCALE.y - scale) * (self._WHEIGHT/2)} self._SCALE.x, self._SCALE.y = scale, scale --apply same scale to X and Y end - + self._GWIDTH = self._RWIDTH * self._PSCALE - self._OFFSET.x * 2 self._GHEIGHT = self._RHEIGHT * self._PSCALE - self._OFFSET.y * 2 end ---[[ DEPRECATED ]]-- function push:apply(operation, shader) - if operation == "start" then - self:start() - elseif operation == "finish" or operation == "end" then - self:finish(shader) - end + self._drawFunctions[operation](self, shader) end function push:start() @@ -140,6 +139,40 @@ function push:start() end end +function push:applyShaders(canvas, shaders) + local _shader = love.graphics.getShader() + if #shaders <= 1 then + love.graphics.setShader(shaders[1]) + love.graphics.draw(canvas) + else + local _canvas = love.graphics.getCanvas() + + local _tmp = self:getCanvasTable("_tmp") + if not _tmp then --create temp canvas only if needed + self:addCanvas({ name = "_tmp", private = true, shader = nil }) + _tmp = self:getCanvasTable("_tmp") + end + + love.graphics.push() + love.graphics.origin() + local outputCanvas + for i = 1, #shaders do + local inputCanvas = i % 2 == 1 and canvas or _tmp.canvas + outputCanvas = i % 2 == 0 and canvas or _tmp.canvas + love.graphics.setCanvas(outputCanvas) + love.graphics.clear() + love.graphics.setShader(shaders[i]) + love.graphics.draw(inputCanvas) + love.graphics.setCanvas(inputCanvas) + end + love.graphics.pop() + + love.graphics.setCanvas(_canvas) + love.graphics.draw(outputCanvas) + end + love.graphics.setShader(_shader) +end + function push:finish(shader) love.graphics.setBackgroundColor(unpack(self._borderColor)) if self._canvas then @@ -147,25 +180,32 @@ function push:finish(shader) love.graphics.pop() - love.graphics.setColor(255, 255, 255) + local white = love11 and 1 or 255 + love.graphics.setColor(white, white, white) --draw canvas love.graphics.setCanvas(_render.canvas) - for i = 1, #self.canvases - 1 do --do not draw _render yet + for i = 1, #self.canvases do --do not draw _render yet local _table = self.canvases[i] - love.graphics.setShader(_table.shader) - love.graphics.draw(_table.canvas) + if not _table.private then + local _canvas = _table.canvas + local _shader = _table.shader + self:applyShaders(_canvas, type(_shader) == "table" and _shader or { _shader }) + end end love.graphics.setCanvas() --draw render love.graphics.translate(self._OFFSET.x, self._OFFSET.y) - love.graphics.setShader(shader or self:getCanvasTable("_render").shader) - love.graphics.draw(self:getCanvasTable("_render").canvas, 0, 0, 0, self._SCALE.x, self._SCALE.y) + local shader = shader or _render.shader + love.graphics.push() + love.graphics.scale(self._SCALE.x, self._SCALE.y) + self:applyShaders(_render.canvas, type(shader) == "table" and shader or { shader }) + love.graphics.pop() --clear canvas for i = 1, #self.canvases do - love.graphics.setCanvas( self.canvases[i].canvas ) + love.graphics.setCanvas(self.canvases[i].canvas) love.graphics.clear() end @@ -184,33 +224,33 @@ end function push:toGame(x, y) x, y = x - self._OFFSET.x, y - self._OFFSET.y local normalX, normalY = x / self._GWIDTH, y / self._GHEIGHT - + x = (x >= 0 and x <= self._WWIDTH * self._SCALE.x) and normalX * self._WWIDTH or nil y = (y >= 0 and y <= self._WHEIGHT * self._SCALE.y) and normalY * self._WHEIGHT or nil - + return x, y end --doesn't work - TODO function push:toReal(x, y) - return x+self._OFFSET.x, y+self._OFFSET.y + return x + self._OFFSET.x, y + self._OFFSET.y end function push:switchFullscreen(winw, winh) self._fullscreen = not self._fullscreen local windowWidth, windowHeight = love.window.getDesktopDimensions() - + if self._fullscreen then --save windowed dimensions for later self._WINWIDTH, self._WINHEIGHT = self._RWIDTH, self._RHEIGHT elseif not self._WINWIDTH or not self._WINHEIGHT then self._WINWIDTH, self._WINHEIGHT = windowWidth * .5, windowHeight * .5 end - + self._RWIDTH = self._fullscreen and windowWidth or winw or self._WINWIDTH self._RHEIGHT = self._fullscreen and windowHeight or winh or self._WINHEIGHT - + self:initValues() - + love.window.setFullscreen(self._fullscreen, "desktop") if not self._fullscreen and (winw or winh) then love.window.setMode(self._RWIDTH, self._RHEIGHT) --set window dimensions @@ -218,8 +258,7 @@ function push:switchFullscreen(winw, winh) end function push:resize(w, h) - local pixelScale = love.window.getPixelScale() - if self._highdpi then w, h = w / pixelScale, h / pixelScale end + if self._highdpi then w, h = w / self._PSCALE, h / self._PSCALE end self._RWIDTH = w self._RHEIGHT = h self:initValues() diff --git a/main.lua b/main.lua index 73fe811..9447365 100644 --- a/main.lua +++ b/main.lua @@ -42,6 +42,11 @@ require 'src/Dependencies' + +function rgb (r, g, b) + return {r / 255, g / 255, b / 255} +end + function love.load() love.window.setTitle('Poke50') love.graphics.setDefaultFilter('nearest', 'nearest') @@ -91,4 +96,4 @@ function love.draw() push:start() gStateStack:render() push:finish() -end \ No newline at end of file +end diff --git a/src/Dependencies.lua b/src/Dependencies.lua index c020281..1fb2c3b 100644 --- a/src/Dependencies.lua +++ b/src/Dependencies.lua @@ -81,15 +81,15 @@ gFonts = { } gSounds = { - ['field-music'] = love.audio.newSource('sounds/field_music.wav'), - ['battle-music'] = love.audio.newSource('sounds/battle_music.mp3'), - ['blip'] = love.audio.newSource('sounds/blip.wav'), - ['powerup'] = love.audio.newSource('sounds/powerup.wav'), - ['hit'] = love.audio.newSource('sounds/hit.wav'), - ['run'] = love.audio.newSource('sounds/run.wav'), - ['heal'] = love.audio.newSource('sounds/heal.wav'), - ['exp'] = love.audio.newSource('sounds/exp.wav'), - ['levelup'] = love.audio.newSource('sounds/levelup.wav'), - ['victory-music'] = love.audio.newSource('sounds/victory.wav'), - ['intro-music'] = love.audio.newSource('sounds/intro.mp3') -} \ No newline at end of file + ['field-music'] = love.audio.newSource('sounds/field_music.wav', "stream"), + ['battle-music'] = love.audio.newSource('sounds/battle_music.mp3', "stream"), + ['blip'] = love.audio.newSource('sounds/blip.wav', "static"), + ['powerup'] = love.audio.newSource('sounds/powerup.wav', "static"), + ['hit'] = love.audio.newSource('sounds/hit.wav', "static"), + ['run'] = love.audio.newSource('sounds/run.wav', "static"), + ['heal'] = love.audio.newSource('sounds/heal.wav', "static"), + ['exp'] = love.audio.newSource('sounds/exp.wav', "static"), + ['levelup'] = love.audio.newSource('sounds/levelup.wav', "static"), + ['victory-music'] = love.audio.newSource('sounds/victory.wav', "stream"), + ['intro-music'] = love.audio.newSource('sounds/intro.mp3', "stream") +} diff --git a/src/battle/BattleSprite.lua b/src/battle/BattleSprite.lua index c3a98cf..6c1bbdd 100644 --- a/src/battle/BattleSprite.lua +++ b/src/battle/BattleSprite.lua @@ -35,7 +35,7 @@ function BattleSprite:update(dt) end function BattleSprite:render() - love.graphics.setColor(255, 255, 255, self.opacity) + love.graphics.setColor(rgb(255, 255, 255), self.opacity) -- if blinking is set to true, we'll send 1 to the white shader, which will -- convert every pixel of the sprite to pure white @@ -46,4 +46,4 @@ function BattleSprite:render() -- reset shader love.graphics.setShader() -end \ No newline at end of file +end diff --git a/src/constants.lua b/src/constants.lua index 5decdd4..2ce106a 100644 --- a/src/constants.lua +++ b/src/constants.lua @@ -14,4 +14,4 @@ VIRTUAL_HEIGHT = 216 WINDOW_WIDTH = 1280 WINDOW_HEIGHT = 720 -TILE_SIZE = 16 \ No newline at end of file +TILE_SIZE = 16 diff --git a/src/gui/Panel.lua b/src/gui/Panel.lua index b72f629..dd962f7 100644 --- a/src/gui/Panel.lua +++ b/src/gui/Panel.lua @@ -23,14 +23,14 @@ end function Panel:render() if self.visible then - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(rgb(255, 255, 255), 255) love.graphics.rectangle('fill', self.x, self.y, self.width, self.height, 3) - love.graphics.setColor(56, 56, 56, 255) + love.graphics.setColor(rgb(56, 56, 56), 255) love.graphics.rectangle('fill', self.x + 2, self.y + 2, self.width - 4, self.height - 4, 3) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(rgb(255, 255, 255), 255) end end function Panel:toggle() self.visible = not self.visible -end \ No newline at end of file +end diff --git a/src/gui/ProgressBar.lua b/src/gui/ProgressBar.lua index 69789c9..03980d6 100644 --- a/src/gui/ProgressBar.lua +++ b/src/gui/ProgressBar.lua @@ -11,10 +11,10 @@ ProgressBar = Class{} function ProgressBar:init(def) self.x = def.x self.y = def.y - + self.width = def.width self.height = def.height - + self.color = def.color self.value = def.value @@ -38,14 +38,14 @@ function ProgressBar:render() local renderWidth = (self.value / self.max) * self.width -- draw main bar, with calculated width based on value / max - love.graphics.setColor(self.color.r, self.color.g, self.color.b, 255) - + love.graphics.setColor(rgb(self.color.r, self.color.g, self.color.b), 255) + if self.value > 0 then love.graphics.rectangle('fill', self.x, self.y, renderWidth, self.height, 3) end -- draw outline around actual bar - love.graphics.setColor(0, 0, 0, 255) + love.graphics.setColor(rgb(0, 0, 0), 255) love.graphics.rectangle('line', self.x, self.y, self.width, self.height, 3) - love.graphics.setColor(255, 255, 255, 255) -end \ No newline at end of file + love.graphics.setColor(rgb(255, 255, 255), 255) +end diff --git a/src/states/game/BattleState.lua b/src/states/game/BattleState.lua index 82cdc38..09f513c 100644 --- a/src/states/game/BattleState.lua +++ b/src/states/game/BattleState.lua @@ -23,9 +23,9 @@ function BattleState:init(player) } } - self.playerSprite = BattleSprite(self.player.party.pokemon[1].battleSpriteBack, + self.playerSprite = BattleSprite(self.player.party.pokemon[1].battleSpriteBack, -64, VIRTUAL_HEIGHT - 128) - self.opponentSprite = BattleSprite(self.opponent.party.pokemon[1].battleSpriteFront, + self.opponentSprite = BattleSprite(self.opponent.party.pokemon[1].battleSpriteFront, VIRTUAL_WIDTH, 8) -- health bars for pokemon @@ -73,7 +73,7 @@ function BattleState:init(player) end function BattleState:enter(params) - + end function BattleState:exit() @@ -91,11 +91,11 @@ end function BattleState:render() love.graphics.clear(214, 214, 214, 255) - love.graphics.setColor(45, 184, 45, 124) + love.graphics.setColor(rgb(45, 184, 45), 124) love.graphics.ellipse('fill', self.opponentCircleX, 60, 72, 24) love.graphics.ellipse('fill', self.playerCircleX, VIRTUAL_HEIGHT - 64, 72, 24) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(rgb(255, 255, 255), 255) self.opponentSprite:render() self.playerSprite:render() @@ -105,14 +105,14 @@ function BattleState:render() self.playerExpBar:render() -- render level text - love.graphics.setColor(0, 0, 0, 255) + love.graphics.setColor(rgb(0, 0, 0), 255) love.graphics.setFont(gFonts['small']) love.graphics.print('LV ' .. tostring(self.playerPokemon.level), self.playerHealthBar.x, self.playerHealthBar.y - 10) love.graphics.print('LV ' .. tostring(self.opponentPokemon.level), self.opponentHealthBar.x, self.opponentHealthBar.y + 8) love.graphics.setFont(gFonts['medium']) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(rgb(255, 255, 255), 255) end self.bottomPanel:render() @@ -134,18 +134,18 @@ function BattleState:triggerSlideIn() end function BattleState:triggerStartingDialogue() - + -- display a dialogue first for the pokemon that appeared, then the one being sent out gStateStack:push(BattleMessageState('A wild ' .. tostring(self.opponent.party.pokemon[1].name .. ' appeared!'), - + -- callback for when the battle message is closed function() gStateStack:push(BattleMessageState('Go, ' .. tostring(self.player.party.pokemon[1].name .. '!'), - + -- push a battle menu onto the stack that has access to the battle state function() gStateStack:push(BattleMenuState(self)) end)) end)) -end \ No newline at end of file +end diff --git a/src/states/game/FadeInState.lua b/src/states/game/FadeInState.lua index 8f6f089..7e8806d 100644 --- a/src/states/game/FadeInState.lua +++ b/src/states/game/FadeInState.lua @@ -25,8 +25,8 @@ function FadeInState:init(color, time, onFadeComplete) end function FadeInState:render() - love.graphics.setColor(self.r, self.g, self.b, self.opacity) + love.graphics.setColor(rgb(self.r, self.g, self.b), self.opacity) love.graphics.rectangle('fill', 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) - love.graphics.setColor(255, 255, 255, 255) -end \ No newline at end of file + love.graphics.setColor(rgb(255, 255, 255), 255) +end diff --git a/src/states/game/FadeOutState.lua b/src/states/game/FadeOutState.lua index c175e85..f57a051 100644 --- a/src/states/game/FadeOutState.lua +++ b/src/states/game/FadeOutState.lua @@ -29,8 +29,8 @@ function FadeOutState:update(dt) end function FadeOutState:render() - love.graphics.setColor(self.r, self.g, self.b, self.opacity) + love.graphics.setColor(rgb(self.r, self.g, self.b), self.opacity) love.graphics.rectangle('fill', 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) - love.graphics.setColor(255, 255, 255, 255) -end \ No newline at end of file + love.graphics.setColor(rgb(255, 255, 255), 255) +end diff --git a/src/states/game/StartState.lua b/src/states/game/StartState.lua index 5fdf73d..9b95bac 100644 --- a/src/states/game/StartState.lua +++ b/src/states/game/StartState.lua @@ -41,9 +41,9 @@ function StartState:update(dt) self.tween:remove() gStateStack:pop() - + gStateStack:push(PlayState()) - gStateStack:push(DialogueState("" .. + gStateStack:push(DialogueState("" .. "Welcome to the world of 50Mon! To start fighting monsters with your own randomly assigned" .. " monster, just walk in the tall grass! If you need to heal, just press 'P' in the field! " .. "Good luck! (Press Enter to dismiss dialogues)" @@ -57,18 +57,18 @@ function StartState:update(dt) end function StartState:render() - love.graphics.clear(188, 188, 188, 255) + love.graphics.clear(rgb(188, 188, 188), 255) - love.graphics.setColor(24, 24, 24, 255) + love.graphics.setColor(rgb(24, 24, 24), 255) love.graphics.setFont(gFonts['large']) love.graphics.printf('50-Mon!', 0, VIRTUAL_HEIGHT / 2 - 72, VIRTUAL_WIDTH, 'center') love.graphics.setFont(gFonts['medium']) love.graphics.printf('Press Enter', 0, VIRTUAL_HEIGHT / 2 + 68, VIRTUAL_WIDTH, 'center') love.graphics.setFont(gFonts['small']) - love.graphics.setColor(45, 184, 45, 124) + love.graphics.setColor(rgb(45, 184, 45), 124) love.graphics.ellipse('fill', VIRTUAL_WIDTH / 2, VIRTUAL_HEIGHT / 2 + 32, 72, 24) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(rgb(255, 255, 255), 255) love.graphics.draw(gTextures[self.sprite], self.spriteX, self.spriteY) -end \ No newline at end of file +end From 7ad4e4324aca608a9447709e6096dd49a0680862 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 11 May 2018 22:44:01 +0200 Subject: [PATCH 2/2] Added alpha to the function --- main.lua | 4 ++-- src/battle/BattleSprite.lua | 2 +- src/gui/Panel.lua | 6 +++--- src/gui/ProgressBar.lua | 6 +++--- src/states/game/BattleState.lua | 8 ++++---- src/states/game/FadeInState.lua | 4 ++-- src/states/game/FadeOutState.lua | 4 ++-- src/states/game/StartState.lua | 8 ++++---- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/main.lua b/main.lua index 9447365..b336e1d 100644 --- a/main.lua +++ b/main.lua @@ -43,8 +43,8 @@ require 'src/Dependencies' -function rgb (r, g, b) - return {r / 255, g / 255, b / 255} +function rgba (r, g, b, a) + return {r / 255, g / 255, b / 255, a / 255} end function love.load() diff --git a/src/battle/BattleSprite.lua b/src/battle/BattleSprite.lua index 6c1bbdd..79e91dc 100644 --- a/src/battle/BattleSprite.lua +++ b/src/battle/BattleSprite.lua @@ -35,7 +35,7 @@ function BattleSprite:update(dt) end function BattleSprite:render() - love.graphics.setColor(rgb(255, 255, 255), self.opacity) + love.graphics.setColor(rgba(255, 255, 255, self.opacity)) -- if blinking is set to true, we'll send 1 to the white shader, which will -- convert every pixel of the sprite to pure white diff --git a/src/gui/Panel.lua b/src/gui/Panel.lua index dd962f7..00b7859 100644 --- a/src/gui/Panel.lua +++ b/src/gui/Panel.lua @@ -23,11 +23,11 @@ end function Panel:render() if self.visible then - love.graphics.setColor(rgb(255, 255, 255), 255) + love.graphics.setColor(rgba(255, 255, 255, 255)) love.graphics.rectangle('fill', self.x, self.y, self.width, self.height, 3) - love.graphics.setColor(rgb(56, 56, 56), 255) + love.graphics.setColor(rgba(56, 56, 56, 255)) love.graphics.rectangle('fill', self.x + 2, self.y + 2, self.width - 4, self.height - 4, 3) - love.graphics.setColor(rgb(255, 255, 255), 255) + love.graphics.setColor(rgba(255, 255, 255, 255)) end end diff --git a/src/gui/ProgressBar.lua b/src/gui/ProgressBar.lua index 03980d6..df10b7d 100644 --- a/src/gui/ProgressBar.lua +++ b/src/gui/ProgressBar.lua @@ -38,14 +38,14 @@ function ProgressBar:render() local renderWidth = (self.value / self.max) * self.width -- draw main bar, with calculated width based on value / max - love.graphics.setColor(rgb(self.color.r, self.color.g, self.color.b), 255) + love.graphics.setColor(rgba(self.color.r, self.color.g, self.color.b, 255)) if self.value > 0 then love.graphics.rectangle('fill', self.x, self.y, renderWidth, self.height, 3) end -- draw outline around actual bar - love.graphics.setColor(rgb(0, 0, 0), 255) + love.graphics.setColor(rgba(0, 0, 0, 255)) love.graphics.rectangle('line', self.x, self.y, self.width, self.height, 3) - love.graphics.setColor(rgb(255, 255, 255), 255) + love.graphics.setColor(rgba(255, 255, 255, 255)) end diff --git a/src/states/game/BattleState.lua b/src/states/game/BattleState.lua index 09f513c..b7fd4c1 100644 --- a/src/states/game/BattleState.lua +++ b/src/states/game/BattleState.lua @@ -91,11 +91,11 @@ end function BattleState:render() love.graphics.clear(214, 214, 214, 255) - love.graphics.setColor(rgb(45, 184, 45), 124) + love.graphics.setColor(rgba(45, 184, 45, 124)) love.graphics.ellipse('fill', self.opponentCircleX, 60, 72, 24) love.graphics.ellipse('fill', self.playerCircleX, VIRTUAL_HEIGHT - 64, 72, 24) - love.graphics.setColor(rgb(255, 255, 255), 255) + love.graphics.setColor(rgba(255, 255, 255, 255)) self.opponentSprite:render() self.playerSprite:render() @@ -105,14 +105,14 @@ function BattleState:render() self.playerExpBar:render() -- render level text - love.graphics.setColor(rgb(0, 0, 0), 255) + love.graphics.setColor(rgba(0, 0, 0, 255)) love.graphics.setFont(gFonts['small']) love.graphics.print('LV ' .. tostring(self.playerPokemon.level), self.playerHealthBar.x, self.playerHealthBar.y - 10) love.graphics.print('LV ' .. tostring(self.opponentPokemon.level), self.opponentHealthBar.x, self.opponentHealthBar.y + 8) love.graphics.setFont(gFonts['medium']) - love.graphics.setColor(rgb(255, 255, 255), 255) + love.graphics.setColor(rgba(255, 255, 255, 255)) end self.bottomPanel:render() diff --git a/src/states/game/FadeInState.lua b/src/states/game/FadeInState.lua index 7e8806d..6ecc49a 100644 --- a/src/states/game/FadeInState.lua +++ b/src/states/game/FadeInState.lua @@ -25,8 +25,8 @@ function FadeInState:init(color, time, onFadeComplete) end function FadeInState:render() - love.graphics.setColor(rgb(self.r, self.g, self.b), self.opacity) + love.graphics.setColor(rgba(self.r, self.g, self.b, self.opacity)) love.graphics.rectangle('fill', 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) - love.graphics.setColor(rgb(255, 255, 255), 255) + love.graphics.setColor(rgba(255, 255, 255, 255)) end diff --git a/src/states/game/FadeOutState.lua b/src/states/game/FadeOutState.lua index f57a051..3b4aa03 100644 --- a/src/states/game/FadeOutState.lua +++ b/src/states/game/FadeOutState.lua @@ -29,8 +29,8 @@ function FadeOutState:update(dt) end function FadeOutState:render() - love.graphics.setColor(rgb(self.r, self.g, self.b), self.opacity) + love.graphics.setColor(rgba(self.r, self.g, self.b, self.opacity)) love.graphics.rectangle('fill', 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) - love.graphics.setColor(rgb(255, 255, 255), 255) + love.graphics.setColor(rgba(255, 255, 255, 255)) end diff --git a/src/states/game/StartState.lua b/src/states/game/StartState.lua index 9b95bac..59f12f8 100644 --- a/src/states/game/StartState.lua +++ b/src/states/game/StartState.lua @@ -57,18 +57,18 @@ function StartState:update(dt) end function StartState:render() - love.graphics.clear(rgb(188, 188, 188), 255) + love.graphics.clear(rgba(188, 188, 188, 255)) - love.graphics.setColor(rgb(24, 24, 24), 255) + love.graphics.setColor(rgba(24, 24, 24, 255)) love.graphics.setFont(gFonts['large']) love.graphics.printf('50-Mon!', 0, VIRTUAL_HEIGHT / 2 - 72, VIRTUAL_WIDTH, 'center') love.graphics.setFont(gFonts['medium']) love.graphics.printf('Press Enter', 0, VIRTUAL_HEIGHT / 2 + 68, VIRTUAL_WIDTH, 'center') love.graphics.setFont(gFonts['small']) - love.graphics.setColor(rgb(45, 184, 45), 124) + love.graphics.setColor(rgba(45, 184, 45, 124)) love.graphics.ellipse('fill', VIRTUAL_WIDTH / 2, VIRTUAL_HEIGHT / 2 + 32, 72, 24) - love.graphics.setColor(rgb(255, 255, 255), 255) + love.graphics.setColor(rgba(255, 255, 255, 255)) love.graphics.draw(gTextures[self.sprite], self.spriteX, self.spriteY) end