/ld27

To get this branch, use:
bzr branch http://9ix.org/bzr/ld27
3 by Josh C
map loading, super basic movement
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'
8 by Josh C
goal... thing
11
require 'goal'
3 by Josh C
map loading, super basic movement
12
13
GameView = View:extend {
14
   gameStart = 0,
15
   onNew = function (self)
16
              self:loadLayers('data/map.lua')
17
              self.focus = the.player
4 by Josh C
switch mazes
18
              self:clampTo(self.bg)
19
20
              self.mazes = {self.maze1, self.maze2}
5 by Josh C
fade in to let you know change is coming
21
              --self.maze1:revive()
22
              --self.maze2:die()
4 by Josh C
switch mazes
23
              the.activeMaze = self.maze1
3 by Josh C
map loading, super basic movement
24
25
              --the.interface = Group:new()
26
27
              --self:add(the.interface)
28
5 by Josh C
fade in to let you know change is coming
29
              self:switchMaze()
30
4 by Josh C
switch mazes
31
              self.gameStart = love.timer.getMicroTime()
32
              self.lastChange = love.timer.getMicroTime()
3 by Josh C
map loading, super basic movement
33
           end,
34
   onUpdate = function(self, dt)
4 by Josh C
switch mazes
35
                 if the.player.active and love.timer.getMicroTime() > self.lastChange + 10 then
3 by Josh C
map loading, super basic movement
36
                    -- switch maze
5 by Josh C
fade in to let you know change is coming
37
                    self:switchMaze()
3 by Josh C
map loading, super basic movement
38
                 end
39
4 by Josh C
switch mazes
40
                 the.activeMaze:collide(the.player)
41
42
3 by Josh C
map loading, super basic movement
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,
5 by Josh C
fade in to let you know change is coming
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
6 by Josh C
how about fade to black instead?
59
                   self._fx = {0,0,0,0}
5 by Josh C
fade in to let you know change is coming
60
                   self.tween:start(self._fx, 4, 150, 10, 'quadIn')
61
62
                   self.lastChange = love.timer.getMicroTime()
63
                end,
3 by Josh C
map loading, super basic movement
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
}