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)
|
love.graphics.setFont(font)
|
||||||
|
|
||||||
|
|
||||||
minesound = love.audio.newSource("mine.ogg", "static")
|
minesound = love.audio.newSource("mine.ogg", "static")
|
||||||
|
placesound = love.audio.newSource("place.ogg", "static")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
15
menu.lua
15
menu.lua
@ -62,7 +62,22 @@ function menu.draw()
|
|||||||
love.graphics.setFont(fontmed)
|
love.graphics.setFont(fontmed)
|
||||||
love.graphics.setColor(255,255,255,255)
|
love.graphics.setColor(255,255,255,255)
|
||||||
love.graphics.print("Score:"..tostring(math.random(0,20000000)), 400,110)
|
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
|
--debug player's pos
|
||||||
|
love.graphics.setColor(255,255,255,255)
|
||||||
love.graphics.print("PosX:"..player.playerx.." PosY:"..player.playery, 400,150)
|
love.graphics.print("PosX:"..player.playerx.." PosY:"..player.playery, 400,150)
|
||||||
end
|
end
|
||||||
|
29
player.lua
29
player.lua
@ -2,6 +2,8 @@
|
|||||||
player = {}
|
player = {}
|
||||||
player.playerx,player.playery = 1,1
|
player.playerx,player.playery = 1,1
|
||||||
|
|
||||||
|
player.mining = true
|
||||||
|
|
||||||
--controls
|
--controls
|
||||||
|
|
||||||
function love.keypressed( key, scancode, isrepeat )
|
function love.keypressed( key, scancode, isrepeat )
|
||||||
@ -22,6 +24,10 @@ function love.keypressed( key, scancode, isrepeat )
|
|||||||
end
|
end
|
||||||
collision(oldposx,oldposy)
|
collision(oldposx,oldposy)
|
||||||
|
|
||||||
|
if key == "space" then
|
||||||
|
player.mining = not player.mining
|
||||||
|
end
|
||||||
|
|
||||||
mine(key)
|
mine(key)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -47,13 +53,26 @@ function mine(key)
|
|||||||
y = 1
|
y = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--cancel if nothing
|
||||||
|
if x == 0 and y == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
--play sound and remove tile
|
--play sound and remove tile
|
||||||
if tiles[player.playerx+x][player.playery+y]["block"] ~= 0 then
|
if player.mining == true then
|
||||||
minesound:setPitch(love.math.random(50,100)/100)
|
if tiles[player.playerx+x][player.playery+y]["block"] ~= 0 then
|
||||||
minesound:stop()
|
minesound:setPitch(love.math.random(50,100)/100)
|
||||||
minesound:play()
|
minesound:stop()
|
||||||
tiles[player.playerx+x][player.playery+y]["block"] = 0
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user