block.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. local textures = {
  2. k = lovr.graphics.newTexture('art/blockK.png'),
  3. e = lovr.graphics.newTexture('art/blockE.png'),
  4. y = lovr.graphics.newTexture('art/blockY.png')
  5. }
  6. local cubeFace = lovr.graphics.newMesh({
  7. { -.25, .25, 0, 0,0,0, 0, 0 },
  8. { .25, .25, 0, 0,0,0, 1, 0 },
  9. { -.25, -.25, 0, 0,0,0, 0, 1 },
  10. { .25, -.25, 0, 0,0,0, 1, 1 }
  11. }, 'strip')
  12. cubeFace:setMaterial(lovr.graphics.newMaterial())
  13. -- DAMMIT
  14. return function(letter)
  15. g.setColor(1, 1, 1)
  16. cubeFace:getMaterial():setTexture(textures[letter])
  17. g.push()
  18. g.rotate(0, 0, 1, 0)
  19. g.translate(0, 0, .25)
  20. cubeFace:draw()
  21. g.pop()
  22. g.push()
  23. g.rotate(math.pi / 2, 0, 1, 0)
  24. g.translate(0, 0, .25)
  25. cubeFace:draw()
  26. g.pop()
  27. g.push()
  28. g.rotate(math.pi, 0, 1, 0)
  29. g.translate(0, 0, .25)
  30. cubeFace:draw()
  31. g.pop()
  32. g.push()
  33. g.rotate(3 * math.pi / 2, 0, 1, 0)
  34. g.translate(0, 0, .25)
  35. cubeFace:draw()
  36. g.pop()
  37. g.push()
  38. g.rotate(math.pi / 2, 1, 0, 0)
  39. g.translate(0, 0, .25)
  40. cubeFace:draw()
  41. g.pop()
  42. g.push()
  43. g.rotate(-math.pi / 2, 1, 0, 0)
  44. g.translate(0, 0, .25)
  45. cubeFace:draw()
  46. g.pop()
  47. end