Add sound
This commit is contained in:
parent
edacf7014b
commit
75296ae5c5
4
main.lua
4
main.lua
@ -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
|
||||
|
||||
|
||||
|
17
player.lua
17
player.lua
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user