--Load poems. local love = love local feet = {} local feetNL = {} local words = {} --Sequence of tables. local poem = {[0] = ""} local poemLang = { [0] = "" } local poemLines = {[0] = 0} local mt = { __index = function() return "linja" end } local s = love.filesystem.read( "text/tok.txt" ) local instrFont = love.graphics.newFont( 24 ) 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 ) local i = 1 --Split string into feet. for foot in s:gmatch( ".-%-") do 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 poem[i] = poem[ i - 1 ]..feetNL[i] poemLines[i] = poemLines[i - 1] + (feetNL[i]:match( "\n") and 1 or 0) 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 word[j] = isTe and "te" or "to" isTe = not( isTe ) j = j + 1 end for w in foot:gmatch( "%a+" ) do word[j] = w j = j + 1 end words[i] = word i = i + 1 end local function Draw( beat ) local foot = feet[ beat ] if beat == 1 then love.graphics.setColor(0, 0, 0, 0.5) if options["high contrast"].value then love.graphics.setColor( 1, 1, 1, 1 ) end love.graphics.rectangle( "fill", 0.5 * love.graphics.getWidth() - 250, 10, 500, 1.1 * largeFont:getHeight(), 10, 10 ) love.graphics.rectangle( "fill", 0.5 * love.graphics.getWidth() - 200, love.graphics.getHeight() - 5.25 * instrFont:getHeight(), 400, 4.5 * instrFont:getHeight(), 50, 50 ) love.graphics.setColor(1.0, 1.0, 1.0, 1.0 ) if options["high contrast"].value then love.graphics.setColor( 0, 0, 0, 1 ) end love.graphics.printf( "your.own.drum", largeFont, 0, 0, love.graphics.getWidth(), "center" ) love.graphics.printf( [[ WASD MOVE SPACE RESTART RETURN DEMOS O OPTIONS]], instrFont, 0.5 * love.graphics.getWidth() - 150, love.graphics.getHeight() - 5 * instrFont:getHeight(), 300, "justify" ) return end love.graphics.setColor(1.0, 1.0, 1.0, 0.5) if options["high contrast"].value then love.graphics.setColor( 0, 0, 0, 1 ) end 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" ) love.graphics.setColor(1.0, 1.0, 1.0, 1.0) if options["high contrast"].value then love.graphics.setColor( 0, 0, 0, 1 ) end love.graphics.printf( foot, largeFont, 0, 0.87 * love.graphics.getHeight(), love.graphics.getWidth(), "center" ) love.graphics.setColor(1.0, 1.0, 1.0, 0.5) if options["high contrast"].value then love.graphics.setColor( 0, 0, 0, 1 ) end 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 = 0 --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] i = i + 4 end local Reset = function() end return { feet = feet, words = words, feetNL = feetNL, Reset = Reset, Draw = Draw }