diff --git a/README.md b/README.md index cdd5e0d..95540d6 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ GitHub all releases - - Love2d version + + Love2d version

@@ -21,24 +21,12 @@ Download the latest version of the game via the [releases][]. ### Windows and MacOS For Windows (win32, win64) and MacOS users, please download the corresponding `.zip` file. -If you have installed LÖVE or want to install it - for this, install the corresponding [release 0.10.2 from GitHub](https://github.com/love2d/love/releases/tag/0.10.2) - you can simply download the `.love` file from the [releases][] and double-click the file to start the game. +If you have installed LÖVE or want to install it (see the [official website](https://love2d.org/) for installing it) you can simply download the `.love` file from the [releases][] and double-click the file to start the game. ### Linux -To run the game on Linux you have to install LÖVE 0.10.2. You can do this manually using the link above or run the following commands in a terminal. - -```bash -LOVE_URL='https://github.com/love2d/love/releases/download/0.10.2' -TEMP_DEB1="$(mktemp)" -TEMP_DEB2="$(mktemp)" -wget -O "$TEMP_DEB1" "$LOVE_URL/liblove0_0.10.2ppa1_amd64.deb" -wget -O "$TEMP_DEB2" "$LOVE_URL/love_0.10.2ppa1_amd64.deb" -sudo dpkg -i "$TEMP_DEB1" "$TEMP_DEB2" -rm -f "$TEMP_DEB1" "$TEMP_DEB2" -``` - +To run the game on Linux you have to install LÖVE 11.3 from the [official website](https://love2d.org/). Then download the `.love` file from the [releases][] and simply double-click it. - ## Instructions #### Menu Use the arrow keys to navigate within menus and press enter to select. @@ -52,7 +40,7 @@ Press esc to quit. ## Used Libraries, Art Packs, Sounds ### Art Pack -The sprites (plus backgrounds, fonts and some sound effects) used in this game are from the art pack [Space Shooter Redux](https://opengameart.org/content/space-shooter-redux) by [Kenny](www.kenney.nl). +The sprites (plus backgrounds, fonts and some sound effects) used in this game are from the art pack [Space Shooter Redux](https://opengameart.org/content/space-shooter-redux) by [Kenny](https://www.kenney.nl). Some UI elements are from the [UI Pack: RPG Expansion](https://www.kenney.nl/assets/ui-pack-rpg-expansion) by Kenny. @@ -62,7 +50,6 @@ The soundtracks are from Juhani Junkala and can be found [here](https://opengame Other sound effects: - Various sounds from [512 Sound Effects](https://opengameart.org/content/512-sound-effects-8-bit-style) -- [Explosion](https://opengameart.org/content/explosion-0) ### Libraries * [Class](https://github.com/vrld/hump) diff --git a/conf.lua b/conf.lua index 137334b..9a6d034 100644 --- a/conf.lua +++ b/conf.lua @@ -1,10 +1,14 @@ function love.conf(t) t.identity = "space-love" -- The name of the save directory (string) - t.version = "0.10.2" -- The LÖVE version this game was made for (string) + t.appendidentity = false -- Search files in source directory before save directory (boolean) + t.version = "11.3" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only) t.accelerometerjoystick = false -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean) t.externalstorage = false -- True to save files (and read from the save directory) in external storage on Android (boolean) - t.gammacorrect = true -- Enable gamma-correct rendering, when supported by the system (boolean) + t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean) + + t.audio.mic = false -- Request and use microphone capabilities in Android (boolean) + t.audio.mixwithsystem = true -- Keep background music playing when opening LOVE (boolean, iOS and Android only) t.window.title = "Space Love" -- The window title (string) t.window.icon = nil -- Filepath to an image to use as the window's icon (string) @@ -16,15 +20,20 @@ function love.conf(t) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.fullscreen = false -- Enable fullscreen (boolean) t.window.fullscreentype = "desktop" -- Choose between "desktop" fullscreen or "exclusive" fullscreen mode (string) - t.window.vsync = true -- Enable vertical sync (boolean) + t.window.vsync = 1 -- Vertical sync mode (number) t.window.msaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) + t.window.depth = nil -- The number of bits per sample in the depth buffer + t.window.stencil = nil -- The number of bits per sample in the stencil buffer t.window.display = 1 -- Index of the monitor to show the window in (number) t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) + t.window.usedpiscale = true -- Enable automatic DPI scaling when highdpi is set to true as well (boolean) t.window.x = nil -- The x-coordinate of the window's position in the specified display (number) t.window.y = nil -- The y-coordinate of the window's position in the specified display (number) t.modules.audio = true -- Enable the audio module (boolean) + t.modules.data = true -- Enable the data module (boolean) t.modules.event = true -- Enable the event module (boolean) + t.modules.font = true -- Enable the font module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.joystick = false -- Enable the joystick module (boolean) @@ -34,9 +43,9 @@ function love.conf(t) t.modules.physics = false -- Enable the physics module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.system = true -- Enable the system module (boolean) + t.modules.thread = true -- Enable the thread module (boolean) t.modules.timer = true -- Enable the timer module (boolean), Disabling it will result 0 delta time in love.update t.modules.touch = false -- Enable the touch module (boolean) t.modules.video = false -- Enable the video module (boolean) t.modules.window = true -- Enable the window module (boolean) - t.modules.thread = true -- Enable the thread module (boolean) end \ No newline at end of file diff --git a/lib/push.lua b/lib/push.lua index 0e0709a..01f8984 100644 --- a/lib/push.lua +++ b/lib/push.lua @@ -1,232 +1,308 @@ --- push.lua v0.2 +-- push.lua v0.4 --- Copyright (c) 2017 Ulysse Ramage +-- Copyright (c) 2020 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 windowUpdateMode = love11 and love.window.updateMode or function(width, height, settings) + local _, _, flags = love.window.getMode() + for k, v in pairs(settings) do + flags[k] = v + end + love.window.setMode(width, height, flags) + end + local push = { - - defaults = { - fullscreen = false, - resizable = false, - pixelperfect = false, - highdpi = true, - canvas = true - } - + defaults = { + fullscreen = false, + resizable = false, + pixelperfect = false, + highdpi = true, + canvas = true, + stencil = 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 - end + for k, v in pairs(settings) do + self["_" .. k] = v + end end -function push:resetSettings() return self:applySettings(self.defaults) end +function push:resetSettings() + return self:applySettings(self.defaults) +end function push:setupScreen(WWIDTH, WHEIGHT, RWIDTH, RHEIGHT, settings) + settings = settings or {} - settings = settings or {} + self._WWIDTH, self._WHEIGHT = WWIDTH, WHEIGHT + self._RWIDTH, self._RHEIGHT = RWIDTH, RHEIGHT - self._WWIDTH, self._WHEIGHT = WWIDTH, WHEIGHT - self._RWIDTH, self._RHEIGHT = RWIDTH, RHEIGHT + self:applySettings(self.defaults) --set defaults first + self:applySettings(settings) --then fill with custom settings - self:applySettings(self.defaults) --set defaults first - self:applySettings(settings) --then fill with custom settings - - love.window.setMode( self._RWIDTH, self._RHEIGHT, { - fullscreen = self._fullscreen, - resizable = self._resizable, - highdpi = self._highdpi - } ) + windowUpdateMode( + self._RWIDTH, + self._RHEIGHT, + { + fullscreen = self._fullscreen, + resizable = self._resizable, + highdpi = self._highdpi + } + ) - self:initValues() + self:initValues() - if self._canvas then - self:setupCanvas({ "default" }) --setup canvas - end + if self._canvas then + self:setupCanvas({"default"}) --setup canvas + end - self._borderColor = {0, 0, 0} + self._borderColor = {0, 0, 0} - self._drawFunctions = { - ["start"] = self.start, - ["end"] = self.finish - } + self._drawFunctions = { + ["start"] = self.start, + ["end"] = self.finish + } - return self + return self 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 = {} + 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) - } - end + for i = 1, #canvases do + push:addCanvas(canvases[i]) + end - return self + 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), + stencil = params.stencil or self._stencil + } + ) end function push:setCanvas(name) - if not self._canvas then return true end - return love.graphics.setCanvas( self:getCanvasTable(name).canvas ) + if not self._canvas then + return true + end + local canvasTable = self:getCanvasTable(name) + return love.graphics.setCanvas({canvasTable.canvas, stencil = canvasTable.stencil}) end function push:getCanvasTable(name) - for i = 1, #self.canvases do - if self.canvases[i].name == name then - return self.canvases[i] + for i = 1, #self.canvases do + if self.canvases[i].name == name then + return self.canvases[i] + end end - end end function push:setShader(name, shader) - if not shader then - self:getCanvasTable("_render").shader = name - else - self:getCanvasTable(name).shader = shader - end + if not shader then + self:getCanvasTable("_render").shader = name + else + self:getCanvasTable(name).shader = shader + end end function push:initValues() - self._PSCALE = self._highdpi and love.window.getPixelScale() 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 -end + self._PSCALE = (not love11 and self._highdpi) and getDPI() or 1 -function push:start() - if self._canvas then - love.graphics.push() - love.graphics.setCanvas(self.canvases[1].canvas) - else - love.graphics.translate(self._OFFSET.x, self._OFFSET.y) - love.graphics.setScissor(self._OFFSET.x, self._OFFSET.y, self._WWIDTH*self._SCALE.x, self._WHEIGHT*self._SCALE.y) - love.graphics.push() - love.graphics.scale(self._SCALE.x, self._SCALE.y) - end -end + self._SCALE = { + x = self._RWIDTH / self._WWIDTH * self._PSCALE, + y = self._RHEIGHT / self._WHEIGHT * self._PSCALE + } -function push:finish(shader) - love.graphics.setBackgroundColor(unpack(self._borderColor)) - if self._canvas then - local _render = self:getCanvasTable("_render") + 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 - love.graphics.pop() + self._GWIDTH = self._RWIDTH * self._PSCALE - self._OFFSET.x * 2 + self._GHEIGHT = self._RHEIGHT * self._PSCALE - self._OFFSET.y * 2 +end - love.graphics.setColor(255, 255, 255) +function push:apply(operation, shader) + self._drawFunctions[operation](self, shader) +end - --draw canvas - love.graphics.setCanvas(_render.canvas) - for i = 1, #self.canvases - 1 do --do not draw _render yet - local _table = self.canvases[i] - love.graphics.setShader(_table.shader) - love.graphics.draw(_table.canvas) +function push:start() + if self._canvas then + love.graphics.push() + love.graphics.setCanvas({self.canvases[1].canvas, stencil = self.canvases[1].stencil}) + else + love.graphics.translate(self._OFFSET.x, self._OFFSET.y) + love.graphics.setScissor( + self._OFFSET.x, + self._OFFSET.y, + self._WWIDTH * self._SCALE.x, + self._WHEIGHT * self._SCALE.y + ) + love.graphics.push() + love.graphics.scale(self._SCALE.x, self._SCALE.y) 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) +end - --clear canvas - for i = 1, #self.canvases do - love.graphics.setCanvas( self.canvases[i].canvas ) - love.graphics.clear() +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 - love.graphics.setCanvas() - love.graphics.setShader() - else - love.graphics.pop() - love.graphics.setScissor() - end +function push:finish(shader) + love.graphics.setBackgroundColor(unpack(self._borderColor)) + if self._canvas then + local _render = self:getCanvasTable("_render") + + love.graphics.pop() + + 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 do --do not draw _render yet + local _table = self.canvases[i] + 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) + 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.clear() + end + + love.graphics.setCanvas() + love.graphics.setShader() + else + love.graphics.pop() + love.graphics.setScissor() + end end function push:setBorderColor(color, g, b) - self._borderColor = g and {color, g, b} or color + self._borderColor = g and {color, g, b} or color 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 + 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 + local realX = self._OFFSET.x + (self._GWIDTH * x) / self._WWIDTH + local realY = self._OFFSET.y + (self._GHEIGHT * y) / self._WHEIGHT + return realX, realY 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 - end + 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 + windowUpdateMode(self._RWIDTH, self._RHEIGHT) --set window dimensions + end end function push:resize(w, h) - local pixelScale = love.window.getPixelScale() - if self._highdpi then w, h = w / pixelScale, h / pixelScale end - self._RWIDTH = w - self._RHEIGHT = h - self:initValues() + if self._highdpi then + w, h = w / self._PSCALE, h / self._PSCALE + end + self._RWIDTH = w + self._RHEIGHT = h + self:initValues() end -function push:getWidth() return self._WWIDTH end -function push:getHeight() return self._WHEIGHT end -function push:getDimensions() return self._WWIDTH, self._WHEIGHT end +function push:getWidth() + return self._WWIDTH +end +function push:getHeight() + return self._WHEIGHT +end +function push:getDimensions() + return self._WWIDTH, self._WHEIGHT +end return push diff --git a/main.lua b/main.lua index 765320a..8f847d0 100644 --- a/main.lua +++ b/main.lua @@ -44,10 +44,10 @@ function love.load() local menuBlinkInterval = 0.6 Timer.every(menuBlinkInterval, function() Timer.tween(menuBlinkInterval / 2, { - [MENU_SELECTED_COLOR] = { r = 100, g = 100, b = 100} + [MENU_SELECTED_COLOR] = { r = 100/255, g = 100/255, b = 100/255} }):finish(function () Timer.tween(menuBlinkInterval / 2, { - [MENU_SELECTED_COLOR] = {r = 150, g = 100, b = 255} + [MENU_SELECTED_COLOR] = {r = 150/255, g = 100/255, b = 255/255} }) end) end) @@ -89,7 +89,7 @@ function love.draw() push:start() gStateStack:render() - love.graphics.setColor(150, 150, 150, 255) + love.graphics.setColor(150/255, 150/255, 150/255, 255/255) love.graphics.setFont(gFonts['default-small']) love.graphics.printf(VERSION, 10, VIRTUAL_HEIGHT-25, VIRTUAL_WIDTH, 'left') diff --git a/sounds/explosion.wav b/sounds/explosion.wav deleted file mode 100644 index c789505..0000000 Binary files a/sounds/explosion.wav and /dev/null differ diff --git a/src/Dependencies.lua b/src/Dependencies.lua index dfb8935..c3b7eb6 100644 --- a/src/Dependencies.lua +++ b/src/Dependencies.lua @@ -66,38 +66,36 @@ gFonts = { } gSounds = { - ['laser-1'] = love.audio.newSource('sounds/sfx_laser1.ogg'), - ['laser-2'] = love.audio.newSource('sounds/sfx_laser2.ogg'), - ['lose'] = love.audio.newSource('sounds/sfx_lose.ogg'), - ['shield-down'] = love.audio.newSource('sounds/sfx_shieldDown.ogg'), - ['shield-up'] = love.audio.newSource('sounds/sfx_shieldUp.ogg'), - ['two-tone'] = love.audio.newSource('sounds/sfx_twoTone.ogg'), - ['zap'] = love.audio.newSource('sounds/sfx_zap.ogg'), - ['powerup-health'] = love.audio.newSource('sounds/sfx_sounds_powerup12.wav'), - ['health-alarm'] = love.audio.newSource('sounds/sfx_alarm_loop6.wav'), - ['impact'] = love.audio.newSource('sounds/sfx_sounds_impact8.wav'), - ['collision'] = love.audio.newSource('sounds/sfx_sounds_impact11.wav'), - - ['music-title-screen'] = love.audio.newSource('sounds/music/music-title-screen.wav'), - ['music-lvl1'] = love.audio.newSource('sounds/music/music-lvl1.wav'), - ['music-lvl2'] = love.audio.newSource('sounds/music/music-lvl2.wav'), - ['music-lvl3'] = love.audio.newSource('sounds/music/music-lvl3.wav'), - ['music-ending'] = love.audio.newSource('sounds/music/music-ending.wav'), - - ['menu-move'] = love.audio.newSource('sounds/menu/sfx_menu_move1.wav'), - ['menu-select'] = love.audio.newSource('sounds/menu/sfx_menu_select2.wav'), - ['pause-start'] = love.audio.newSource('sounds/menu/sfx_sounds_pause6_in.wav'), - ['pause-end'] = love.audio.newSource('sounds/menu/sfx_sounds_pause6_out.wav'), - - ['explosion'] = love.audio.newSource('sounds/explosion.wav') + ['laser-1'] = love.audio.newSource('sounds/sfx_laser1.ogg', 'static'), + ['laser-2'] = love.audio.newSource('sounds/sfx_laser2.ogg', 'static'), + ['lose'] = love.audio.newSource('sounds/sfx_lose.ogg', 'static'), + ['shield-down'] = love.audio.newSource('sounds/sfx_shieldDown.ogg', 'static'), + ['shield-up'] = love.audio.newSource('sounds/sfx_shieldUp.ogg', 'static'), + ['two-tone'] = love.audio.newSource('sounds/sfx_twoTone.ogg', 'static'), + ['zap'] = love.audio.newSource('sounds/sfx_zap.ogg', 'static'), + ['powerup-health'] = love.audio.newSource('sounds/sfx_sounds_powerup12.wav', 'static'), + ['health-alarm'] = love.audio.newSource('sounds/sfx_alarm_loop6.wav', 'static'), + ['impact'] = love.audio.newSource('sounds/sfx_sounds_impact8.wav', 'static'), + ['collision'] = love.audio.newSource('sounds/sfx_sounds_impact11.wav', 'static'), + + ['music-title-screen'] = love.audio.newSource('sounds/music/music-title-screen.wav', 'stream'), + ['music-lvl1'] = love.audio.newSource('sounds/music/music-lvl1.wav', 'stream'), + ['music-lvl2'] = love.audio.newSource('sounds/music/music-lvl2.wav', 'stream'), + ['music-lvl3'] = love.audio.newSource('sounds/music/music-lvl3.wav', 'stream'), + ['music-ending'] = love.audio.newSource('sounds/music/music-ending.wav', 'stream'), + + ['menu-move'] = love.audio.newSource('sounds/menu/sfx_menu_move1.wav', 'static'), + ['menu-select'] = love.audio.newSource('sounds/menu/sfx_menu_select2.wav', 'static'), + ['pause-start'] = love.audio.newSource('sounds/menu/sfx_sounds_pause6_in.wav', 'static'), + ['pause-end'] = love.audio.newSource('sounds/menu/sfx_sounds_pause6_out.wav', 'static'), } for i = 1, EXPLOSION_SHORT_COUNT, 1 do - gSounds['explosion-short-' .. i] = love.audio.newSource('sounds/explosion_short/sfx_exp_short_hard' .. i ..'.wav') + gSounds['explosion-short-' .. i] = love.audio.newSource('sounds/explosion_short/sfx_exp_short_hard' .. i ..'.wav', 'static') end for i = 1, EXPLOSION_MEDIUM_COUNT, 1 do - gSounds['explosion-medium-' .. i] = love.audio.newSource('sounds/explosion_medium/sfx_exp_medium' .. i ..'.wav') + gSounds['explosion-medium-' .. i] = love.audio.newSource('sounds/explosion_medium/sfx_exp_medium' .. i ..'.wav', 'static') end for k, sound in pairs(gSounds) do @@ -106,7 +104,7 @@ for k, sound in pairs(gSounds) do sound:setLooping(true) end end -gSounds['explosion']:setVolume(0.7) + gSounds['health-alarm']:setLooping(true) diff --git a/src/Utils.lua b/src/Utils.lua index 564a870..f7f101a 100644 --- a/src/Utils.lua +++ b/src/Utils.lua @@ -118,7 +118,7 @@ end function getBlast(size) local blast = love.graphics.newCanvas(size, size) love.graphics.setCanvas(blast) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) love.graphics.circle("fill", size/2, size/2, size/2) love.graphics.setCanvas() return blast @@ -131,7 +131,7 @@ function getExplosion(image) pSystem = love.graphics.newParticleSystem(image, 50) pSystem:setParticleLifetime(0.8, 0.8) pSystem:setLinearAcceleration(-100, -100, 100, 100) - pSystem:setColors(255, 255, 0, 255, 255, 153, 51, 255, 64, 64, 64, 0) + pSystem:setColors(255/255, 255/255, 0, 255/255, 255/255, 153/255, 51/255, 255/255, 64/255, 64/255, 64/255, 0) pSystem:setSizes(0.5, 0.7) return pSystem end @@ -171,7 +171,7 @@ end function writeSaveFile(file, data, mode) - if mode == "append" and love.filesystem.exists(FILE_HIGHSCORES) then + if mode == "append" and love.filesystem.getInfo(FILE_HIGHSCORES) then success, message = love.filesystem.append(FILE_HIGHSCORES, data) fsType = "fs-append" else @@ -190,17 +190,17 @@ end function color2rgb(color) color = color:lower() if color == "red" then - return {r = 255, g = 0, b = 0} + return {r = 1, g = 0, b = 0} elseif color == "green" then - return {r = 0, g = 255, b = 0} + return {r = 0, g = 1, b = 0} elseif color == "blue" then - return {r = 0, g = 0, b = 255} + return {r = 0, g = 0, b = 1} elseif color == "white" then - return {r = 255, g = 255, b = 255} + return {r = 1, g = 1, b = 1} elseif color == "black" then return {r = 0, g = 0, b = 0} elseif color == "orange" then - return {r = 255, g = 140, b = 0} + return {r = 1, g = 140/255, b = 0} end end @@ -224,7 +224,7 @@ function gradient(colors) else x, y = i - 1, 0 end - result:setPixel(x, y, color[1], color[2], color[3], color[4] or 255) + result:setPixel(x, y, color[1], color[2], color[3], color[4] or 1) end result = love.graphics.newImage(result) result:setFilter('linear', 'linear') diff --git a/src/constants.lua b/src/constants.lua index 8779ce1..1dffacc 100644 --- a/src/constants.lua +++ b/src/constants.lua @@ -16,7 +16,7 @@ BACKGROUND_SPEED = 50 BACKGROUNDS = {'bg_black', 'bg_blue', 'bg_dark-purple'} MENU_BACKGROUND = 'bg_black' -MENU_SELECTED_COLOR = {r = 150, g = 100, b = 255} +MENU_SELECTED_COLOR = {r = 150/255, g = 100/255, b = 255/255} PLAYER_LASER_SPEED = 600 * GAME_SPEED_MULTIPLIER diff --git a/src/entity/Entity.lua b/src/entity/Entity.lua index 1b54ce9..d8c28c3 100644 --- a/src/entity/Entity.lua +++ b/src/entity/Entity.lua @@ -98,7 +98,6 @@ function Entity:createHealthbar() parentOffset = offset, width = barWidth, height = 5, - color = {r = 255, g = 255, b = 255}, max = self.health, value = self.health, separators = true diff --git a/src/entity/Player.lua b/src/entity/Player.lua index 1c66021..cd31a4d 100644 --- a/src/entity/Player.lua +++ b/src/entity/Player.lua @@ -177,7 +177,6 @@ function Player:shieldUp(time) y = HUD_PADDING + HUD_ITEM_MARGIN, width = 150, height = 10, - color = {r = 255, g = 255, b = 255}, max = time, value = time, text = "shield" diff --git a/src/entity/Ufo.lua b/src/entity/Ufo.lua index 98f5f8b..6b0d8cf 100644 --- a/src/entity/Ufo.lua +++ b/src/entity/Ufo.lua @@ -28,7 +28,6 @@ function Ufo:createHealthbar() parentOffset = offset, width = barWidth, height = 5, - color = {r = 255, g = 255, b = 255}, max = self.health, value = self.health, separators = true, diff --git a/src/gui/LowHealthOverlay.lua b/src/gui/LowHealthOverlay.lua index 9a669b8..d9fefb8 100644 --- a/src/gui/LowHealthOverlay.lua +++ b/src/gui/LowHealthOverlay.lua @@ -45,7 +45,7 @@ function LowHealthOverlay:render() if self.mode == "full" then love.graphics.setColor(self.color.r, self.color.g, self.color.b, self.alpha) love.graphics.rectangle('fill', 0, 0 , VIRTUAL_WIDTH, VIRTUAL_HEIGHT) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) elseif self.mode == "edge" then loc = { {x = 0, y = 0, w = self.width, h = VIRTUAL_HEIGHT}, diff --git a/src/gui/Menu.lua b/src/gui/Menu.lua index 92242a8..9a9121c 100644 --- a/src/gui/Menu.lua +++ b/src/gui/Menu.lua @@ -79,7 +79,7 @@ function Menu:render() if k == self.selected then love.graphics.setColor(MENU_SELECTED_COLOR.r, MENU_SELECTED_COLOR.g, MENU_SELECTED_COLOR.b, 255) else - love.graphics.setColor(100, 100, 100, 255) + love.graphics.setColor(100/255, 100/255, 100/255, 255/255) end love.graphics.printf(text, self.x, self.y + offsetY, VIRTUAL_WIDTH, 'center') @@ -92,14 +92,14 @@ function Menu:render() -- Then print the option text if k == self.selected then - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) else - love.graphics.setColor(100, 100, 100, 255) + love.graphics.setColor(100/255, 100/255, 100/255, 255/255) end love.graphics.printf(self:getSelectedSideText(k), self.x, self.y + offsetY, VIRTUAL_WIDTH, 'center') end offsetY = offsetY + self.rowOffset end - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) end \ No newline at end of file diff --git a/src/gui/PlayerHealthBar.lua b/src/gui/PlayerHealthBar.lua index d1abe27..d8955d4 100644 --- a/src/gui/PlayerHealthBar.lua +++ b/src/gui/PlayerHealthBar.lua @@ -2,7 +2,7 @@ PlayerHealthBar = Class{__includes = ProgressBar} function PlayerHealthBar:init(def) ProgressBar.init(self, def) - self.color = {r = 0, g = 255, b = 0} + self.color = {r = 0, g = 1, b = 0} self.text = "health" self.separators = true end @@ -13,10 +13,10 @@ function PlayerHealthBar:update(dt) local frac = self.value / self.max if frac > 0.5 then - self.color = {r = 0, g = 255, b = 0} + self.color = {r = 0, g = 1, b = 0} elseif self.value > 1 then - self.color = {r = 255, g = 255, b = 0} + self.color = {r = 1, g = 1, b = 0} else - self.color = {r = 255, g = 0, b = 0} + self.color = {r = 1, g = 0, b = 0} end end \ No newline at end of file diff --git a/src/gui/ProgressBar.lua b/src/gui/ProgressBar.lua index 1d1a709..b43c075 100644 --- a/src/gui/ProgressBar.lua +++ b/src/gui/ProgressBar.lua @@ -18,9 +18,9 @@ function ProgressBar:init(def) self.width = def.width self.height = def.height - self.color = def.color or {r = 255, g = 255, b = 255} -- defaults to white + self.color = def.color or {r = 1, g = 1, b = 1} -- defaults to white self.outlineColor = def.outlineColor or {r = 0, g = 0, b = 0} -- defaults to black - self.textColor = def.textColor or {r = 255, g = 255, b = 255} -- defaults to white + self.textColor = def.textColor or {r = 1, g = 1, b = 1} -- defaults to white self.value = def.value or 0 self.min = def.min or 0 @@ -49,7 +49,7 @@ function ProgressBar:render() -- print text above bar (if set) local yOffset = self.text and HEALTH_BAR_TEXT_OFFSET or 0 if self.text then - love.graphics.setColor(self.textColor.r, self.textColor.g, self.textColor.b, 255) + love.graphics.setColor(self.textColor.r, self.textColor.g, self.textColor.b, 1) love.graphics.setFont(self.font) love.graphics.print(self.text, self.x, self.y) end @@ -61,12 +61,12 @@ function ProgressBar:render() if value > 0 then -- 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(self.color.r, self.color.g, self.color.b, 1) love.graphics.rectangle('fill', self.x, self.y + yOffset, renderWidth, self.height, 2) end -- draw outline around actual bar - love.graphics.setColor(self.outlineColor.r, self.outlineColor.g, self.outlineColor.b, 255) + love.graphics.setColor(self.outlineColor.r, self.outlineColor.g, self.outlineColor.b, 1) love.graphics.rectangle('line', self.x, self.y + yOffset, self.width, self.height, 2) if self.separators then @@ -76,5 +76,5 @@ function ProgressBar:render() end end - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) end \ No newline at end of file diff --git a/src/object/GameObject.lua b/src/object/GameObject.lua index 71e92c6..eb88437 100644 --- a/src/object/GameObject.lua +++ b/src/object/GameObject.lua @@ -158,13 +158,13 @@ end function GameObject:render() if self.blinking then if self.blinkTimer > self.blinkInterval / 2 then - love.graphics.setColor(255, 255, 255, 16) + love.graphics.setColor(1, 1, 1, 16/255) end if self.blinkTimer > self.blinkInterval then self.blinkTimer = 0 end else - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) end local frame @@ -180,18 +180,18 @@ function GameObject:render() end end - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) if DEBUG then - love.graphics.setColor(100, 100, 100, 255) + love.graphics.setColor(100/255, 100/255, 100/255, 1) love.graphics.rectangle('line', self.x, self.y, self.width, self.height) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) if self.type == "meteor" then local hitbox = self:getHitbox() - love.graphics.setColor(0, 255, 255, 255) + love.graphics.setColor(0, 1, 1, 1) love.graphics.rectangle('line', hitbox.x, hitbox.y, hitbox.width, hitbox.height) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) end end end \ No newline at end of file diff --git a/src/states/entity/EntityBaseState.lua b/src/states/entity/EntityBaseState.lua index 3b46c04..b1ec1a8 100644 --- a/src/states/entity/EntityBaseState.lua +++ b/src/states/entity/EntityBaseState.lua @@ -13,20 +13,20 @@ function EntityBaseState:exit() end function EntityBaseState:processAI(params, dt) end function EntityBaseState:render() - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) love.graphics.draw(gTextures[self.entity.texture], gFrames[self.entity.texture][self.entity:getFrame()], math.floor(self.entity.x), math.floor(self.entity.y)) if DEBUG then - love.graphics.setColor(255, 0, 255, 255) + love.graphics.setColor(1, 0, 1, 1) love.graphics.rectangle('line', self.entity.x, self.entity.y, self.entity.width, self.entity.height) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) local hitboxes = self.entity:getHitboxes() for k, hitbox in pairs(hitboxes) do - love.graphics.setColor(0, 255, 255, 255) + love.graphics.setColor(0, 1, 1, 1) love.graphics.rectangle('line', hitbox.x, hitbox.y, hitbox.width, hitbox.height) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) end end end diff --git a/src/states/game/GameOverState.lua b/src/states/game/GameOverState.lua index 5086859..b282aa9 100644 --- a/src/states/game/GameOverState.lua +++ b/src/states/game/GameOverState.lua @@ -63,7 +63,7 @@ function GameOverState:render() self.background:render() self.menu:render() - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) love.graphics.setFont(gFonts['large']) love.graphics.printf('Game Over', 0, VIRTUAL_HEIGHT / 2 - 200, VIRTUAL_WIDTH, 'center') diff --git a/src/states/game/HighscoreState.lua b/src/states/game/HighscoreState.lua index fd585a3..70c6653 100644 --- a/src/states/game/HighscoreState.lua +++ b/src/states/game/HighscoreState.lua @@ -38,7 +38,7 @@ function HighscoreState:update(dt) end function HighscoreState:render() - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) self.background:render() love.graphics.setFont(gFonts['large']) love.graphics.printf('Highscores', 0, 200, VIRTUAL_WIDTH, 'center') @@ -54,7 +54,7 @@ function HighscoreState:render() end function HighscoreState:readScores(limit) - if love.filesystem.exists(FILE_HIGHSCORES) then + if love.filesystem.getInfo(FILE_HIGHSCORES) then content, size = love.filesystem.read(FILE_HIGHSCORES) limitedContent = "" local rows = {} diff --git a/src/states/game/PauseState.lua b/src/states/game/PauseState.lua index a9e2ae8..67b24c1 100644 --- a/src/states/game/PauseState.lua +++ b/src/states/game/PauseState.lua @@ -21,10 +21,10 @@ end function PauseState:render() -- black rectangle with lower alpha to let the background (level) appear inactive - love.graphics.setColor(0, 0, 0, 180) + love.graphics.setColor(0, 0, 0, 180/255) love.graphics.rectangle('fill', 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) love.graphics.setFont(gFonts['large']) love.graphics.printf("Game paused", 0, VIRTUAL_HEIGHT / 2 - 200, VIRTUAL_WIDTH, 'center') end diff --git a/src/states/game/PlayState.lua b/src/states/game/PlayState.lua index ff0995e..71ed59e 100644 --- a/src/states/game/PlayState.lua +++ b/src/states/game/PlayState.lua @@ -14,7 +14,7 @@ function PlayState:init(params) ]] Event.on('stage-changed', function(stage) self.stageLabelText = stage - self.transitionAlpha = 80 + self.transitionAlpha = 80/255 -- first, over a period of 1 second, transition our alpha to 0 Timer.tween(1, { @@ -64,14 +64,14 @@ function PlayState:render() self.level:render() -- render Stage # label and background rect - love.graphics.setColor(95, 205, 228, 200) + love.graphics.setColor(95/255, 205/255, 228/255, 200/255) love.graphics.rectangle('fill', 0, self.stageLabelY - 2, VIRTUAL_WIDTH, 48) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) love.graphics.setFont(gFonts['large']) love.graphics.printf(self.stageLabelText, 0, self.stageLabelY, VIRTUAL_WIDTH, 'center') -- our transition foreground rectangle - love.graphics.setColor(255, 255, 255, self.transitionAlpha) + love.graphics.setColor(1, 1, 1, self.transitionAlpha) love.graphics.rectangle('fill', 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) end diff --git a/src/states/game/SelectShipState.lua b/src/states/game/SelectShipState.lua index d7bdbc0..136ed87 100644 --- a/src/states/game/SelectShipState.lua +++ b/src/states/game/SelectShipState.lua @@ -32,7 +32,7 @@ function SelectShipState:init(params) x = VIRTUAL_WIDTH / 2 - SHIP_DEFS[self.playerShip.ship].width / 2, y = VIRTUAL_HEIGHT / 2 + 100 }, - [self] = { blackAlpha = 255 } + [self] = { blackAlpha = 1 } }) :finish(function() gSounds['music-title-screen']:stop() @@ -193,8 +193,7 @@ function SelectShipState:render() laser:render() end - love.graphics.setBackgroundColor(0.5, 0, 1) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) love.graphics.setFont(gFonts['large']) love.graphics.printf('Select Your Ship', 0, VIRTUAL_HEIGHT / 2 - 240, VIRTUAL_WIDTH, 'center') @@ -208,7 +207,7 @@ function SelectShipState:render() love.graphics.setColor(0, 0, 0, self.blackAlpha) love.graphics.rectangle('fill', 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) love.graphics.draw(gTextures['sheet'], gFrames['sheet'][Player.getFrame(self.playerShip)], self.playerShip.x, self.playerShip.y) end \ No newline at end of file diff --git a/src/states/game/StartState.lua b/src/states/game/StartState.lua index b72c353..10ddb10 100644 --- a/src/states/game/StartState.lua +++ b/src/states/game/StartState.lua @@ -37,8 +37,7 @@ end function StartState:render() self.background:render() - -- love.graphics.setBackgroundColor(0.5,0,1) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(1, 1, 1, 1) love.graphics.setFont(gFonts['large']) love.graphics.printf('Space Love', 0, VIRTUAL_HEIGHT / 2 - 120, VIRTUAL_WIDTH, 'center') diff --git a/src/world/Level.lua b/src/world/Level.lua index e05a8cf..836864f 100644 --- a/src/world/Level.lua +++ b/src/world/Level.lua @@ -27,9 +27,9 @@ function Level:init(params) self.background = Background() self.lowHealthOverlay = LowHealthOverlay({ - color = {r = 255, g = 0, b = 0}, + color = {r = 1, g = 0, b = 0}, interval = 1, - maxAlpha = 15, + maxAlpha = 15/255, mode = 'full' }) @@ -263,7 +263,7 @@ function Level:render() end -- Draw screen barriers (for enemies and ufo) - love.graphics.setColor(150, 150, 150, 255) + love.graphics.setColor(150/255, 150/255, 150/255, 1) love.graphics.line(0, SCREEN_BARRIER_SIZE, VIRTUAL_WIDTH, SCREEN_BARRIER_SIZE) love.graphics.line(0, VIRTUAL_HEIGHT - SCREEN_BARRIER_SIZE, VIRTUAL_WIDTH, VIRTUAL_HEIGHT - SCREEN_BARRIER_SIZE) end @@ -371,10 +371,14 @@ end function Level:pauseAudio() gSounds['music-lvl' .. self.stage]:pause() - gSounds['health-alarm']:pause() + if self.lowHealthOverlay.enabled then + gSounds['health-alarm']:pause() + end end function Level:resumeAudio() - gSounds['music-lvl' .. self.stage]:resume() - gSounds['health-alarm']:resume() + gSounds['music-lvl' .. self.stage]:play() + if self.lowHealthOverlay.enabled then + gSounds['health-alarm']:play() + end end \ No newline at end of file