Page 1 of 1

How end work.

Posted: Sun May 08, 2016 10:50 am
by Nutte
Hi!

I trying to make a game. But i wonder how the end command work? Why i must have 2 end in love.draw function ?

Re: How end work.

Posted: Sun May 08, 2016 10:55 am
by zorg
Exactly where did you see that you needed two ends with love.draw?

Re: How end work.

Posted: Sun May 08, 2016 11:06 am
by Nutte

Code: Select all

  function love.draw()
                       	     love.graphics.draw(grill, 500)
                       	     love.graphics.draw(bakrund)
                       	             if burgare then
                       	     love.graphics.draw(burgare, 40) 
                       	              love.graphics.draw(raw, 50)
                       	               end
                       	           end
My code i have write. Evryone write this drawcode with 2 ends, why?

Re: How end work.

Posted: Sun May 08, 2016 11:10 am
by zorg
Let me fix your identation first:

Code: Select all

function love.draw()
    love.graphics.draw(grill, 500)
    love.graphics.draw(bakrund)
    if burgare then
        love.graphics.draw(burgare, 40) 
        love.graphics.draw(raw, 50)
    end
end
The keywords "function", "if", "do", "while", "for" need their blocks to be closed with "end".
In your case, one end is for the if block, the other for the whole function.

Re: How end work.

Posted: Sun May 08, 2016 11:23 am
by Nutte
Thank you so much Zorg.