0
\$\begingroup\$

Okay so i have two files one named Player.lua and one named Main.lua

Main:

function love.load()
end

function love.update()
end

function love.draw()
end

Player:

function player.load()
end

function player.update()
end

function player.draw()
    love.graphics.setColor(255, 0, 0)
    love.graphics.rectangle("fill", 50, 50, 50, 50)
end

Output is just a black screen!

\$\endgroup\$
  • \$\begingroup\$ Hello, Ras. M, and welcome to Game Development! Maybe you can improve your question by expanding the description of your work, and better addressing your issues, so that we can better understand and help you. \$\endgroup\$ – liggiorgio Jun 8 '16 at 9:47
1
\$\begingroup\$

The main.lua file is automatically executed from the Löve application and the overriden functions love.load, love.update and love.draw get called.

This means that if in your main.lua file you've included the love.load function, at the start of the game that function is called; then, if there's a love.update function, it gets called too, then the love.draw if it's present, and then back to update, draw, update, and so on.

So the player.lua file will never gets executed, unless you tell the program to execute it from main.lua.

main.lua

function love.load()
    require "player.lua"
    player.load()
end

function love.update()
    player.update()
end

function love.draw()
    player.draw()
end

This is how it should look like.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.