2023-01-13 18:28:58 +00:00
|
|
|
--Load poems.
|
|
|
|
local love = love
|
2023-01-15 20:46:32 +00:00
|
|
|
local feet = {}
|
|
|
|
local feetNL = {}
|
|
|
|
local words = {} --Sequence of tables.
|
|
|
|
local poem = {[0] = ""}
|
2023-01-15 22:29:21 +00:00
|
|
|
local poemLang = { [0] = "" }
|
2023-01-15 20:46:32 +00:00
|
|
|
local poemLines = {[0] = 0}
|
|
|
|
|
|
|
|
local mt = { __index = function() return "linja" end }
|
|
|
|
|
|
|
|
local s = love.filesystem.read( "text/tok.txt" )
|
2023-01-22 15:22:51 +00:00
|
|
|
local instrFont = love.graphics.newFont( 18 )
|
2023-01-24 22:30:38 +00:00
|
|
|
local enFont = love.graphics.setNewFont( "text/yod-linja-sike.ttf", 18 )
|
|
|
|
local smallFont = love.graphics.setNewFont( "text/yod-linja-sike.ttf", 24 )
|
|
|
|
local largeFont = love.graphics.setNewFont( "text/yod-linja-sike.ttf", 64 )
|
2023-01-15 22:29:21 +00:00
|
|
|
|
2023-01-15 20:46:32 +00:00
|
|
|
|
|
|
|
local i = 1
|
|
|
|
--Split string into feet.
|
|
|
|
for foot in s:gmatch( ".-%-") do
|
2023-01-15 22:29:21 +00:00
|
|
|
|
2023-01-15 20:46:32 +00:00
|
|
|
feet[i] = foot:gsub( "-", "" ):gsub( " $", "" ):gsub( "%c", "") --Remove hyphens, trailing spaces, newlines.
|
|
|
|
feetNL[i] = foot:gsub( "-", "" ):gsub(" ", "")--:gsub( "%.", " " ) --Remove hyphens, spaces, transform periods to spaces
|
2023-01-15 22:29:21 +00:00
|
|
|
|
|
|
|
|
2023-01-15 20:46:32 +00:00
|
|
|
poem[i] = poem[ i - 1 ]..feetNL[i]
|
|
|
|
poemLines[i] = poemLines[i - 1] + (feetNL[i]:match( "\n") and 1 or 0)
|
|
|
|
|
2023-01-15 22:29:21 +00:00
|
|
|
|
2023-01-15 20:46:32 +00:00
|
|
|
i = i + 1
|
|
|
|
end
|
|
|
|
|
|
|
|
--Split string into words.
|
|
|
|
i = 1
|
|
|
|
local isTe = true
|
|
|
|
for foot in s:gmatch( ".-%-" ) do
|
|
|
|
--Split foot into words.
|
|
|
|
local word = {}
|
|
|
|
local j = 1
|
|
|
|
|
|
|
|
for w in foot:gmatch( [["]] ) do
|
2023-01-22 15:22:51 +00:00
|
|
|
|
2023-01-15 20:46:32 +00:00
|
|
|
word[j] = isTe and "te" or "to"
|
|
|
|
isTe = not( isTe )
|
|
|
|
j = j + 1
|
2023-01-22 15:22:51 +00:00
|
|
|
|
2023-01-15 20:46:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
for w in foot:gmatch( "%a+" ) do
|
|
|
|
word[j] = w
|
|
|
|
j = j + 1
|
2023-01-13 18:28:58 +00:00
|
|
|
end
|
2023-01-15 20:46:32 +00:00
|
|
|
words[i] = word
|
|
|
|
i = i + 1
|
2023-01-13 18:28:58 +00:00
|
|
|
end
|
|
|
|
|
2023-01-15 20:46:32 +00:00
|
|
|
local function Draw( beat )
|
|
|
|
|
|
|
|
local foot = feet[ beat ]
|
2023-01-22 15:22:51 +00:00
|
|
|
|
2023-01-15 22:29:21 +00:00
|
|
|
if beat == 1 then
|
2023-01-22 15:22:51 +00:00
|
|
|
love.graphics.setColor(1.0, 1.0, 1.0, 1.0)
|
2023-01-16 04:38:47 +00:00
|
|
|
love.graphics.printf( "your.own.drum",
|
2023-01-22 15:22:51 +00:00
|
|
|
largeFont,
|
|
|
|
0, 0,
|
|
|
|
love.graphics.getWidth(),
|
|
|
|
"center"
|
2023-01-16 04:38:47 +00:00
|
|
|
)
|
|
|
|
|
2023-01-22 15:22:51 +00:00
|
|
|
love.graphics.printf(
|
|
|
|
[[
|
|
|
|
wasd move
|
|
|
|
space restart
|
|
|
|
return recall
|
|
|
|
o options]],
|
|
|
|
instrFont,
|
|
|
|
0, love.graphics.getHeight() - 4 * instrFont:getHeight(),
|
|
|
|
love.graphics.getWidth(),
|
|
|
|
"left"
|
|
|
|
)
|
|
|
|
return
|
2023-01-15 22:29:21 +00:00
|
|
|
end
|
2023-01-15 20:46:32 +00:00
|
|
|
|
|
|
|
|
2023-01-15 22:29:21 +00:00
|
|
|
love.graphics.setColor(1.0, 1.0, 1.0, 0.5)
|
|
|
|
local lineNumber
|
|
|
|
if poemLines[beat] < 2 then lineNumber = 0
|
|
|
|
else lineNumber = 2 - poemLines[beat]
|
|
|
|
end
|
|
|
|
love.graphics.printf( poem[beat],
|
|
|
|
smallFont,
|
|
|
|
8, lineNumber * smallFont:getHeight(),
|
|
|
|
love.graphics.getWidth(),
|
|
|
|
"left"
|
|
|
|
)
|
|
|
|
|
2023-01-15 20:46:32 +00:00
|
|
|
love.graphics.setColor(1.0, 1.0, 1.0, 1.0)
|
2023-01-15 22:29:21 +00:00
|
|
|
love.graphics.printf( foot,
|
|
|
|
largeFont,
|
|
|
|
0, 0.87 * love.graphics.getHeight(),
|
2023-01-15 20:46:32 +00:00
|
|
|
love.graphics.getWidth(),
|
2023-01-15 22:29:21 +00:00
|
|
|
"center"
|
|
|
|
)
|
2023-01-15 20:46:32 +00:00
|
|
|
|
|
|
|
love.graphics.setColor(1.0, 1.0, 1.0, 0.5)
|
2023-01-15 22:29:21 +00:00
|
|
|
love.graphics.printf( poemLang[beat],
|
|
|
|
enFont,
|
|
|
|
-8, 0,--(2 - poemLines[beat]) * smallFont:getHeight(),
|
|
|
|
love.graphics.getWidth(),
|
|
|
|
"right"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
s = love.filesystem.read( "text/en.txt" )
|
|
|
|
i = 1
|
|
|
|
--Split string into lines.
|
|
|
|
for line in s:gmatch( ".-\n") do
|
|
|
|
|
|
|
|
line = line:gsub("%.", ","):gsub( " ", "." )
|
|
|
|
poemLang[i] = line
|
|
|
|
poemLang[i + 1], poemLang[i + 2], poemLang[i + 3] = poemLang[i], poemLang[i], poemLang[i]
|
2023-01-15 20:46:32 +00:00
|
|
|
|
|
|
|
|
2023-01-15 22:29:21 +00:00
|
|
|
i = i + 4
|
2023-01-15 20:46:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local Reset = function() end
|
|
|
|
|
|
|
|
return { feet = feet, words = words, feetNL = feetNL, Reset = Reset, Draw = Draw }
|