/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-06 22:51:43 UTC
  • Revision ID: josh@9ix.org-20140706225143-q72jn0va7v4ssvyy
ignore lovebird, inspect

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
STRICT = true
 
1
STRICT = false
2
2
DEBUG = false
3
3
 
 
4
if SDL then
 
5
  print = SDL.log
 
6
end
 
7
 
 
8
--lovebird = require 'lovebird'
4
9
require 'zoetrope'
5
10
--require 'pepperprof'
6
11
--inspect = require 'inspect'
22
27
              self.focus = the.player
23
28
              self:clampTo(self.bg)
24
29
 
25
 
              self.scale = the.app.scale
 
30
              the.app:setScaling(self)
26
31
 
27
32
              self.mazes = {self.maze1, self.maze2, self.maze3}
28
33
              self.bgs = {self.bg, self.bg, self.bg2}
130
135
MenuScreen = View:extend {
131
136
   bg = Tile:new{image = 'data/intro.png', x = 0, y = 0},
132
137
   onNew = function(self)
133
 
              self.scale = the.app.scale
 
138
              the.app:setScaling(self)
134
139
 
135
140
              self:add(self.bg)
136
141
              --self.title:centerAround(400, 200)
176
181
 
177
182
           end,
178
183
   onUpdate = function(self, elapsed)
179
 
                 if the.keys:allJustPressed() then
180
 
                    the.app.view = GameView:new()
181
 
                 end
182
 
              end
 
184
     if the.keys:allJustPressed() or the.mouse:pressed() then
 
185
       the.app.view = GameView:new()
 
186
     end
 
187
   end
183
188
}
184
189
 
185
190
the.app = App:new {
207
212
                    ss:encode('screenshot-' ..love.timer.getTime()..'.png')
208
213
                 end
209
214
              end,
210
 
   setScaling = function(self)
 
215
   update = function(self, dt)
 
216
     if lovebird then
 
217
       fps = love.timer.getFPS()
 
218
       lovebird.update()
 
219
     end
 
220
     App.update(self, dt)
 
221
   end,
 
222
   setScaling = function(self, view)
 
223
     local view = view or the.app.view
 
224
 
211
225
     local winw, winh = love.window.getMode()
212
226
     --if love.window.getFullscreen() then
213
227
     if winw == self.width and winh == self.height then
214
228
       self.scale = 1
215
 
       self.view.realTranslate = { x=0, y=0 }
 
229
       view.realTranslate = { x=0, y=0 }
216
230
       love.graphics.setScissor()
217
231
     else
218
232
       --self.scale = math.min(
224
238
       elseif winh < the.app.height then
225
239
         self.scale = winh / the.app.height
226
240
       end
227
 
       self.view.realTranslate.x = math.floor((winw - self.width * self.scale) / 2)
228
 
       self.view.realTranslate.y = math.floor((winh - self.height * self.scale) / 2)
229
 
       --print('translate: ' .. self.view.realTranslate.x .. ', ' .. self.view.realTranslate.y)
 
241
       view.realTranslate.x = math.floor((winw - self.width * self.scale) / 2)
 
242
       view.realTranslate.y = math.floor((winh - self.height * self.scale) / 2)
 
243
       --print('translate: ' .. view.realTranslate.x .. ', ' .. view.realTranslate.y)
230
244
 
231
245
       love.graphics.setColor(0,0,0)
232
246
       love.graphics.rectangle('fill', 0, 0, winw, winh)
233
 
       love.graphics.setScissor( self.view.realTranslate.x,
234
 
                                 self.view.realTranslate.y,
 
247
       love.graphics.setScissor( view.realTranslate.x,
 
248
                                 view.realTranslate.y,
235
249
                                 self.width * self.scale,
236
250
                                 self.height * self.scale)
237
251
     end
238
252
 
239
 
     self.view.scale = self.scale
 
253
     view.scale = self.scale
240
254
   end
241
255
}
242
256