/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-25 22:47:18 UTC
  • Revision ID: josh@9ix.org-20130825224718-c93zymxgkm9r3kjh
play silly sound on level switch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
STRICT = true
2
 
DEBUG = false
 
2
DEBUG = true
3
3
 
4
4
require 'zoetrope'
5
5
--require 'pepperprof'
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
 
                    table.insert(self.goals[tonumber(obj.map)], obj)
 
42
                    self.goals[tonumber(obj.map)] = obj
43
43
                 end
44
44
              end
45
45
 
60
60
              --the.profiler = newProfiler()
61
61
              --the.profiler:start()
62
62
 
63
 
              self.gameStart = love.timer.getTime()
64
 
              self.lastChange = love.timer.getTime()
 
63
              self.gameStart = love.timer.getMicroTime()
 
64
              self.lastChange = love.timer.getMicroTime()
65
65
           end,
66
66
   onUpdate = function(self, dt)
67
 
                 if the.player.active and love.timer.getTime() > self.lastChange + 10 then
 
67
                 if the.player.active and love.timer.getMicroTime() > self.lastChange + 10 then
68
68
                    -- switch maze
69
69
                    self:switchMaze()
70
70
                 end
71
71
 
72
72
                 if not (DEBUG and the.console.visible) then
73
 
                    for _, goal in ipairs(the.activeGoals) do
74
 
                       the.player.collider:collide(goal)
75
 
                    end
 
73
                    --the.player.collider:collide(the.activeMaze)
 
74
                    the.player.collider:collide(the.activeGoal)
76
75
                 end
77
76
 
78
77
                 if the.keys:justPressed('escape', 'q') then
93
92
                      the.activeBg.visible = false
94
93
                      the.activeBg = self.bgs[newMaze]
95
94
 
96
 
                      for _, goal in ipairs(the.activeGoals) do
97
 
                         goal.visible = false
 
95
                      if the.activeGoal then
 
96
                         the.activeGoal.visible = false
98
97
                      end
99
 
                      the.activeGoals = self.goals[newMaze]
 
98
                      the.activeGoal = self.goals[newMaze]
100
99
 
101
100
                      love.audio.play(self.switchSounds[math.random(#self.switchSounds)])
102
101
                   else
103
102
                      the.activeMaze = self.maze2
104
103
                      the.activeBg = self.bg
105
 
                      the.activeGoals = self.goals[2]
 
104
                      the.activeGoal = self.goals[2]
106
105
                   end
107
106
 
108
107
                   the.activeMaze:revive()
109
108
                   the.activeBg.visible = true
110
 
                   for _, goal in ipairs(the.activeGoals) do
111
 
                      goal.visible = true
 
109
                   if the.activeGoal then
 
110
                      the.activeGoal.visible = true
112
111
                   end
113
112
                   the.player.scale = the.activeMaze.playerScale
114
113
                   the.player.collider.width = the.player.width * the.activeMaze.playerScale
117
116
                   self._fx = {0,0,0,0}
118
117
                   self.tween:start(self._fx, 4, 175, 10, 'quadIn')
119
118
 
120
 
                   self.lastChange = love.timer.getTime()
 
119
                   self.lastChange = love.timer.getMicroTime()
121
120
                end,
122
121
   onEndFrame = function(self)
123
122
                   --the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2
133
132
 
134
133
              local nr = 'data/NewRocker-Regular.otf'
135
134
              self:add(Text:new{
136
 
                          text = 'Treasures of the Decimaze',
 
135
                          text = 'Name Of Game',
137
136
                          --x = 0,
138
137
                          y = 100,
139
138
                          width = self.bg.width,
143
142
                       })
144
143
 
145
144
              self:add(Text:new{
146
 
                          text = 'Find the 4 lost shinies!',
 
145
                          text = 'Find the 3 lost shinies!',
147
146
                          y = 170,
148
147
                          width = self.bg.width,
149
148
                          font = {nr, 28},
179
178
}
180
179
 
181
180
the.app = App:new {
182
 
   name = "Treasures of the Decimaze",
183
181
   onRun = function (self)
184
182
              print('Version: ' .. VERSION)
185
183
 
195
193
              end
196
194
           end,
197
195
   onUpdate = function (self, dt)
198
 
                 if the.keys:justPressed('f1') then
199
 
                    local ss = love.graphics.newScreenshot()
200
 
                    ss:encode('screenshot-' ..love.timer.getTime()..'.png')
201
 
                 end
202
196
              end
203
197
}