Leveling system

This commit is contained in:
Alexey 2025-06-25 16:51:23 +03:00
commit efe9f386bd
6 changed files with 83 additions and 26 deletions

39
makegrid.lua Normal file
View file

@ -0,0 +1,39 @@
require 'grid'
require 'line'
require 'point'
-- Constructs line from { start x, start y, end x, end y, color }
---@param table table
---@return Line
local function makeLine( table )
local startpoint = GridPoint:new( table[1], table[2] )
local endpoint = GridPoint:new( table[3], table[4] )
return Line:new( startpoint, endpoint, Color[table[5]] )
end
-- Constructs all game objects using data table
-- table = {
-- -- Size
-- width = 5,
-- height = 5,
-- -- Lines
-- lines = {
-- -- start x, start y, end x, end y, color
-- { 1, 1, 3, 3, "red" },
-- { 1, 5, 5, 2, "green" },
-- { 2, 5, 5, 3, "blue" }
-- }
-- }
---@param table table
---@return Grid
function MakeGrid( table )
local size = Point:new( table.width, table.height )
local grid = Grid:new( size )
for _, lineData in ipairs( table.lines ) do
local line = makeLine( lineData )
grid:push( line )
end
return grid
end