Add sound

This commit is contained in:
jordan4ibanez 2017-06-20 01:59:18 -04:00
parent edacf7014b
commit 75296ae5c5
3 changed files with 17 additions and 4 deletions

View File

@ -19,10 +19,14 @@ end
function love.load() function love.load()
maplib.createmap() maplib.createmap()
font = love.graphics.newFont("font.ttf", 12) font = love.graphics.newFont("font.ttf", 12)
fontmed = love.graphics.newFont("font.ttf", 22) fontmed = love.graphics.newFont("font.ttf", 22)
fontbig = love.graphics.newFont("font.ttf", 35) fontbig = love.graphics.newFont("font.ttf", 35)
love.graphics.setFont(font) love.graphics.setFont(font)
minesound = love.audio.newSource("mine.ogg", "static")
end end

BIN
mine.ogg Normal file

Binary file not shown.

View File

@ -29,23 +29,32 @@ end
--mining --mining
function mine(key) function mine(key)
local x,y = 0,0
if key == "a" then if key == "a" then
if player.playerx > 1 then if player.playerx > 1 then
tiles[player.playerx-1][player.playery]["block"] = 0 x = -1
end end
elseif key == "d" then elseif key == "d" then
if player.playerx < mapwidth then if player.playerx < mapwidth then
tiles[player.playerx+1][player.playery]["block"] = 0 x = 1
end end
elseif key == "w" then elseif key == "w" then
if player.playery > 1 then if player.playery > 1 then
tiles[player.playerx][player.playery-1]["block"] = 0 y = -1
end end
elseif key == "s" then elseif key == "s" then
if player.playery < mapheight then if player.playery < mapheight then
tiles[player.playerx][player.playery+1]["block"] = 0 y = 1
end end
end end
--play sound and remove tile
if tiles[player.playerx+x][player.playery+y]["block"] ~= 0 then
minesound:setPitch(love.math.random(50,100)/100)
minesound:stop()
minesound:play()
tiles[player.playerx+x][player.playery+y]["block"] = 0
end
end end