FANDOM


This will constitute the template for all new object file. I advise to make it a snippet.

You are obviously free to rearrange the shape and identations to your convenience, but this is made so everyone can work with the same calls and environnement.

TemplateEdit

-----------------------------------------------------------
----    CObject definition
-----------------------------------------------------------

------------------------
-- Description
--[[
    
]]

-----------------------------------------------------------
------------------------
--  Init
CObject = {}
CObject.__index = CObject

------------------------
--  Properties
CObject.type = "CObject"


------------------------
--  Constructor
function CObject:create(proto)
    local Object = {}
    setmetatable(Object, CObject)
    
    
    
    return Object
end


------------------------
--  Callbacks

function CObject:load()
    
end

function CObject:draw()
    
end

function CObject:update(dt)
    
end

function CObject:mousepressed(x, y, btn)
    
end

function CObject:keypressed(key)
    
end

function CObject:mousereleased(x, y, btn)
    
end

function CObject:keyreleased(key)
    
end

------------------------
--  Static functions
function CObject.classFunc(arg)
    -- I am only useful for the class itself and static properties.
    
end

------------------------
--  Gets & Sets
function CObject:getType()
    return self.type
end


------------------------
--  Member functions
function CObject:dummyProcedure()
    -- I just do nothing
    
end

function CObject:__tostring()
    -- I translate in a string what the Object is
    -- TODO

end

print "CObject loaded"

DescriptionEdit

The name CObject stands for a class of the object 'Object', you will have to replace 'Object' by the name of what you want to make.

The description section will contain a detailed description on the 'Object', what is used for, its purpose, a TODO list if it's a work in progress, ...

The Callback section can be shortened if the object don't interact that way, this is for Love2D.

The Static function section will contain class wise function, like if you make a CPoint object, all of them can have the same reference, stored in the class itself and accessed/modified with static funtions.

The Gets & Set functions are compulsory accessors to the properties, and should be filled with asserts commands.

The Member function section will contain all functions that need to acces or modify properties of the object, not the class. They should be declared with the self instruction or the shortcut ':'.