mirror of
https://github.com/libretro/lutro-game-of-life.git
synced 2024-11-22 23:39:39 +00:00
first commit
This commit is contained in:
commit
d9201ce4a8
11
AliveCell.lua
Normal file
11
AliveCell.lua
Normal 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
12
Cell.lua
Normal 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
11
DeadCell.lua
Normal 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
6
README.md
Normal file
@ -0,0 +1,6 @@
|
||||
Usage
|
||||
|
||||
retroarch -L libretro_lutro.so path/to/main.lua
|
||||
|
||||
|
||||
|
34
World.lua
Normal file
34
World.lua
Normal 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
|
Loading…
Reference in New Issue
Block a user