diff --git a/main.lua b/main.lua index 469a371..8f285e1 100644 --- a/main.lua +++ b/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 diff --git a/mine.ogg b/mine.ogg new file mode 100644 index 0000000..a820b89 Binary files /dev/null and b/mine.ogg differ diff --git a/player.lua b/player.lua index d8b935c..557d649 100644 --- a/player.lua +++ b/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