/ld28

To get this branch, use:
bzr branch http://9ix.org/bzr/ld28
2 by Josh C
basic delayed movement
1
STRICT = true
2
DEBUG = true
3
4
require 'zoetrope'
5
deque = require 'deque'
10 by Josh C
collide w/ the map
6
--inspect = require 'inspect'
7
require 'sprite'
2 by Josh C
basic delayed movement
8
10 by Josh C
collide w/ the map
9
require 'util'
2 by Josh C
basic delayed movement
10
require 'version'
11
require 'player'
7 by Josh C
rename NotPlayer to Clone cuz they're clones, and it's way too early
12
require 'clone'
2 by Josh C
basic delayed movement
13
14
GameView = View:extend {
15
   onNew = function (self)
10 by Josh C
collide w/ the map
16
              self:loadLayers('data/map.lua')
2 by Josh C
basic delayed movement
17
3 by Josh C
add a couple other clones that move randomly
18
              the.player = Player:new{
19
                 x = math.random(the.app.width),
20
                 y = math.random(the.app.height),
21
              }
2 by Josh C
basic delayed movement
22
              self:add(the.player)
3 by Josh C
add a couple other clones that move randomly
23
7 by Josh C
rename NotPlayer to Clone cuz they're clones, and it's way too early
24
              the.clones = Group:new()
25
              self:add(the.clones)
4 by Josh C
more clones, no null movement
26
              for _ = 1, 14 do
7 by Josh C
rename NotPlayer to Clone cuz they're clones, and it's way too early
27
                 the.clones:add(Clone:new {
10 by Josh C
collide w/ the map
28
                                       x = math.random(16, the.app.width-32),
29
                                       y = math.random(16, the.app.height-32),
3 by Josh C
add a couple other clones that move randomly
30
                                    })
31
              end
2 by Josh C
basic delayed movement
32
           end,
33
   onUpdate = function(self, dt)
3 by Josh C
add a couple other clones that move randomly
34
                 if the.player.moved then
35
                    -- this should encapsulate
7 by Josh C
rename NotPlayer to Clone cuz they're clones, and it's way too early
36
                    for _, np in ipairs(the.clones.sprites) do
3 by Josh C
add a couple other clones that move randomly
37
                       np:doMove()
38
                    end
39
10 by Josh C
collide w/ the map
40
                    the.clones:collide(self.map)
41
                    the.player:collide(self.map)
42
9 by Josh C
collision
43
                    the.clones:collide()
44
                    the.clones:collide(the.player)
45
3 by Josh C
add a couple other clones that move randomly
46
                    the.player.moved = false
47
                 end
48
2 by Josh C
basic delayed movement
49
                 if the.keys:justPressed('escape', 'q') then
50
                    the.app:quit()
51
                 end
52
              end,
53
}
54
55
the.app = App:new {
3 by Josh C
add a couple other clones that move randomly
56
   name = "LD28",
2 by Josh C
basic delayed movement
57
   onRun = function (self)
58
              print('Version: ' .. VERSION)
59
60
              self.view = GameView:new()
61
62
              if DEBUG then
63
                 self.console:watch('VERSION', 'VERSION')
64
65
                 -- back off that dark overlay a bit
66
                 self.console.fill.fill[4] = 75
67
              end
68
           end,
8 by Josh C
screenshots
69
   onUpdate = function (self, dt)
70
                 if the.keys:justPressed('f1') then
71
                    local ss = love.graphics.newScreenshot()
72
                    ss:encode('screenshot-' ..love.timer.getTime()..'.png')
73
                 end
74
              end
2 by Josh C
basic delayed movement
75
}