/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: 2014-07-03 14:43:25 UTC
  • Revision ID: josh@9ix.org-20140703144325-799ow43au3uimguy
zoetrope scaling patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
STRICT = true
2
 
DEBUG = true
 
2
DEBUG = false
3
3
 
4
4
require 'zoetrope'
5
5
--require 'pepperprof'
16
16
 
17
17
GameView = View:extend {
18
18
   gameStart = 0,
 
19
   switchSounds = {},
19
20
   onNew = function (self)
20
21
              self:loadLayers('data/map.lua')
21
22
              self.focus = the.player
33
34
              self.maze2.playerScale = 0.5
34
35
              self.maze3.playerScale = 1
35
36
 
36
 
              self.goals = {}
 
37
              self.goals = {{},{},{}}
37
38
              the.goalsAchieved = 0
38
39
              for _, obj in ipairs(self.objects.sprites) do
39
40
                 if obj:instanceOf(Goal) then
40
41
                    obj.visible = false
41
 
                    self.goals[tonumber(obj.map)] = obj
 
42
                    table.insert(self.goals[tonumber(obj.map)], obj)
42
43
                 end
43
44
              end
44
45
 
 
46
              local sndFiles = {'data/Explosion2.wav', 'data/Explosion3.wav', 'data/Hit_Hurt3.wav'}
 
47
 
 
48
              for _, sndFile in ipairs(sndFiles) do
 
49
                 local snd = love.audio.newSource(sndFile, 'static')
 
50
                 table.insert(self.switchSounds, snd)
 
51
              end
 
52
 
45
53
              --the.interface = Group:new()
46
54
 
47
55
              --self:add(the.interface)
52
60
              --the.profiler = newProfiler()
53
61
              --the.profiler:start()
54
62
 
55
 
              self.gameStart = love.timer.getMicroTime()
56
 
              self.lastChange = love.timer.getMicroTime()
 
63
              self.gameStart = love.timer.getTime()
 
64
              self.lastChange = love.timer.getTime()
57
65
           end,
58
66
   onUpdate = function(self, dt)
59
 
                 if the.player.active and love.timer.getMicroTime() > self.lastChange + 10 then
 
67
                 if the.player.active and love.timer.getTime() > self.lastChange + 10 then
60
68
                    -- switch maze
61
69
                    self:switchMaze()
62
70
                 end
63
71
 
64
72
                 if not (DEBUG and the.console.visible) then
65
 
                    --the.player.collider:collide(the.activeMaze)
66
 
                    the.player.collider:collide(the.activeGoal)
 
73
                    for _, goal in ipairs(the.activeGoals) do
 
74
                       the.player.collider:collide(goal)
 
75
                    end
67
76
                 end
68
77
 
69
78
                 if the.keys:justPressed('escape', 'q') then
84
93
                      the.activeBg.visible = false
85
94
                      the.activeBg = self.bgs[newMaze]
86
95
 
87
 
                      if the.activeGoal then
88
 
                         the.activeGoal.visible = false
 
96
                      for _, goal in ipairs(the.activeGoals) do
 
97
                         goal.visible = false
89
98
                      end
90
 
                      the.activeGoal = self.goals[newMaze]
 
99
                      the.activeGoals = self.goals[newMaze]
 
100
 
 
101
                      love.audio.play(self.switchSounds[math.random(#self.switchSounds)])
91
102
                   else
92
103
                      the.activeMaze = self.maze2
93
104
                      the.activeBg = self.bg
94
 
                      the.activeGoal = self.goals[2]
 
105
                      the.activeGoals = self.goals[2]
95
106
                   end
96
107
 
97
108
                   the.activeMaze:revive()
98
109
                   the.activeBg.visible = true
99
 
                   if the.activeGoal then
100
 
                      the.activeGoal.visible = true
 
110
                   for _, goal in ipairs(the.activeGoals) do
 
111
                      goal.visible = true
101
112
                   end
102
113
                   the.player.scale = the.activeMaze.playerScale
103
114
                   the.player.collider.width = the.player.width * the.activeMaze.playerScale
106
117
                   self._fx = {0,0,0,0}
107
118
                   self.tween:start(self._fx, 4, 175, 10, 'quadIn')
108
119
 
109
 
                   self.lastChange = love.timer.getMicroTime()
 
120
                   self.lastChange = love.timer.getTime()
110
121
                end,
111
122
   onEndFrame = function(self)
112
123
                   --the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2
122
133
 
123
134
              local nr = 'data/NewRocker-Regular.otf'
124
135
              self:add(Text:new{
125
 
                          text = 'Name Of Game',
 
136
                          text = 'Treasures of the Decimaze',
126
137
                          --x = 0,
127
138
                          y = 100,
128
139
                          width = self.bg.width,
132
143
                       })
133
144
 
134
145
              self:add(Text:new{
135
 
                          text = 'Find the 3 lost shinies!',
 
146
                          text = 'Find the 4 lost shinies!',
136
147
                          y = 170,
137
148
                          width = self.bg.width,
138
149
                          font = {nr, 28},
168
179
}
169
180
 
170
181
the.app = App:new {
 
182
   name = "Treasures of the Decimaze",
171
183
   onRun = function (self)
172
184
              print('Version: ' .. VERSION)
173
185
 
183
195
              end
184
196
           end,
185
197
   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
186
202
              end
187
203
}