/ld26-basecode

To get this branch, use:
bzr branch /bzr/ld26-basecode
4 by Josh C
basecode
1
STRICT = true
2
DEBUG = true
3
4
require 'zoetrope'
5
6
require 'sprite'
7
require 'version'
8
9
util = {
10
   dim = function(dir)
11
      if dir == 'x' then
12
         return 'width'
13
      elseif dir == 'y' then
14
         return 'height'
15
      else
16
         if STRICT then error('dir '..dir) end
17
      end
18
   end
19
}
20
21
GameView = View:extend {
22
   onNew = function (self)
23
              t = Text:new{y = 300, width = the.app.width, align = 'center',
24
                           text = 'This space intentionally left blank'}
25
              self:add(t)
26
27
              --self:loadLayers('data/map.lua')
28
              --self.focus = the.player
29
              --self:clampTo(self.map)
30
           end,
31
   draw = function (self, x, y)
32
             View.draw(self, x, y)
33
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
34
          end
35
}
36
37
MenuScreen = View:extend {
38
   title = Text:new{text = "Press a key to start", font = 48, wordWrap = false},
39
   --title = Tile:new{image = 'data/title.png', x = 0, y = 0},
40
   onNew = function(self)
41
              self:add(self.title)
42
              self.title:centerAround(400, 200)
43
           end,
44
   onUpdate = function(self, elapsed)
45
                 if the.keys:allJustPressed() then
46
                    the.app.view = GameView:new()
47
                 end
48
              end
49
}
50
51
the.app = App:new {
52
   record = true,
53
   onRun = function (self)
54
              self.view = MenuScreen:new()
55
              if DEBUG then
56
                 self.console:watch('VERSION', 'VERSION')
57
                 self.console:watch('updateTook', 'the.updateTook')
58
                 --self.console:watch('drawTook', 'the.drawTook')
59
              end
60
           end,
61
   onUpdate = function (self, dt)
62
                 if the.keys:justPressed('escape') then
63
                    self.quit()
64
                 end
65
              end,
66
   update = function (self, dt)
67
               the.updateStart = love.timer.getMicroTime()
68
               App.update(self, dt)
69
               if the.updateStart then
70
                  the.updateTook = love.timer.getMicroTime() - the.updateStart
71
               end
72
            end
73
}