placing
This commit is contained in:
parent
75296ae5c5
commit
00b5f301cf
2
main.lua
2
main.lua
@ -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
|
||||
|
||||
|
||||
|
15
menu.lua
15
menu.lua
@ -63,6 +63,21 @@ function menu.draw()
|
||||
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
|
||||
|
29
player.lua
29
player.lua
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user