Browse Source

Sound effects

tags/6
Madiwka3 3 years ago
parent
commit
8fbcd27eb2
27 changed files with 90 additions and 20 deletions
  1. BIN
      entities/camera/button01.mp3.flac
  2. BIN
      entities/camera/button02.mp3.flac
  3. BIN
      entities/camera/button03.mp3.flac
  4. BIN
      entities/camera/button04.mp3.flac
  5. BIN
      entities/camera/button05.mp3.flac
  6. BIN
      entities/music/menu.ogg
  7. BIN
      entities/music/play.wav
  8. BIN
      entities/planet/asteroid.png
  9. BIN
      entities/planet/boom.wav
  10. BIN
      entities/planet/close.wav
  11. +10
    -0
      entities/planet/planet.lua
  12. BIN
      entities/ship/Appear.wav
  13. BIN
      entities/ship/Finish.wav
  14. +2
    -2
      entities/ship/ship.lua
  15. +2
    -2
      levels/level1.lua
  16. +2
    -2
      levels/level2.lua
  17. +4
    -3
      levels/level3.lua
  18. +2
    -2
      levels/level4.lua
  19. +5
    -5
      levels/level5.lua
  20. +2
    -0
      levels/levelgeneral.lua
  21. +15
    -1
      levels/practice.lua
  22. +2
    -1
      main.lua
  23. +1
    -0
      src/GUI.lua
  24. +1
    -0
      src/dependencies.lua
  25. +6
    -2
      src/mainMenu.lua
  26. +35
    -0
      src/musicController.lua
  27. +1
    -0
      stateMachine.lua

BIN
entities/camera/button01.mp3.flac View File


BIN
entities/camera/button02.mp3.flac View File


BIN
entities/camera/button03.mp3.flac View File


BIN
entities/camera/button04.mp3.flac View File


BIN
entities/camera/button05.mp3.flac View File


BIN
entities/music/menu.ogg View File


BIN
entities/music/play.wav View File


BIN
entities/planet/asteroid.png View File

Before After
Width: 300  |  Height: 300  |  Size: 62 KiB

BIN
entities/planet/boom.wav View File


BIN
entities/planet/close.wav View File


+ 10
- 0
entities/planet/planet.lua View File

@@ -2,10 +2,13 @@ planet = Class{}


G = 6.67e-1 G = 6.67e-1



function planet:init(x, y, mass, radius, img, arg) function planet:init(x, y, mass, radius, img, arg)
self.x = x self.x = x
self.y = y self.y = y
self.mass = mass self.mass = mass
self.attractionX = 0
self.attractionY = 0
self.r = radius self.r = radius
self.w = img:getWidth() self.w = img:getWidth()
self.image = img self.image = img
@@ -19,6 +22,7 @@ end
end end


function planet:update(dt) function planet:update(dt)
if not reachedGoal then
local distanceToShip = math.sqrt((firstShip.x - self.x)^2 + (firstShip.y - self.y)^2) local distanceToShip = math.sqrt((firstShip.x - self.x)^2 + (firstShip.y - self.y)^2)
local gravitationalAttraction = G*self.mass/(distanceToShip^2) local gravitationalAttraction = G*self.mass/(distanceToShip^2)
@@ -33,9 +37,15 @@ function planet:update(dt)
love.window.setTitle(self.attractionX) love.window.setTitle(self.attractionX)
firstShip.dx = firstShip.dx + self.attractionX firstShip.dx = firstShip.dx + self.attractionX
firstShip.dy = firstShip.dy + self.attractionY firstShip.dy = firstShip.dy + self.attractionY
if distanceToShip < 100 then
sounds["close"]:play()
end
if distanceToShip < self.w/4 then if distanceToShip < self.w/4 then
shipIsHit = true shipIsHit = true
sounds["close"]:stop()
sounds["boom"]:play()
end end
end
end end


function planet:draw() function planet:draw()


BIN
entities/ship/Appear.wav View File


BIN
entities/ship/Finish.wav View File


+ 2
- 2
entities/ship/ship.lua View File

@@ -30,7 +30,7 @@ function ship:update(dt)
if not shipIsHit then if not shipIsHit then
self.dottimer = self.dottimer - dt self.dottimer = self.dottimer - dt
if self.dottimer < 0 then 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)) table.insert(self.path, self:newPathDot(self.x, self.y, 1))
else else
table.insert(self.path, self:newPathDot(self.x, self.y, 2)) 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.dx = math.cos(self.vector) * self.speed
self.dy = math.sin(self.vector) * self.speed self.dy = math.sin(self.vector) * self.speed
end ]]-- 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.fuel = self.fuel - 0.5
self.speed = self.speed + 0.05 self.speed = self.speed + 0.05




+ 2
- 2
levels/level1.lua View File

