/ld27

To get this branch, use:
bzr branch http://9ix.org/bzr/ld27

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-08-26 00:10:14 UTC
  • Revision ID: josh@9ix.org-20130826001014-d7iobtdaet72558t
actually handle multiple goals in one maze

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
              self.maze2.playerScale = 0.5
35
35
              self.maze3.playerScale = 1
36
36
 
37
 
              self.goals = {}
 
37
              self.goals = {{},{},{}}
38
38
              the.goalsAchieved = 0
39
39
              for _, obj in ipairs(self.objects.sprites) do
40
40
                 if obj:instanceOf(Goal) then
41
41
                    obj.visible = false
42
 
                    self.goals[tonumber(obj.map)] = obj
 
42
                    table.insert(self.goals[tonumber(obj.map)], obj)
43
43
                 end
44
44
              end
45
45
 
70
70
                 end
71
71
 
72
72
                 if not (DEBUG and the.console.visible) then
73
 
                    --the.player.collider:collide(the.activeMaze)
74
 
                    the.player.collider:collide(the.activeGoal)
 
73
                    for _, goal in ipairs(the.activeGoals) do
 
74
                       the.player.collider:collide(goal)
 
75
                    end
75
76
                 end
76
77
 
77
78
                 if the.keys:justPressed('escape', 'q') then
92
93
                      the.activeBg.visible = false
93
94
                      the.activeBg = self.bgs[newMaze]
94
95
 
95
 
                      if the.activeGoal then
96
 
                         the.activeGoal.visible = false
 
96
                      for _, goal in ipairs(the.activeGoals) do
 
97
                         goal.visible = false
97
98
                      end
98
 
                      the.activeGoal = self.goals[newMaze]
 
99
                      the.activeGoals = self.goals[newMaze]
99
100
 
100
101
                      love.audio.play(self.switchSounds[math.random(#self.switchSounds)])
101
102
                   else
102
103
                      the.activeMaze = self.maze2
103
104
                      the.activeBg = self.bg
104
 
                      the.activeGoal = self.goals[2]
 
105
                      the.activeGoals = self.goals[2]
105
106
                   end
106
107
 
107
108
                   the.activeMaze:revive()
108
109
                   the.activeBg.visible = true
109
 
                   if the.activeGoal then
110
 
                      the.activeGoal.visible = true
 
110
                   for _, goal in ipairs(the.activeGoals) do
 
111
                      goal.visible = true
111
112
                   end
112
113
                   the.player.scale = the.activeMaze.playerScale
113
114
                   the.player.collider.width = the.player.width * the.activeMaze.playerScale