AsciiArt
This commit is contained in:
@@ -19,49 +19,7 @@ ContinuedWindow.text = [[
|
||||
--- @within ContinuedWindow
|
||||
function ContinuedWindow.draw()
|
||||
cls(Config.colors.black)
|
||||
local lines = {}
|
||||
local max_len = 0
|
||||
-- Get all lines and find max length
|
||||
for line in (ContinuedWindow.text .. "\n"):gmatch("(.-)\n") do
|
||||
table.insert(lines, line)
|
||||
if #line > max_len then max_len = #line end
|
||||
end
|
||||
|
||||
-- Clean up empty lines from the start/end
|
||||
if #lines > 0 and lines[1] == "" then table.remove(lines, 1) end
|
||||
if #lines > 0 and lines[#lines] == "" then table.remove(lines, #lines) end
|
||||
|
||||
local char_w = 4
|
||||
local char_h = 5
|
||||
local line_gap = 0
|
||||
local word_gap = 6
|
||||
|
||||
local total_h = 0
|
||||
for _, line in ipairs(lines) do
|
||||
if line:find("#") then
|
||||
total_h = total_h + char_h + line_gap
|
||||
else
|
||||
total_h = total_h + word_gap
|
||||
end
|
||||
end
|
||||
total_h = total_h - line_gap
|
||||
|
||||
local current_y = (Config.screen.height - total_h) / 2
|
||||
local x_offset = (Config.screen.width - (max_len * char_w)) / 2
|
||||
|
||||
for _, line in ipairs(lines) do
|
||||
if line:find("#") then
|
||||
for j = 1, #line do
|
||||
local char = line:sub(j, j)
|
||||
if char == "#" then
|
||||
rect(x_offset + (j - 1) * char_w, current_y, char_w - 1, char_h - 1, Config.colors.light_blue)
|
||||
end
|
||||
end
|
||||
current_y = current_y + char_h + line_gap
|
||||
else
|
||||
current_y = current_y + word_gap
|
||||
end
|
||||
end
|
||||
AsciiArt.draw(ContinuedWindow.text, {})
|
||||
end
|
||||
|
||||
--- Updates the continued window logic.
|
||||
|
||||
@@ -23,49 +23,7 @@ TitleIntroWindow.text = [[
|
||||
--- Draws the title intro window.
|
||||
--- @within TitleIntroWindow
|
||||
function TitleIntroWindow.draw()
|
||||
local lines = {}
|
||||
local max_len = 0
|
||||
-- Get all lines and find max length
|
||||
for line in (TitleIntroWindow.text .. "\n"):gmatch("(.-)\n") do
|
||||
table.insert(lines, line)
|
||||
if #line > max_len then max_len = #line end
|
||||
end
|
||||
|
||||
-- Clean up empty lines from the start/end
|
||||
if #lines > 0 and lines[1] == "" then table.remove(lines, 1) end
|
||||
if #lines > 0 and lines[#lines] == "" then table.remove(lines, #lines) end
|
||||
|
||||
local char_w = 4
|
||||
local char_h = 5
|
||||
local line_gap = 0
|
||||
local word_gap = 6
|
||||
|
||||
local total_h = 0
|
||||
for _, line in ipairs(lines) do
|
||||
if line:find("#") then
|
||||
total_h = total_h + char_h + line_gap
|
||||
else
|
||||
total_h = total_h + word_gap
|
||||
end
|
||||
end
|
||||
total_h = total_h - line_gap
|
||||
|
||||
local current_y = (Config.screen.height - total_h) / 2
|
||||
local x_offset = (Config.screen.width - (max_len * char_w)) / 2
|
||||
|
||||
for _, line in ipairs(lines) do
|
||||
if line:find("#") then
|
||||
for j = 1, #line do
|
||||
local char = line:sub(j, j)
|
||||
if char == "#" then
|
||||
rect(x_offset + (j - 1) * char_w, current_y, char_w - 1, char_h - 1, Config.colors.light_blue)
|
||||
end
|
||||
end
|
||||
current_y = current_y + char_h + line_gap
|
||||
else
|
||||
current_y = current_y + word_gap
|
||||
end
|
||||
end
|
||||
AsciiArt.draw(TitleIntroWindow.text, {})
|
||||
end
|
||||
|
||||
--- Updates the title intro window logic.
|
||||
|
||||
@@ -12,34 +12,11 @@ TTGIntroWindow.text = [[
|
||||
--- Draws the TTG intro window.
|
||||
--- @within TTGIntroWindow
|
||||
function TTGIntroWindow.draw()
|
||||
if not TTGIntroWindow.glitch_started then
|
||||
Glitch.show()
|
||||
TTGIntroWindow.glitch_started = true
|
||||
end
|
||||
|
||||
local lines = {}
|
||||
local max_len = 0
|
||||
for line in TTGIntroWindow.text:gmatch("[^\r\n]+") do
|
||||
table.insert(lines, line)
|
||||
if #line > max_len then max_len = #line end
|
||||
end
|
||||
|
||||
local char_w = 6
|
||||
local char_h = 7
|
||||
local y = (Config.screen.height - (#lines * char_h + 12)) / 2
|
||||
local x_offset = (Config.screen.width - (max_len * char_w)) / 2
|
||||
|
||||
for i, line in ipairs(lines) do
|
||||
for j = 1, #line do
|
||||
local char = line:sub(j, j)
|
||||
if char == "#" then
|
||||
rect(x_offset + (j - 1) * char_w, y + (i - 1) * char_h, char_w - 1, char_h - 1, Config.colors.light_blue)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Print.text_center("Teletype Games", Config.screen.width / 2, y + #lines * char_h + 4, Config.colors.light_blue)
|
||||
local bounds = AsciiArt.draw(TTGIntroWindow.text, {})
|
||||
if not bounds then return end
|
||||
Print.text_center("Teletype Games", (Config.screen.width / 2 + 3) , (bounds.bottom + 4), Config.colors.light_blue)
|
||||
end
|
||||
|
||||
--- Updates the TTG intro window logic.
|
||||
--- @within TTGIntroWindow
|
||||
function TTGIntroWindow.update()
|
||||
|
||||
Reference in New Issue
Block a user