@@ -31,7 +31,7 @@ function level1.load()
table.insert(guibutts, menu:addButton("To menu", function () table.insert(guibutts, menu:addButton("To menu", function ()
level.goBack() level.goBack()
end)) end))
table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete"))
table.insert(planets, planet(700, 200, 50, 0.3, asteroidImage, "nodelete"))
end end
function level1.hint() function level1.hint()
GUIDraw("left") GUIDraw("left")
@@ -49,7 +49,7 @@ function level1.reset()
planets[k] = nil planets[k] = nil
end end
local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") 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 shipsleft = 1
shipIsHit = false shipIsHit = false
firstShip.fuel = 25 firstShip.fuel = 25


+ 2
- 2
levels/level2.lua View File

@@ -31,7 +31,7 @@ function level2.load()
table.insert(guibutts, menu:addButton("To menu", function () table.insert(guibutts, menu:addButton("To menu", function ()
level2.goBack() level2.goBack()
end)) end))
table.insert(planets, planet(700, 500, 50, 0.3, planetImage, "nodelete"))
table.insert(planets, planet(700, 500, 50, 0.3, asteroidImage, "nodelete"))
end end
function level2.reset() function level2.reset()
firstShip:reset() firstShip:reset()
@@ -40,7 +40,7 @@ function level2.reset()
end end
firstShip.fuel = 50 firstShip.fuel = 50
local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") 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 shipsleft = 1
shipIsHit = false shipIsHit = false
planetsleft = 3 planetsleft = 3


+ 4
- 3
levels/level3.lua View File

