/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 17:35:23 UTC
  • Revision ID: josh@9ix.org-20131214173523-8g4gd5hlk4fix1r6
collision

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
require 'version'
8
8
require 'player'
 
9
require 'clone'
9
10
 
10
11
GameView = View:extend {
11
12
   onNew = function (self)
13
14
              --self.focus = the.player
14
15
              --self:clampTo(self.bg)
15
16
 
16
 
              the.player = Player:new{x = the.app.width / 2,
17
 
                                      y = the.app.height / 2}
 
17
              the.player = Player:new{
 
18
                 x = math.random(the.app.width),
 
19
                 y = math.random(the.app.height),
 
20
              }
18
21
              self:add(the.player)
 
22
 
 
23
              the.clones = Group:new()
 
24
              self:add(the.clones)
 
25
              for _ = 1, 14 do
 
26
                 the.clones:add(Clone:new {
 
27
                                       x = math.random(the.app.width),
 
28
                                       y = math.random(the.app.height),
 
29
                                    })
 
30
              end
19
31
           end,
20
32
   onUpdate = function(self, dt)
 
33
                 if the.player.moved then
 
34
                    -- this should encapsulate
 
35
                    for _, np in ipairs(the.clones.sprites) do
 
36
                       np:doMove()
 
37
                    end
 
38
 
 
39
                    the.clones:collide()
 
40
                    the.clones:collide(the.player)
 
41
 
 
42
                    the.player.moved = false
 
43
                 end
 
44
 
21
45
                 if the.keys:justPressed('escape', 'q') then
22
46
                    the.app:quit()
23
47
                 end
25
49
}
26
50
 
27
51
the.app = App:new {
28
 
   name = "LD Warmup",
 
52
   name = "LD28",
29
53
   onRun = function (self)
30
54
              print('Version: ' .. VERSION)
31
55
 
38
62
                 self.console.fill.fill[4] = 75
39
63
              end
40
64
           end,
 
65
   onUpdate = function (self, dt)
 
66
                 if the.keys:justPressed('f1') then
 
67
                    local ss = love.graphics.newScreenshot()
 
68
                    ss:encode('screenshot-' ..love.timer.getTime()..'.png')
 
69
                 end
 
70
              end
41
71
}