Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local game = {}
- largeurTuile = 70
- hauteurTuile = 70
- largeurMap = 5
- hauteurMap = 10
- game.map = {
- {1,1,3,4,5},
- {1,2,3,4,5},
- {1,2,3,4,5},
- {1,2,3,4,5},
- {1,2,3,4,5},
- {1,2,3,4,5},
- {1,2,3,4,5},
- {1,2,3,4,5},
- {1,2,3,4,5},
- {1,1,3,4,5},
- }
- function game.load()
- game.texture = {}
- game.texture[0] = nil
- game.texture[1] = love.graphics.newImage("images/grassCenter.png")
- game.texture[2] = love.graphics.newImage("images/liquidLava.png")
- game.texture[3] = love.graphics.newImage("images/liquidWater.png")
- game.texture[4] = love.graphics.newImage("images/snowCenter.png")
- game.texture[5] = love.graphics.newImage("images/stoneCenter.png")
- end
- function game.draw()
- local c,l
- for l = 1, largeurMap do
- for c = 1,hauteurMap do
- --ligne 1 et colonne c
- local id = game.map[l][c]
- local tex = game.texture[id]
- if tex ~= nil then
- love.graphics.draw(tex,(c-1)*largeurTuile, (l-1)*hauteurTuile)
- end
- end
- end
- local x = love.mouse.getX()
- local y = love.mouse.getY()
- --convertir les coordonnées en colonnes
- local col = math.floor(x / largeurTuile) + 1
- local lig = math.floor(y / hauteurTuile) + 1
- --a verifier
- if col >= 0 and col <= largeurMap and lig >= 0 and lig <= hauteurMap then
- local id = game.map[lig][col]
- --local tex = Game.TileTextures[l][c]
- love.graphics.print("ID:"..tostring(id),1,1)
- else
- love.graphics.print("Hors du tableau!",1,1)
- end
- end
- return game
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement