class

v0.0.3
class(name);

Create a metatable

Arguments

nameThe class name

local Player = class('Player');

function Player:init(x, y)
  self.x = x;
  self.y = y;
  return self;
end

function Player:draw()
  circle(self.x, self.y, 16);
end


-- Create 2 players and draw them
local p1 = Player:new(100, 200);
local p2 = Player:new(300, 200);

function setup()
  createWindow(400, 400);
end

function draw()
  background(51);

  p1:draw();
  p2:draw();
end
See class in classes.h