/ld28

To get this branch, use:
bzr branch http://9ix.org/bzr/ld28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
STRICT = true
DEBUG = true

require 'zoetrope'
deque = require 'deque'

require 'version'
require 'player'
require 'clone'

GameView = View:extend {
   onNew = function (self)
              --self:loadLayers('data/map.lua')
              --self.focus = the.player
              --self:clampTo(self.bg)

              the.player = Player:new{
                 x = math.random(the.app.width),
                 y = math.random(the.app.height),
              }
              self:add(the.player)

              the.clones = Group:new()
              self:add(the.clones)
              for _ = 1, 14 do
                 the.clones:add(Clone:new {
                                       x = math.random(the.app.width),
                                       y = math.random(the.app.height),
                                    })
              end
           end,
   onUpdate = function(self, dt)
                 if the.player.moved then
                    -- this should encapsulate
                    for _, np in ipairs(the.clones.sprites) do
                       np:doMove()
                    end

                    the.clones:collide()
                    the.clones:collide(the.player)

                    the.player.moved = false
                 end

                 if the.keys:justPressed('escape', 'q') then
                    the.app:quit()
                 end
              end,
}

the.app = App:new {
   name = "LD28",
   onRun = function (self)
              print('Version: ' .. VERSION)

              self.view = GameView:new()

              if DEBUG then
                 self.console:watch('VERSION', 'VERSION')

                 -- back off that dark overlay a bit
                 self.console.fill.fill[4] = 75
              end
           end,
   onUpdate = function (self, dt)
                 if the.keys:justPressed('f1') then
                    local ss = love.graphics.newScreenshot()
                    ss:encode('screenshot-' ..love.timer.getTime()..'.png')
                 end
              end
}