After trying to use Plu's way, I am still confused. Where does the "cooldown = 5" go?
Code: Select all
function love.load()
cooldown = 0
smallshack = love.graphics.newImage("smallshack.png")
-- lumber left
lumber = 200
-- cost of a house
-- amount of population
pop = 3
houseCost = 50
-- houses - hold all generated houses
houses = {}
smallshackCounter = 1
end
-- and lumber >= 50
function love.update( dt )
cooldown = cooldown - dt
if love.keyboard.isDown("z") and cooldown < 0 then
if smallshackCounter == 1 then
smallshack2State = "drawn"
lumber = lumber - 50
smallshackCounter = smallshackCounter + 1
pop = pop + 3
cooldown = 5 -- this will install a 5 second wait because cooldown will now be larger than 0 for 5 seconds
end
if smallshackCounter == 2 then
smallshack3State = "drawn"
lumber = lumber - 50
smallshackCounter = smallshackCounter + 1
pop = pop + 3
end
end
if smallshackCounter == 3 then
smallshack4State = "drawn"
lumber = lumber - 50
smallshackCounter = smallshackCounter + 1
pop = pop + 3
end
end
function love.draw()
charitybutton = love.graphics.newImage("charitybutton.png")--displays the charity button
x = 530
y = 530
love.graphics.draw(charitybutton,x, y)
bottommenu = love.graphics.newImage("bottommenu.png")
x = 10
y = 410
love.graphics.draw(bottommenu,x, y) --displays the bottom menu
divider = love.graphics.newImage("divider.png")
x = 0
y = 405
love.graphics.draw(divider,x, y) --displays the divider
tree1 = love.graphics.newImage("tree1.png")
x = 700
y = 100
love.graphics.draw(tree1,x, y)
x = 750
y = 233
love.graphics.draw(tree1,x, y)
x = 668
y = 292
love.graphics.draw(tree1,x, y)
tree2 = love.graphics.newImage("tree2.png")
x = 690
y = 260
love.graphics.draw(tree2,x, y)
x = 623
y = 220
love.graphics.draw(tree2,x, y)
x = 780
y = 100
love.graphics.draw(tree2,x, y)
tree3 = love.graphics.newImage("tree3.png")
x = 700
y = 150
love.graphics.draw(tree3,x, y)
x = 600
y = 100
love.graphics.draw(tree3,x, y)
x = 620
y = 300
love.graphics.draw(tree3,x, y)
lumbercamp = love.graphics.newImage("lumbercamp.png")
x = 500
y = 200
love.graphics.draw(lumbercamp,x, y)
x = 50
y = 50
love.graphics.draw(smallshack,x, y)
guy = love.graphics.newImage("guy.png")
x = 600
y = 200
love.graphics.draw(guy,x, y)
x = 590
y = 300
love.graphics.draw(guy,x, y)
x = 685
y = 340
love.graphics.draw(guy,x, y)
topmenu = love.graphics.newImage("topmenu.png")
x = 530
y = 460
love.graphics.draw(topmenu,x, y)
love.graphics.print("Created by Ryan Martin", 3, 575)
love.graphics.print("V1.0", 210, 575)
love.graphics.print("x3", 100, 490)
love.graphics.print("x10", 270, 490)
love.graphics.print("x5", 415, 490)
love.graphics.print("50", 8, 443)
love.graphics.print("100", 165, 443)
love.graphics.print("150", 310, 443)
love.graphics.print("z", 50, 530)
love.graphics.print("x", 220, 530)
love.graphics.print("c", 360, 585)
love.graphics.print(pop, 672, 470)
love.graphics.print(lumber, 535, 470)
if smallshack2State == "drawn" then
love.graphics.draw (smallshack, 300, 300)
end
if smallshack3State == "drawn" then
love.graphics.draw (smallshack, 250, 250)
end
if smallshack4State == "drawn" then
love.graphics.draw (smallshack, 100, 100)
end
end