/traderous

To get this branch, use:
bzr branch http://9ix.org/bzr/traderous

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-05-04 20:47:29 UTC
  • Revision ID: josh@9ix.org-20130504204729-0g2wmw6k4nvsh58s
basecode main.lua

Show diffs side-by-side

added added

removed removed

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