Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. local game = {}
  2.  
  3. largeurTuile = 70
  4. hauteurTuile = 70
  5.  
  6. largeurMap = 5
  7. hauteurMap = 10
  8.  
  9. game.map = {
  10. {1,1,3,4,5},
  11. {1,2,3,4,5},
  12. {1,2,3,4,5},
  13. {1,2,3,4,5},
  14. {1,2,3,4,5},
  15. {1,2,3,4,5},
  16. {1,2,3,4,5},
  17. {1,2,3,4,5},
  18. {1,2,3,4,5},
  19. {1,1,3,4,5},
  20. }
  21.  
  22.  
  23.  
  24. function game.load()
  25.  
  26. game.texture = {}
  27. game.texture[0] = nil
  28. game.texture[1] = love.graphics.newImage("images/grassCenter.png")
  29. game.texture[2] = love.graphics.newImage("images/liquidLava.png")
  30. game.texture[3] = love.graphics.newImage("images/liquidWater.png")
  31. game.texture[4] = love.graphics.newImage("images/snowCenter.png")
  32. game.texture[5] = love.graphics.newImage("images/stoneCenter.png")
  33. end
  34.  
  35. function game.draw()
  36.  
  37. local c,l
  38. for l = 1, largeurMap do
  39. for c = 1,hauteurMap do
  40. --ligne 1 et colonne c
  41. local id = game.map[l][c]
  42. local tex = game.texture[id]
  43. if tex ~= nil then
  44. love.graphics.draw(tex,(c-1)*largeurTuile, (l-1)*hauteurTuile)
  45. end
  46. end
  47. end
  48.  
  49. local x = love.mouse.getX()
  50. local y = love.mouse.getY()
  51.  
  52. --convertir les coordonnées en colonnes
  53. local col = math.floor(x / largeurTuile) + 1
  54. local lig = math.floor(y / hauteurTuile) + 1
  55.  
  56. --a verifier
  57. if col >= 0 and col <= largeurMap and lig >= 0 and lig <= hauteurMap then
  58. local id = game.map[lig][col]
  59. --local tex = Game.TileTextures[l][c]
  60. love.graphics.print("ID:"..tostring(id),1,1)
  61. else
  62. love.graphics.print("Hors du tableau!",1,1)
  63. end
  64. end
  65.  
  66. return game
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement