In my simple game, you must rebuild your houses after a natural disaster. But it seems that I have run into a dilemma. When the "z" key is pressed, I want a house drawn, given there is 50 lumber in the stockpile. During the debugging, when I press the "z" key, no house appears, nor is 50 lumber subtracted.
Here's the code:
smallshack = love.graphics.newImage("smallshack.png")
function love.keypressed(key)
if key == "z" then
lumber = lumber - 50
love.draw()
x = 200
y = 200
love.graphics.draw(smallshack, x, y)
end
end
I don't understand the problem. Could you possibly explain to me my errors?
smallshack = love.graphics.newImage("smallshack.png")
function love.keypressed(key)
if key == "z" then
lumber = lumber - 50
love.draw()
x = 200
y = 200
love.graphics.draw(smallshack, x, y)
end
end
You might want to try out some tutorials first, mainly to learn how to work with the lua main loops ( love.load, love.update, love.draw ).
Another great way to learn things is to look at other people's source code ( just said if you don't know it already ;] )
on topic:
Heres a pretty ugly, but hopefully easy to understand example of what you want to happen.
houses.love
You can open the file with any .zip unpacking tool and look at the source.
Maybe this simple example help somehow. If you've further questions, feel free to ask