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