diff --git a/entities/camera/button01.mp3.flac b/entities/camera/button01.mp3.flac new file mode 100644 index 0000000..dbe38ce Binary files /dev/null and b/entities/camera/button01.mp3.flac differ diff --git a/entities/camera/button02.mp3.flac b/entities/camera/button02.mp3.flac new file mode 100644 index 0000000..b2b0be8 Binary files /dev/null and b/entities/camera/button02.mp3.flac differ diff --git a/entities/camera/button03.mp3.flac b/entities/camera/button03.mp3.flac new file mode 100644 index 0000000..66515ca Binary files /dev/null and b/entities/camera/button03.mp3.flac differ diff --git a/entities/camera/button04.mp3.flac b/entities/camera/button04.mp3.flac new file mode 100644 index 0000000..cbfa140 Binary files /dev/null and b/entities/camera/button04.mp3.flac differ diff --git a/entities/camera/button05.mp3.flac b/entities/camera/button05.mp3.flac new file mode 100644 index 0000000..a951bde Binary files /dev/null and b/entities/camera/button05.mp3.flac differ diff --git a/entities/music/menu.ogg b/entities/music/menu.ogg new file mode 100644 index 0000000..c292c73 Binary files /dev/null and b/entities/music/menu.ogg differ diff --git a/entities/music/play.wav b/entities/music/play.wav new file mode 100644 index 0000000..58b64df Binary files /dev/null and b/entities/music/play.wav differ diff --git a/entities/planet/asteroid.png b/entities/planet/asteroid.png new file mode 100644 index 0000000..e4d8519 Binary files /dev/null and b/entities/planet/asteroid.png differ diff --git a/entities/planet/boom.wav b/entities/planet/boom.wav new file mode 100644 index 0000000..cb67ee1 Binary files /dev/null and b/entities/planet/boom.wav differ diff --git a/entities/planet/close.wav b/entities/planet/close.wav new file mode 100644 index 0000000..4e34979 Binary files /dev/null and b/entities/planet/close.wav differ diff --git a/entities/planet/planet.lua b/entities/planet/planet.lua index 77408b8..7d254dc 100644 --- a/entities/planet/planet.lua +++ b/entities/planet/planet.lua @@ -2,10 +2,13 @@ planet = Class{} G = 6.67e-1 + function planet:init(x, y, mass, radius, img, arg) self.x = x self.y = y self.mass = mass +self.attractionX = 0 +self.attractionY = 0 self.r = radius self.w = img:getWidth() self.image = img @@ -19,6 +22,7 @@ end end function planet:update(dt) + if not reachedGoal then local distanceToShip = math.sqrt((firstShip.x - self.x)^2 + (firstShip.y - self.y)^2) local gravitationalAttraction = G*self.mass/(distanceToShip^2) @@ -33,9 +37,15 @@ function planet:update(dt) love.window.setTitle(self.attractionX) firstShip.dx = firstShip.dx + self.attractionX firstShip.dy = firstShip.dy + self.attractionY + if distanceToShip < 100 then + sounds["close"]:play() + end if distanceToShip < self.w/4 then shipIsHit = true + sounds["close"]:stop() + sounds["boom"]:play() end +end end function planet:draw() diff --git a/entities/ship/Appear.wav b/entities/ship/Appear.wav new file mode 100644 index 0000000..68c955f Binary files /dev/null and b/entities/ship/Appear.wav differ diff --git a/entities/ship/Finish.wav b/entities/ship/Finish.wav new file mode 100644 index 0000000..c6986d7 Binary files /dev/null and b/entities/ship/Finish.wav differ diff --git a/entities/ship/ship.lua b/entities/ship/ship.lua index ad7cd7f..e4ecbef 100644 --- a/entities/ship/ship.lua +++ b/entities/ship/ship.lua @@ -30,7 +30,7 @@ function ship:update(dt) if not shipIsHit then self.dottimer = self.dottimer - dt if self.dottimer < 0 then - if (love.keyboard.isDown('w') and self.fuel > 0) then + if (love.keyboard.isDown('w') and self.fuel > 0 and gameState == "levelgeneral") then table.insert(self.path, self:newPathDot(self.x, self.y, 1)) else table.insert(self.path, self:newPathDot(self.x, self.y, 2)) @@ -53,7 +53,7 @@ function ship:update(dt) self.dx = math.cos(self.vector) * self.speed self.dy = math.sin(self.vector) * self.speed end ]]-- - if love.keyboard.isDown('w') and self.fuel > 0 then + if love.keyboard.isDown('w') and self.fuel > 0 and gameState == "levelgeneral" then self.fuel = self.fuel - 0.5 self.speed = self.speed + 0.05 diff --git a/levels/level1.lua b/levels/level1.lua index 6eebfde..6783cbc 100644 --- a/levels/level1.lua +++ b/levels/level1.lua @@ -31,7 +31,7 @@ function level1.load() table.insert(guibutts, menu:addButton("To menu", function () level.goBack() end)) - table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete")) + table.insert(planets, planet(700, 200, 50, 0.3, asteroidImage, "nodelete")) end function level1.hint() GUIDraw("left") @@ -49,7 +49,7 @@ function level1.reset() planets[k] = nil end local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") - table.insert(planets, planet(700, 200, 50, 0.3, planetImage)) + table.insert(planets, planet(700, 200, 50, 0.3, asteroidImage)) shipsleft = 1 shipIsHit = false firstShip.fuel = 25 diff --git a/levels/level2.lua b/levels/level2.lua index 7d12399..a888b98 100644 --- a/levels/level2.lua +++ b/levels/level2.lua @@ -31,7 +31,7 @@ function level2.load() table.insert(guibutts, menu:addButton("To menu", function () level2.goBack() end)) - table.insert(planets, planet(700, 500, 50, 0.3, planetImage, "nodelete")) + table.insert(planets, planet(700, 500, 50, 0.3, asteroidImage, "nodelete")) end function level2.reset() firstShip:reset() @@ -40,7 +40,7 @@ function level2.reset() end firstShip.fuel = 50 local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") - table.insert(planets, planet(700, 500, 50, 0.3, planetImage)) + table.insert(planets, planet(700, 500, 50, 0.3, asteroidImage)) shipsleft = 1 shipIsHit = false planetsleft = 3 diff --git a/levels/level3.lua b/levels/level3.lua index 08d4818..f436e37 100644 --- a/levels/level3.lua +++ b/levels/level3.lua @@ -31,9 +31,9 @@ function level3.load() table.insert(guibutts, menu:addButton("To menu", function () levelgeneral.goBack() end)) - table.insert(planets, planet(900, 400, 50, 0.3, planetImage, "nodelete")) - table.insert(planets, planet(700, 300, 50, 0.3, planetImage, "nodelete")) - table.insert(planets, planet(900, 200, 50, 0.3, planetImage, "nodelete")) + table.insert(planets, planet(900, 400, 50, 0.3, asteroidImage, "nodelete")) + table.insert(planets, planet(700, 300, 50, 0.3, asteroidImage, "nodelete")) + table.insert(planets, planet(900, 200, 50, 0.3, asteroidImage, "nodelete")) end function level3.hint() GUIDraw("left") @@ -57,6 +57,7 @@ function level3.reset() firstShip.fuel = 75 shipIsHit = false planetsleft = 3 + end function level3.GUIControl() if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then diff --git a/levels/level4.lua b/levels/level4.lua index 3f71e35..777fc74 100644 --- a/levels/level4.lua +++ b/levels/level4.lua @@ -31,8 +31,8 @@ function level4.load() table.insert(guibutts, menu:addButton("To menu", function () levelgeneral.goBack() end)) - table.insert(planets, planet(-200, 400, 50, 0.3, planetImage, "nodelete")) - table.insert(planets, planet(-200, 200, 50, 0.3, planetImage, "nodelete")) + table.insert(planets, planet(-200, 400, 50, 0.3, asteroidImage, "nodelete")) + table.insert(planets, planet(-200, 200, 50, 0.3, asteroidImage, "nodelete")) end function level4.reset() diff --git a/levels/level5.lua b/levels/level5.lua index 49daa62..77ecd97 100644 --- a/levels/level5.lua +++ b/levels/level5.lua @@ -4,7 +4,7 @@ local M = {} function level5.load() shipsleft = 1 local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") - planetsleft = 5 + planetsleft = 10 gameStatus = "setup" playbutts = {} guibutts = {} @@ -31,9 +31,9 @@ function level5.load() table.insert(guibutts, menu:addButton("To menu", function () levelgeneral.goBack() end)) - table.insert(planets, planet(0, 2000, 50, 0.3, planetImage, "nodelete")) - table.insert(planets, planet(100, 2000, 50, 0.3, planetImage, "nodelete")) - table.insert(planets, planet(50, 1700, 50, 0.3, planetImage, "nodelete")) + table.insert(planets, planet(0, 2000, 50, 0.3, asteroidImage, "nodelete")) + table.insert(planets, planet(100, 2000, 50, 0.3, asteroidImage, "nodelete")) + table.insert(planets, planet(50, 1700, 50, 0.3, asteroidImage, "nodelete")) end function level5.reset() @@ -47,7 +47,7 @@ function level5.reset() shipsleft = 1 firstShip.fuel = 100 shipIsHit = false - planetsleft = 5 + planetsleft = 10 end function level5.GUIControl() if (love.keyboard.isDown('w') and VCAM.y > -WINDOW_WIDTH) then diff --git a/levels/levelgeneral.lua b/levels/levelgeneral.lua index 6165ea2..cd9197e 100644 --- a/levels/levelgeneral.lua +++ b/levels/levelgeneral.lua @@ -4,6 +4,7 @@ local M = {} local thrusterMax = 0 local animationComplete = false local frame = 0 +asteroidImage = love.graphics.newImage("entities/planet/asteroid.png") function levelgeneral.update(dt) if not levelLoaded then level = require("levels/level" .. currentLevel) @@ -81,6 +82,7 @@ function levelgeneral.draw() love.graphics.clear(0,0,0,1) love.graphics.setColor(30/255, 30/255, 30/255, 1) if frame < WINDOW_WIDTH then + sounds["finish"]:play() love.graphics.circle("fill", firstShip.x, firstShip.y, WINDOW_WIDTH - frame) end frame = frame + 20 diff --git a/levels/practice.lua b/levels/practice.lua index 255f1ee..3323faa 100644 --- a/levels/practice.lua +++ b/levels/practice.lua @@ -1,6 +1,7 @@ practice = Class{} local levelLoaded = false local M = {} +local currenctScore = 0 function practice.update(dt) if not levelLoaded then shipsleft = 1 @@ -9,7 +10,10 @@ function practice.update(dt) playbutts = {} guibutts = {} XCAM = 0 + currentScore = 0 + thrusterMax = 0 YCAM = 0 + firstShip.fuel = 0 explosions = {} shipIsHit = false guimenu = mainMenu() @@ -31,7 +35,6 @@ function practice.update(dt) levelLoaded = true end camera:update(dt) - --print(camera.x .. " " .. camera.y) for i, explosion in ipairs(explosions) do explosion:update(dt) @@ -54,6 +57,7 @@ function practice.update(dt) for i in ipairs(planets) do planets[i]:update(dt) end + currentScore = currentScore + math.sqrt(firstShip.dx^2 + firstShip.dy^2) else camera:follow(VCAM.x, VCAM.y) end @@ -81,7 +85,10 @@ function practice.draw() if gameStatus == "setup" then GUIDraw("anywhere") + practice.hint() elseif gameStatus == "play" then + local textW = tinyfont:getWidth("Score: " .. math.floor(currentScore/100)) + love.graphics.print("Score: " .. math.floor(currentScore/100), WINDOW_WIDTH/2-textW/2, 10) guimenu:butt(playbutts, WINDOW_WIDTH, WINDOW_HEIGHT, 1100, WINDOW_HEIGHT-50, 40, WINDOW_WIDTH/3) love.keyboard.mouseisReleased = false end @@ -102,8 +109,13 @@ function practice.reset() planets[k] = nil end shipsleft = 1 + if currentScore > saveData.score then + saveData.score = currentScore + end + currentScore = 0 shipIsHit = false planetsleft = 10 + firstShip.fuel = 99999 end function practice.GUIControl() if (love.keyboard.isDown('w')) then @@ -125,6 +137,8 @@ function practice.hint() love.graphics.print("↓[S]",50,100) love.graphics.print("←[A]",10,50) love.graphics.print("→[D]",100,50) + + end return practice \ No newline at end of file diff --git a/main.lua b/main.lua index 162605d..e1919df 100644 --- a/main.lua +++ b/main.lua @@ -15,7 +15,8 @@ OFFSET_Y = 0 currentLevel = 0 saveData = { - levelsBeaten = 0 + levelsBeaten = 0, + score = 0 } planets = {} diff --git a/src/GUI.lua b/src/GUI.lua index 5646169..36c777f 100644 --- a/src/GUI.lua +++ b/src/GUI.lua @@ -45,6 +45,7 @@ function GUIDraw(mode) love.keyboard.mouseisReleased = false firstShip.x = vmx firstShip.y = vmy + sounds["appear"]:play() shipsleft = shipsleft - 1 end if shipsleft == 0 then diff --git a/src/dependencies.lua b/src/dependencies.lua index b72612c..d56e526 100644 --- a/src/dependencies.lua +++ b/src/dependencies.lua @@ -11,6 +11,7 @@ require 'src/GUI' require 'stateMachine' require 'entities/base/base' require 'entities/camera/VCAM' +require 'src/musicController' tick = require 'src/tick' utf8 = require("utf8") serialize = require 'src/ser' diff --git a/src/mainMenu.lua b/src/mainMenu.lua index 1ba996a..ebbd5aa 100644 --- a/src/mainMenu.lua +++ b/src/mainMenu.lua @@ -15,7 +15,7 @@ function mainMenu:butt(buttons, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, locationx, locati local my = my * DIFFERENCE_Y local hot = (mx > ev_bx and mx < ev_bx + ev_button_width and my > ev_by and my < ev_by + ev_BUTTON_HEIGHT) and i if (hot == i) then - color = {10, 10, 0, 255} + color = {10/255, 10/255, 10/255, 255} end button.now = love.keyboard.mouseisReleased if location == "android" then @@ -24,6 +24,7 @@ function mainMenu:butt(buttons, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, locationx, locati if button.now and hot == i then love.keyboard.mouseisReleased = false button.fn() + musicController("click") hot = false break end @@ -36,7 +37,10 @@ function mainMenu:butt(buttons, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, locationx, locati love.graphics.rectangle("fill", ev_bx,ev_by, ev_button_width, ev_BUTTON_HEIGHT) love.graphics.setColor(0, 0, 0, 255) local textW = smallfont:getWidth(button.text) - local textH = smallfont:getHeight(button.text) + local textH = smallfont:getHeight(button.text) + if hot == i then + love.graphics.setColor(1,1,1,255) + end love.graphics.print(button.text, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5) love.graphics.setColor(255, 255, 255, 255) cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin) diff --git a/src/musicController.lua b/src/musicController.lua new file mode 100644 index 0000000..bc202c4 --- /dev/null +++ b/src/musicController.lua @@ -0,0 +1,35 @@ +sounds = { + ["menu"] = love.audio.newSource("entities/music/menu.ogg", "static"), + ["boom"] = love.audio.newSource("entities/planet/boom.wav", "static"), + ["close"] = love.audio.newSource("entities/planet/close.wav", "static"), + ["play"] = love.audio.newSource("entities/music/play.wav", "static"), + ["appear"] = love.audio.newSource("entities/ship/Appear.wav", "static"), + ["finish"] = love.audio.newSource("entities/ship/Finish.wav", "static") +} +mute = false +function musicController(orders, toggling) + if (orders == 'norm' and not mute) then + if (gameState == 'menu' or gameState == "selectlv") then + sounds['menu']:play() + elseif gameStatus == 'play' then + stopSounds() + sounds["play"]:play() + end + elseif orders == "mute" then + if toggling == 1 then + mute = true + else + mute = false + end + elseif orders == "click" then + -- print("entities/camera/button0" .. math.random(1, 5)..".mp3.flac") + local tempClick = love.audio.newSource("entities/camera/button0" .. math.random(1, 5)..".mp3.flac", "static") + tempClick:play() + end +end +function stopSounds() + for i, sound in ipairs(sounds) do + sound[i]:stop() + print("stopping sounds") + end +end \ No newline at end of file diff --git a/stateMachine.lua b/stateMachine.lua index 2db34e7..7e03f7e 100644 --- a/stateMachine.lua +++ b/stateMachine.lua @@ -6,6 +6,7 @@ function stateUpdate(dt) if love.keyboard.isDown('escape') then love.event.quit() end + musicController("norm") end