I am working on a survival game of currently just blocks avoiding each other and I'm getting to the point of inserting some animations and graphics. To avoid my files being very large and stuff being hard to find and debug, I want graphics stuff, AI stuff, inventory stuff etc outside the main.lua if it's possible.
I know you can use the require to link to other files, but can anyone tell me how to set that up? I'm planning to have a graphics.lua file that will contain a couple of references like an image called "spritesheet" and a couple of functions to do something with that image. in main.lua, I want to access those functions and references in code, like in love.draw().
for instance:
Code: Select all
-- main.lua
graphics = require 'graphics'
-- [...]
function love.update(dt)
graphics.doSomething(dt)
end
Code: Select all
-- graphics.lua
function doSomething(dt)
-- AAA-style graphics doing mindboggling stuff
end