/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 15:28:23 UTC
  • Revision ID: josh@9ix.org-20140703152823-4241je58pflhx7ec
scaling

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
8
3
 
9
4
require 'zoetrope'
10
5
--require 'pepperprof'
27
22
              self.focus = the.player
28
23
              self:clampTo(self.bg)
29
24
 
30
 
              the.app:setScaling(self)
 
25
              self.scale = the.app.scale
31
26
 
32
27
              self.mazes = {self.maze1, self.maze2, self.maze3}
33
28
              self.bgs = {self.bg, self.bg, self.bg2}
135
130
MenuScreen = View:extend {
136
131
   bg = Tile:new{image = 'data/intro.png', x = 0, y = 0},
137
132
   onNew = function(self)
138
 
              the.app:setScaling(self)
 
133
              self.scale = the.app.scale
139
134
 
140
135
              self:add(self.bg)
141
136
              --self.title:centerAround(400, 200)
212
207
                    ss:encode('screenshot-' ..love.timer.getTime()..'.png')
213
208
                 end
214
209
              end,
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
 
 
 
210
   setScaling = function(self)
224
211
     local winw, winh = love.window.getMode()
225
212
     --if love.window.getFullscreen() then
226
213
     if winw == self.width and winh == self.height then
227
214
       self.scale = 1
228
 
       view.realTranslate = { x=0, y=0 }
 
215
       self.view.realTranslate = { x=0, y=0 }
229
216
       love.graphics.setScissor()
230
217
     else
231
218
       --self.scale = math.min(
237
224
       elseif winh < the.app.height then
238
225
         self.scale = winh / the.app.height
239
226
       end
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)
 
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)
243
230
 
244
231
       love.graphics.setColor(0,0,0)
245
232
       love.graphics.rectangle('fill', 0, 0, winw, winh)
246
 
       love.graphics.setScissor( view.realTranslate.x,
247
 
                                 view.realTranslate.y,
 
233
       love.graphics.setScissor( self.view.realTranslate.x,
 
234
                                 self.view.realTranslate.y,
248
235
                                 self.width * self.scale,
249
236
                                 self.height * self.scale)
250
237
     end
251
238
 
252
 
     view.scale = self.scale
 
239
     self.view.scale = self.scale
253
240
   end
254
241
}
255
242