/ld28

To get this branch, use:
bzr branch http://9ix.org/bzr/ld28

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-12-14 20:49:46 UTC
  • Revision ID: josh@9ix.org-20131214204946-x376m4m055wrwfrz
collide w/ the map

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
require 'zoetrope'
5
5
deque = require 'deque'
 
6
--inspect = require 'inspect'
 
7
require 'sprite'
6
8
 
 
9
require 'util'
7
10
require 'version'
8
11
require 'player'
 
12
require 'clone'
9
13
 
10
14
GameView = View:extend {
11
15
   onNew = function (self)
12
 
              --self:loadLayers('data/map.lua')
13
 
              --self.focus = the.player
14
 
              --self:clampTo(self.bg)
 
16
              self:loadLayers('data/map.lua')
15
17
 
16
 
              the.player = Player:new{x = the.app.width / 2,
17
 
                                      y = the.app.height / 2}
 
18
              the.player = Player:new{
 
19
                 x = math.random(the.app.width),
 
20
                 y = math.random(the.app.height),
 
21
              }
18
22
              self:add(the.player)
 
23
 
 
24
              the.clones = Group:new()
 
25
              self:add(the.clones)
 
26
              for _ = 1, 14 do
 
27
                 the.clones:add(Clone:new {
 
28
                                       x = math.random(16, the.app.width-32),
 
29
                                       y = math.random(16, the.app.height-32),
 
30
                                    })
 
31
              end
19
32
           end,
20
33
   onUpdate = function(self, dt)
 
34
                 if the.player.moved then
 
35
                    -- this should encapsulate
 
36
                    for _, np in ipairs(the.clones.sprites) do
 
37
                       np:doMove()
 
38
                    end
 
39
 
 
40
                    the.clones:collide(self.map)
 
41
                    the.player:collide(self.map)
 
42
 
 
43
                    the.clones:collide()
 
44
                    the.clones:collide(the.player)
 
45
 
 
46
                    the.player.moved = false
 
47
                 end
 
48
 
21
49
                 if the.keys:justPressed('escape', 'q') then
22
50
                    the.app:quit()
23
51
                 end
25
53
}
26
54
 
27
55
the.app = App:new {
28
 
   name = "LD Warmup",
 
56
   name = "LD28",
29
57
   onRun = function (self)
30
58
              print('Version: ' .. VERSION)
31
59
 
38
66
                 self.console.fill.fill[4] = 75
39
67
              end
40
68
           end,
 
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
41
75
}