/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 03:41:24 UTC
  • Revision ID: josh@9ix.org-20131214034124-vsekv7pyk6z5bvqf
basic delayed movement

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'
8
6
 
9
 
require 'util'
10
7
require 'version'
11
8
require 'player'
12
 
require 'clone'
13
9
 
14
10
GameView = View:extend {
15
11
   onNew = function (self)
16
 
              self:loadLayers('data/map.lua')
 
12
              --self:loadLayers('data/map.lua')
 
13
              --self.focus = the.player
 
14
              --self:clampTo(self.bg)
17
15
 
18
 
              the.player = Player:new{
19
 
                 x = math.random(the.app.width),
20
 
                 y = math.random(the.app.height),
21
 
              }
 
16
              the.player = Player:new{x = the.app.width / 2,
 
17
                                      y = the.app.height / 2}
22
18
              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
32
19
           end,
33
20
   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
 
 
49
21
                 if the.keys:justPressed('escape', 'q') then
50
22
                    the.app:quit()
51
23
                 end
53
25
}
54
26
 
55
27
the.app = App:new {
56
 
   name = "LD28",
 
28
   name = "LD Warmup",
57
29
   onRun = function (self)
58
30
              print('Version: ' .. VERSION)
59
31
 
66
38
                 self.console.fill.fill[4] = 75
67
39
              end
68
40
           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
75
41
}