-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel.lua
More file actions
89 lines (84 loc) · 2.52 KB
/
Copy pathlevel.lua
File metadata and controls
89 lines (84 loc) · 2.52 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
-- 0 fond
-- 1 mur
-- 2 PorteOuverte
-- 3 PorteFermé
-- 4 Bouton / Pressure plate
-- 5 Boite
-- 'P' Joueur
Level = Object:extend()
function Level:new()
self.map = {}
self.map.start = "present"
self.map.actual = self.map.start
self.map.present = {}
self.map.presentBackground = love.graphics.newImage("res/present_bg.png")
self.map.futurBackground = love.graphics.newImage("res/futur_bg.png")
self.map.futur = {}
self.entities = {}
self.entities.present = {}
self.entities.futur = {}
self.playerSpawn = {}
self.nextLevel = nil
self.isEnded = false
self.canPlayerTimeTravel = false
end
function Level:createMap()
for time, map in pairs({["present"]=self.map.present, ["futur"]=self.map.futur})
do
for i, v in ipairs(map)
do
for j, w in ipairs(v)
do
if type(w) == "number" then
if w == 1
then
table.insert(self.entities[time], Wall((j-1)*50, (i-1)*50))
elseif w == 2 or w == 3
then
table.insert(self.entities[time], Door((j-1)*50, (i-1)*50, w))
elseif w == 4
then
table.insert(self.entities[time], Lever((j-1)*50, (i-1)*50))
elseif w == 5
then
table.insert(self.entities[time], Box((j-1)*50, (i-1)*50))
elseif w == 6
then
table.insert(self.entities[time], Banana((j-1)*50, (i-1)*50))
elseif w == 7
then
table.insert(self.entities[time], Teleportatron((j-1)*50, (i-1)*50))
end
elseif type(w) == "string" then
if w == 'P' then
self.playerSpawn = {x=(j-1)*50, y=(i-1)*50}
end
else
if w.type == "Lever" then
table.insert(self.entities[time], Lever((j-1)*50, (i-1)*50, w.linkedTo, w.id))
elseif w.type == "Door" then
table.insert(self.entities[time], Door((j-1)*50, (i-1)*50, w.status, w.linkedId, w.id))
elseif w.type == "PressurePlate" then
table.insert(self.entities[time], PressurePlate((j-1)*50, (i-1)*50, w.linkedTo, w.id))
elseif w.type == "MagicWall" then
table.insert(self.entities[time], MagicWall((j-1)*50, (i-1)*50, w.status, w.linkedId, w.id))
end
end
end
end
end
end
function Level:getAllEntities()
return self.entities[self.map.actual]
end
function Level:timeTravel()
if self.canPlayerTimeTravel
then
if self.map.actual == "present"
then
self.map.actual = "futur"
else
self.map.actual = "present"
end
end
end