Dissecting Mari0 - Loading Text

Often

New Member
OP
Newbie
Joined
Mar 5, 2016
Messages
0
Trophies
0
XP
60
Country
United States
0eqn5aS.png


Code:
function love.load()

   scale = 2
   
   love.graphics.setBackgroundColor(0, 0, 0)
   
   fontimage = love.graphics.newImage("graphics/SMB/font.png")
   
   fontglyphs = "0123456789abcdefghijklmnopqrstuvwxyz.:/,'C-_>* !{}?"
   
   fontquads = {}
   
   for i = 1, string.len(fontglyphs) do
   
     fontquads[string.sub(fontglyphs, i, i)] = love.graphics.newQuad((i-1)*8, 0, 8, 8, 512, 8)
     
   end
   
   love.graphics.setColor(100, 100, 100)
   
   loadingtexts = {"loading.."}
   
   loadingtext = loadingtexts[math.random(#loadingtexts)]
   
   love.graphics.present()
   
end



function love.draw()

   properprint(loadingtext, (20*4*scale-string.len(loadingtext)*2*scale)+1, (54*scale)+9)
   
end



function properprint(s, x, y)

   local startx = x
   
   for i = 1, string.len(tostring(s)) do
   
     local char = string.sub(s, i, i)
     
     if char == "|" then
     
       x = startx-((i)*8)*scale
       
       y = y + 10*scale
       
     elseif fontquads[char] then
     
      love.graphics.setScreen("bottom")
     
       love.graphics.draw(fontimage, fontquads[char], x+((i-1)*4)*scale, y, 0, 2, scale, scale)
       
     end
     
   end
   
end



function love.keypressed(key)

  if key == 'start' then
   
  love.event.quit()
     
  end
   
end
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: Also touch is better.... Well at least better than the launch DS, the lite one improved that a ton