I’m wondering about best practices for reusing code that is put in the update function.
For example movement.
If I want movement to be handled the same for different units should I put the code into a function that I then put into a LUA module and call this from the update function?
Like so:
local movement = require "..."
function update(self, dt)
movement.move()
end
I’m also not sure how I would reference the unit’s direction, speed, etc, should I pass those as arguments?
function update(self, dt)
movement.move(dir, speed, pos, dt)
end
Is LUA module the way to go or is there another good way to do it?