draw.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. local charset = ("\
  2. ☺☻♥♦♣♠•◘○◙♂♀♪♫☼\
  3. ►◄↕‼¶§▬↨↑↓→←∟↔▲▼\
  4. !\"#$%&'()*+,-./\
  5. 0123456789:;<=>?\
  6. @ABCDEFGHIJKLMNO\
  7. PQRSTUVWXYZ[\\]^_\
  8. `abcdefghijklmno\
  9. pqrstuvwxyz{|}~⌂\
  10. ÇüéâäàåçêëèïîìÄÅ\
  11. ÉæÆôöòûùÿÖÜ¢£¥₧ƒ\
  12. áíóúñѪº¿⌐¬½¼¡«»\
  13. ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐\
  14. └┴┬├─┼╞╟╚╔╩╦╠═╬╧\
  15. ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀\
  16. αßΓπΣσµτΦΘΩδ∞φε∩\
  17. ≡±≥≤⌠⌡÷≈°∙·√ⁿ²■�"):gsub("\n", "")
  18. function loadFont()
  19. font = love.graphics.newImageFont("dwarf.png", charset)
  20. love.graphics.setFont(font)
  21. end
  22. function newGrid()
  23. local grid = {}
  24. for y = 1, HEIGHT do
  25. grid[y] = {}
  26. for x = 1, WIDTH do
  27. grid[y][x] = {char = ' '}
  28. end
  29. end
  30. return grid
  31. end
  32. function drawText(grid, message)
  33. for y = 1, HEIGHT do
  34. for x = 1, WIDTH do
  35. if grid[y][x].color then
  36. love.graphics.setColor(grid[y][x].color)
  37. else
  38. love.graphics.setColor(COLOR.WHITE)
  39. end
  40. love.graphics.print(grid[y][x].char, 9 * x - 9, 12 * y - 9)
  41. end
  42. end
  43. love.graphics.print(message, 0, HEIGHT * 12)
  44. end