/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: 2013-08-24 03:11:38 UTC
  • Revision ID: josh@9ix.org-20130824031138-j4ta4ome0upsxcv5
zoetrope 1.4

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 'group'
7
 
 
8
 
require 'version'
9
 
--require 'wrap_tile'
10
 
require 'player'
11
 
 
12
 
GameView = View:extend {
13
 
   gameStart = 0,
14
 
   onNew = function (self)
15
 
              self:loadLayers('data/map.lua')
16
 
              self.focus = the.player
17
 
              self:clampTo(self.bg)
18
 
 
19
 
              self.mazes = {self.maze1, self.maze2}
20
 
              self.maze1:revive()
21
 
              self.maze2:die()
22
 
              the.activeMaze = self.maze1
23
 
 
24
 
              --the.interface = Group:new()
25
 
 
26
 
              --self:add(the.interface)
27
 
 
28
 
              self.gameStart = love.timer.getMicroTime()
29
 
              self.lastChange = love.timer.getMicroTime()
30
 
           end,
31
 
   onUpdate = function(self, dt)
32
 
                 if the.player.active and love.timer.getMicroTime() > self.lastChange + 10 then
33
 
                    -- switch maze
34
 
                    the.activeMaze:die()
35
 
                    if the.activeMaze == self.maze1 then
36
 
                       the.activeMaze = self.maze2
37
 
                    else
38
 
                       the.activeMaze = self.maze1
39
 
                    end
40
 
                    the.activeMaze:revive()
41
 
 
42
 
                    self.lastChange = love.timer.getMicroTime()
43
 
                 end
44
 
 
45
 
                 the.activeMaze:collide(the.player)
46
 
 
47
 
 
48
 
                 -- for _, mirror in ipairs(the.mirrors.sprites) do
49
 
                 --    if not mirror.of then
50
 
                 --       print('mirror:' .. inspect(mirror))
51
 
                 --       error('mirror OF NOTHING')
52
 
                 --    end
53
 
                 -- end
54
 
              end,
55
 
   onEndFrame = function(self)
56
 
                   --the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2
57
 
                   --the.interface.translate.y = the.player.y - the.app.height / 2 + the.player.height / 2
58
 
                end
59
 
}
60
 
 
61
 
MenuScreen = View:extend {
62
 
   title = Text:new{text = "Press a key to start", font = 48, wordWrap = false},
63
 
   --title = Tile:new{image = 'data/title.png', x = 0, y = 0},
64
 
   onNew = function(self)
65
 
              self:add(self.title)
66
 
              self.title:centerAround(400, 200)
67
 
           end,
68
 
   onUpdate = function(self, elapsed)
69
 
                 if the.keys:allJustPressed() then
70
 
                    the.app.view = GameView:new()
71
 
                 end
72
 
              end
73
 
}
74
 
 
75
 
the.app = App:new {
76
 
   onRun = function (self)
77
 
              print('Version: ' .. VERSION)
78
 
 
79
 
              self.view = GameView:new()
80
 
 
81
 
              if DEBUG then
82
 
                 self.console:watch('VERSION', 'VERSION')
83
 
 
84
 
                 -- back off that dark overlay a bit
85
 
                 self.console.fill.fill[4] = 75
86
 
              end
87
 
           end,
88
 
   onUpdate = function (self, dt)
89
 
                 if the.keys:justPressed('escape') then
90
 
                    self.quit()
91
 
                 end
92
 
              end
93
 
}