first commit

This commit is contained in:
Niouby 2015-02-20 02:00:54 +01:00
commit d9201ce4a8
6 changed files with 95 additions and 0 deletions

11
AliveCell.lua Normal file
View File

@ -0,0 +1,11 @@
AliveCell = Cell.new()
AliveCell.__index = AliveCell
function AliveCell.new(n)
local self = setmetatable({}, AliveCell)
return self
end
function AliveCell:getColor()
return 0xfff2b0a4
end

12
Cell.lua Normal file
View File

@ -0,0 +1,12 @@
Cell = {}
Cell.__index = Cell
function Cell.new(n)
local self = setmetatable({}, Cell)
return self
end
function Cell:getColor()
return 0xffd2e2d8
end

11
DeadCell.lua Normal file
View File

@ -0,0 +1,11 @@
DeadCell = Cell.new()
DeadCell.__index = DeadCell
function DeadCell.new(n)
local self = setmetatable({}, DeadCell)
return self
end
function DeadCell:getColor()
return 0xff9d8c84
end

6
README.md Normal file
View File

@ -0,0 +1,6 @@
Usage
retroarch -L libretro_lutro.so path/to/main.lua

34
World.lua Normal file
View File

@ -0,0 +1,34 @@
require "Cell"
World = {}
World.__index = World
function World.new(n)
local self = setmetatable({}, World)
self.grid = {}
for i=0,99 do
self.grid[i] = {}
for j=0,99 do
self.grid[i][j] = Cell.new()
end
end
self.grid[10][10] = AliveCell.new()
self.grid[20][10] = DeadCell.new()
return self
end
function World:getNbColumn()
return #self.grid
end
function World:getNbLine()
return #self.grid[1]
end
function World:draw()
for i=1,self:getNbColumn() do
for j=1,self:getNbLine() do
lutro.graphics.rectangle(i*2,j*2,1,1, self.grid[i][j]:getColor())
end
end
end

21
main.lua Normal file
View File

@ -0,0 +1,21 @@
require "World"
require "Cell"
require "AliveCell"
require "DeadCell"
function lutro.conf(t)
t.width = 200
t.height = 200
end
function lutro.load()
w1 = World.new(1)
end
function lutro.update(dt)
end
function lutro.draw()
w1:draw()
end