This commit is contained in:
jordan4ibanez 2017-06-20 02:16:21 -04:00
parent 75296ae5c5
commit 00b5f301cf
4 changed files with 41 additions and 5 deletions

View File

@ -26,7 +26,9 @@ function love.load()
love.graphics.setFont(font)
minesound = love.audio.newSource("mine.ogg", "static")
placesound = love.audio.newSource("place.ogg", "static")
end

View File

@ -62,7 +62,22 @@ function menu.draw()
love.graphics.setFont(fontmed)
love.graphics.setColor(255,255,255,255)
love.graphics.print("Score:"..tostring(math.random(0,20000000)), 400,110)
--debug mining
if player.mining == true then
love.graphics.setColor(255,0,0,255)
love.graphics.print("Mining", 400,180)
love.graphics.setColor(128,128,128,255)
love.graphics.print("Placing", 560,180)
elseif player.mining == false then
love.graphics.setColor(128,128,128,255)
love.graphics.print("Mining", 400,180)
love.graphics.setColor(255,0,0,255)
love.graphics.print("Placing", 560,180)love.graphics.print("PosX:"..player.playerx.." PosY:"..player.playery, 400,150)
end
--debug player's pos
love.graphics.setColor(255,255,255,255)
love.graphics.print("PosX:"..player.playerx.." PosY:"..player.playery, 400,150)
end

BIN
place.ogg Normal file

Binary file not shown.

View File

@ -2,6 +2,8 @@
player = {}
player.playerx,player.playery = 1,1
player.mining = true
--controls
function love.keypressed( key, scancode, isrepeat )
@ -22,6 +24,10 @@ function love.keypressed( key, scancode, isrepeat )
end
collision(oldposx,oldposy)
if key == "space" then
player.mining = not player.mining
end
mine(key)
end
@ -47,13 +53,26 @@ function mine(key)
y = 1
end
end
--cancel if nothing
if x == 0 and y == 0 then
return
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
if player.mining == true then
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
elseif player.mining == false then
if tiles[player.playerx+x][player.playery+y]["block"] == 0 then
placesound:setPitch(love.math.random(50,100)/100)
placesound:stop()
placesound:play()
tiles[player.playerx+x][player.playery+y]["block"] = 1
end
end
end