/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-04 22:05:15 UTC
  • Revision ID: josh@9ix.org-20140704220515-1lyoulmix915mlcp
propagate scaling / translate properly

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
STRICT = true
2
2
DEBUG = false
 
3
LOVEBIRD = false
 
4
 
 
5
if SDL then
 
6
  print = SDL.log
 
7
end
3
8
 
4
9
require 'zoetrope'
5
10
--require 'pepperprof'
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)
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
       require('lovebird').update()
 
218
     end
 
219
     App.update(self, dt)
 
220
   end,
 
221
   setScaling = function(self, view)
 
222
     local view = view or the.app.view
 
223
 
211
224
     local winw, winh = love.window.getMode()
212
225
     --if love.window.getFullscreen() then
213
226
     if winw == self.width and winh == self.height then
214
227
       self.scale = 1
215
 
       self.view.realTranslate = { x=0, y=0 }
 
228
       view.realTranslate = { x=0, y=0 }
216
229
       love.graphics.setScissor()
217
230
     else
218
231
       --self.scale = math.min(
224
237
       elseif winh < the.app.height then
225
238
         self.scale = winh / the.app.height
226
239
       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)
 
240
       view.realTranslate.x = math.floor((winw - self.width * self.scale) / 2)
 
241
       view.realTranslate.y = math.floor((winh - self.height * self.scale) / 2)
 
242
       --print('translate: ' .. view.realTranslate.x .. ', ' .. view.realTranslate.y)
230
243
 
231
244
       love.graphics.setColor(0,0,0)
232
245
       love.graphics.rectangle('fill', 0, 0, winw, winh)
233
 
       love.graphics.setScissor( self.view.realTranslate.x,
234
 
                                 self.view.realTranslate.y,
 
246
       love.graphics.setScissor( view.realTranslate.x,
 
247
                                 view.realTranslate.y,
235
248
                                 self.width * self.scale,
236
249
                                 self.height * self.scale)
237
250
     end
238
251
 
239
 
     self.view.scale = self.scale
 
252
     view.scale = self.scale
240
253
   end
241
254
}
242
255