@@ -31,9 +31,9 @@ function level3.load()
table.insert(guibutts, menu:addButton("To menu", function () table.insert(guibutts, menu:addButton("To menu", function ()
levelgeneral.goBack() levelgeneral.goBack()
end)) 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 end
function level3.hint() function level3.hint()
GUIDraw("left") GUIDraw("left")
@@ -57,6 +57,7 @@ function level3.reset()
firstShip.fuel = 75 firstShip.fuel = 75
shipIsHit = false shipIsHit = false
planetsleft = 3 planetsleft = 3
end end
function level3.GUIControl() function level3.GUIControl()
if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then


+ 2
- 2
levels/level4.lua View File

@@ -31,8 +31,8 @@ function level4.load()
table.insert(guibutts, menu:addButton("To menu", function () table.insert(guibutts, menu:addButton("To menu", function ()
levelgeneral.goBack() levelgeneral.goBack()
end)) 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 end


function level4.reset() function level4.reset()


+ 5
- 5
levels/level5.lua View File

@@ -4,7 +4,7 @@ local M = {}
function level5.load() function level5.load()
shipsleft = 1 shipsleft = 1
local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
planetsleft = 5
planetsleft = 10
gameStatus = "setup" gameStatus = "setup"
playbutts = {} playbutts = {}
guibutts = {} guibutts = {}
@@ -31,9 +31,9 @@ function level5.load()
table.insert(guibutts, menu:addButton("To menu", function () table.insert(guibutts, menu:addButton("To menu", function ()
levelgeneral.goBack() levelgeneral.goBack()
end)) 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 end


function level5.reset() function level5.reset()
@@ -47,7 +47,7 @@ function level5.reset()
shipsleft = 1 shipsleft = 1
firstShip.fuel = 100 firstShip.fuel = 100
shipIsHit = false shipIsHit = false
planetsleft = 5
planetsleft = 10
end end
function level5.GUIControl() function level5.GUIControl()
if (love.keyboard.isDown('w') and VCAM.y > -WINDOW_WIDTH) then if (love.keyboard.isDown('w') and VCAM.y > -WINDOW_WIDTH) then


+ 2
- 0
levels/levelgeneral.lua View File

@@ -4,6 +4,7 @@ local M = {}
local thrusterMax = 0 local thrusterMax = 0
local animationComplete = false local animationComplete = false
local frame = 0 local frame = 0
asteroidImage = love.graphics.newImage("entities/planet/asteroid.png")
function levelgeneral.update(dt) function levelgeneral.update(dt)
if not levelLoaded then if not levelLoaded then
level = require("levels/level" .. currentLevel) level = require("levels/level" .. currentLevel)
@@ -81,6 +82,7 @@ function levelgeneral.draw()
love.graphics.clear(0,0,0,1) love.graphics.clear(0,0,0,1)
love.graphics.setColor(30/255, 30/255, 30/255, 1) love.graphics.setColor(30/255, 30/255, 30/255, 1)
if frame < WINDOW_WIDTH then if frame < WINDOW_WIDTH then
sounds["finish"]:play()
love.graphics.circle("fill", firstShip.x, firstShip.y, WINDOW_WIDTH - frame) love.graphics.circle("fill", firstShip.x, firstShip.y, WINDOW_WIDTH - frame)
end end
frame = frame + 20 frame = frame + 20


+ 15
- 1
levels/practice.lua View File

@@ -1,6 +1,7 @@
practice = Class{} practice = Class{}
local levelLoaded = false local levelLoaded = false
local M = {} local M = {}
local currenctScore = 0
function practice.update(dt) function practice.update(dt)
if not levelLoaded then if not levelLoaded then
shipsleft = 1 shipsleft = 1
@@ -9,7 +10,10 @@ function practice.update(dt)
playbutts = {} playbutts = {}
guibutts = {} guibutts = {}
XCAM = 0 XCAM = 0
currentScore = 0
thrusterMax = 0
YCAM = 0 YCAM = 0
firstShip.fuel = 0
explosions = {} explosions = {}
shipIsHit = false shipIsHit = false
guimenu = mainMenu() guimenu = mainMenu()
@@ -31,7 +35,6 @@ function practice.update(dt)
levelLoaded = true levelLoaded = true
end end
camera:update(dt) camera:update(dt)
--print(camera.x .. " " .. camera.y) --print(camera.x .. " " .. camera.y)
for i, explosion in ipairs(explosions) do for i, explosion in ipairs(explosions) do
explosion:update(dt) explosion:update(dt)
@@ -54,6 +57,7 @@ function practice.update(dt)
for i in ipairs(planets) do for i in ipairs(planets) do
planets[i]:update(dt) planets[i]:update(dt)
end end
currentScore = currentScore + math.sqrt(firstShip.dx^2 + firstShip.dy^2)
else else
camera:follow(VCAM.x, VCAM.y) camera:follow(VCAM.x, VCAM.y)
end end
@@ -81,7 +85,10 @@ function practice.draw()
if gameStatus == "setup" then if gameStatus == "setup" then
GUIDraw("anywhere") GUIDraw("anywhere")
practice.hint()
elseif gameStatus == "play" then 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) guimenu:butt(playbutts, WINDOW_WIDTH, WINDOW_HEIGHT, 1100, WINDOW_HEIGHT-50, 40, WINDOW_WIDTH/3)
love.keyboard.mouseisReleased = false love.keyboard.mouseisReleased = false
end end
@@ -102,8 +109,13 @@ function practice.reset()
planets[k] = nil planets[k] = nil
end end
shipsleft = 1 shipsleft = 1
if currentScore > saveData.score then
saveData.score = currentScore
end
currentScore = 0
shipIsHit = false shipIsHit = false
planetsleft = 10 planetsleft = 10
firstShip.fuel = 99999
end end
function practice.GUIControl() function practice.GUIControl()
if (love.keyboard.isDown('w')) then if (love.keyboard.isDown('w')) then
@@ -125,6 +137,8 @@ function practice.hint()
love.graphics.print("↓[S]",50,100) love.graphics.print("↓[S]",50,100)
love.graphics.print("←[A]",10,50) love.graphics.print("←[A]",10,50)
love.graphics.print("→[D]",100,50) love.graphics.print("→[D]",100,50)


end end
return practice return practice

+ 2
- 1
main.lua View File

@@ -15,7 +15,8 @@ OFFSET_Y = 0
currentLevel = 0 currentLevel = 0


saveData = { saveData = {
levelsBeaten = 0
levelsBeaten = 0,
score = 0
} }


planets = {} planets = {}


+ 1
- 0
src/GUI.lua View File

@@ -45,6 +45,7 @@ function GUIDraw(mode)
love.keyboard.mouseisReleased = false love.keyboard.mouseisReleased = false
firstShip.x = vmx firstShip.x = vmx
firstShip.y = vmy firstShip.y = vmy
sounds["appear"]:play()
shipsleft = shipsleft - 1 shipsleft = shipsleft - 1
end end
if shipsleft == 0 then if shipsleft == 0 then


+ 1
- 0
src/dependencies.lua View File

@@ -11,6 +11,7 @@ require 'src/GUI'
require 'stateMachine' require 'stateMachine'
require 'entities/base/base' require 'entities/base/base'
require 'entities/camera/VCAM' require 'entities/camera/VCAM'
require 'src/musicController'
tick = require 'src/tick' tick = require 'src/tick'
utf8 = require("utf8") utf8 = require("utf8")
serialize = require 'src/ser' serialize = require 'src/ser'

+ 6
- 2
src/mainMenu.lua View File

@@ -15,7 +15,7 @@ function mainMenu:butt(buttons, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, locationx, locati
local my = my * DIFFERENCE_Y 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 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 if (hot == i) then
color = {10, 10, 0, 255}
color = {10/255, 10/255, 10/255, 255}
end end
button.now = love.keyboard.mouseisReleased button.now = love.keyboard.mouseisReleased
if location == "android" then 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 if button.now and hot == i then
love.keyboard.mouseisReleased = false love.keyboard.mouseisReleased = false
button.fn() button.fn()
musicController("click")
hot = false hot = false
break break
end 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.rectangle("fill", ev_bx,ev_by, ev_button_width, ev_BUTTON_HEIGHT)
love.graphics.setColor(0, 0, 0, 255) love.graphics.setColor(0, 0, 0, 255)
local textW = smallfont:getWidth(button.text) 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.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) love.graphics.setColor(255, 255, 255, 255)
cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin) cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin)


+ 35
- 0
src/musicController.lua View File

@@ -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

+ 1
- 0
stateMachine.lua View File

@@ -6,6 +6,7 @@ function stateUpdate(dt)
if love.keyboard.isDown('escape') then if love.keyboard.isDown('escape') then
love.event.quit() love.event.quit()
end end
musicController("norm")
end end






Loading…
Cancel
Save