Beginner Coding Problem 2
Posted: Thu Feb 13, 2014 1:48 am
Basically, the game I am making is one in which you must rebuild a town after a natural disaster. When you press the "z" key and you have at least 50 lumber, a house is drawn. However, whenever I press the "z" key multiple houses are drawn at the same time because you can make multiple houses. My question is: How can you make a time buffer between drawing each house so that all the houses are not drawn at the same time?
The part that needs work:
Thank you in advance.
The part that needs work:
Code: Select all
function love.update(dt)
if lumber >= 50 then
if love.keyboard.isDown("z") then
if smallshackCounter == 1 then
smallshack2State = "drawn"
lumber = lumber - 50
smallshackCounter = smallshackCounter + 1
pop = pop + 3
end
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