Code: Select all
love.graphics.draw(trollface, trollx, trolly)
Code: Select all
love.graphics.draw(trollface, trollx, trolly)
Code: Select all
function love.load()
drawtroll = true
end
function love.draw()
if drawtroll == true then
love.graphics.draw(trollface, trollx, trolly)
end
end
function love.keypressed(key)
if key == "q" then
drawtroll = true
elseif key == "w" then
drawtroll = false
end
end
Just so you know, there's an even more convenient way to write that in Lua:veethree wrote:Code: Select all
function love.draw() if drawtroll == true then love.graphics.draw(trollface, trollx, trolly) end end
Code: Select all
function love.draw()
if drawtroll then
love.graphics.draw(trollface, trollx, trolly)
end
end
That is indeed convenient as hell..wish i had found out about that sooner. hahatentus wrote:Just so you know, there's an even more convenient way to write that in Lua:veethree wrote:Code: Select all
function love.draw() if drawtroll == true then love.graphics.draw(trollface, trollx, trolly) end end
In Lua, you don't have to say == true, and if you want to see if something is false, you can just say not before the variable name. I find that these two little details contribute greatly towards the legibility of Lua.Code: Select all
function love.draw() if drawtroll then love.graphics.draw(trollface, trollx, trolly) end end
That's not specific to Lua. As a matter of fact, I can't think of a single programming language where you can't as long as "drawtroll" is a boolean (although the specific syntax of course varies).tentus wrote:Just so you know, there's an even more convenient way to write that in Lua:veethree wrote:Code: Select all
function love.draw() if drawtroll == true then love.graphics.draw(trollface, trollx, trolly) end end
In Lua, you don't have to say == true, and if you want to see if something is false, you can just say not before the variable name. I find that these two little details contribute greatly towards the legibility of Lua.Code: Select all
function love.draw() if drawtroll then love.graphics.draw(trollface, trollx, trolly) end end
Code: Select all
trol = {}
if trol then
print("yes")
end
Code: Select all
function on_collide(dt, a, b, x,y)
if ents[b.id].reaction then
ents[b.id]:reaction()
end
if b.solid then
a:move(x,y)
end
end
Users browsing this forum: Google [Bot] and 2 guests