Advertisement
Guest User

Untitled

a guest
Sep 12th, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. -- Setup
  2. local loader = require("AdvTiledLoader.Loader")
  3. loader.path = "maps/"
  4. map = loader.load("desert.tmx")
  5. tileLayer = map.layers["Ground"]
  6. require ("mobs")
  7.  
  8. ---------------------------------------------------------------------------------------------------
  9. -- Fare ad inizio del livello in modo da assicurarsi che boxboy sia nel posto giusto
  10. Boy.moveTile(0,0)
  11. Boy.facing = "down"
  12.  
  13. ---------------------------------------------------------------------------------------------------
  14. -- Dichiarato come classe.
  15. local DesertExample = {}
  16.  
  17. ---------------------------------------------------------------------------------------------------
  18. -- Funzione che verrà richiamata nel main
  19. function DesertExample.keypressed(k)
  20.     if k == 'w' then Boy.moveTile(0,-1) end
  21.     if k == 'a' then Boy.moveTile(-1,0) end
  22.     if k == 's' then Boy.moveTile(0,1) end
  23.     if k == 'd' then Boy.moveTile(1,0) end
  24. end
  25.  
  26. ---------------------------------------------------------------------------------------------------
  27. -- Prepara camera e boxboy per il prossimo livello
  28. function DesertExample.nextLevel()
  29.     global.tX = -5
  30.     global.tY = -434
  31.     Boy.tileX = 8
  32.     Boy.tileY = 22
  33.     Boy.moveTile(0,0)
  34.     Boy.facing = "down"
  35.     displayTime = 0
  36. end
  37.  
  38. ---------------------------------------------------------------------------------------------------
  39. -- Aggiorna mappa.
  40. function DesertExample.update(dt)
  41. end
  42.  
  43. ---------------------------------------------------------------------------------------------------
  44. -- Called from love.draw()
  45. function DesertExample.draw()
  46.     local ftX, ftY = math.floor(global.tX), math.floor(global.tY)
  47.     love.graphics.translate(ftX, ftY)
  48.     map:draw()
  49.     love.graphics.draw(Boy.image, Boy.quads[Boy.facing], Boy.x, Boy.y)
  50.     love.graphics.print(global.tX,100,100)  
  51. end
  52.  
  53. ---------------------------------------------------------------------------------------------------
  54. return DesertExample
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement