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

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

BIN
mine.ogg Normal file

Binary file not shown.

@ -29,23 +29,32 @@ end
--mining
function mine(key)
local x,y = 0,0
if key == "a" then
if player.playerx > 1 then
tiles[player.playerx-1][player.playery]["block"] = 0
x = -1
end
elseif key == "d" then
if player.playerx < mapwidth then
tiles[player.playerx+1][player.playery]["block"] = 0
x = 1
end
elseif key == "w" then
if player.playery > 1 then
tiles[player.playerx][player.playery-1]["block"] = 0
y = -1
end
elseif key == "s" then
if player.playery < mapheight then
tiles[player.playerx][player.playery+1]["block"] = 0
y = 1
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