-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmapLoader.lua
More file actions
69 lines (59 loc) · 2 KB
/
mapLoader.lua
File metadata and controls
69 lines (59 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
M={}
function generateMap(arg,layer)
map = require(arg)
tramap={}
ligne={}
image=love.graphics.newImage("Assets/Atlas/"..map.tilesets[1].image)
for i = 1,map.layers[layer].width do
ligne={}
for j = 1,map.layers[layer].height do
table.insert(ligne,map.layers[layer].data[i*map.layers[layer].width-map.layers[layer].width+j])
end
table.insert(tramap,ligne)
end
return tramap
end
function makeQuad()
environement={}
stackLine=image:getWidth()/map.tilesets[1].tilewidth
for j=1,16 do
environement[j] = {}
for i=1,33 do
environement[j][i]=love.graphics.newQuad(
(i-1)%(stackLine)*map.tilesets[1].tilewidth,
math.floor(i/(stackLine +1))*map.tilesets[1].tilewidth + j * 96,map.tilesets[1].tilewidth,map.tilesets[1].tilewidth,image:getWidth(),image:getHeight())
end
end
return environement
end
function Draw(tab, x, y)
love.graphics.setColor(58 / 255, 18 / 255, 59 / 255)
love.graphics.rectangle("fill", x + 16, y + 160, 304, 800)
love.graphics.setColor(71 / 255, 46 / 255, 98 / 255)
love.graphics.rectangle("fill", x + 16, y + 160, -304, 800)
love.graphics.setColor(1,1,1)
for i = 1,map.layers[1].width do
for j = 1,map.layers[1].height do
stackLine=image:getWidth()/map.tilesets[1].tilewidth
id=tab[i][j]
if id>0 and id~=nil then
local xpos = 16*j- 16*i
local ypos = 8*i+ 8*j
if id >= 10 then
ypos = ypos - 16
end
my_frame = math.floor((frame)/4) % 15 + 1
if (id > 23) then
love.graphics.draw(image,environement[1][1],xpos + x,ypos + y)
love.graphics.setColor(currentMap[player1.lvl].color[1],currentMap[player1.lvl].color[2],currentMap[player1.lvl].color[3])
end
love.graphics.draw(image,environement[my_frame][id],xpos + x,ypos + y)
love.graphics.setColor(1,1,1)
end
end
end
end
M.generateMap=generateMap
M.makeQuad=makeQuad
M.Draw=Draw
return M