/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:
6
6
 
7
7
require 'version'
8
8
require 'player'
9
 
require 'notplayer'
10
9
 
11
10
GameView = View:extend {
12
11
   onNew = function (self)
14
13
              --self.focus = the.player
15
14
              --self:clampTo(self.bg)
16
15
 
17
 
              the.player = Player:new{
18
 
                 x = math.random(the.app.width),
19
 
                 y = math.random(the.app.height),
20
 
              }
 
16
              the.player = Player:new{x = the.app.width / 2,
 
17
                                      y = the.app.height / 2}
21
18
              self:add(the.player)
22
 
 
23
 
              the.notplayers = Group:new()
24
 
              self:add(the.notplayers)
25
 
              for _ = 1, math.random(1,2) do
26
 
                 the.notplayers:add(NotPlayer:new {
27
 
                                       x = math.random(the.app.width),
28
 
                                       y = math.random(the.app.height),
29
 
                                    })
30
 
              end
31
19
           end,
32
20
   onUpdate = function(self, dt)
33
 
                 if the.player.moved then
34
 
                    -- this should encapsulate
35
 
                    for _, np in ipairs(the.notplayers.sprites) do
36
 
                       np:doMove()
37
 
                    end
38
 
 
39
 
                    the.player.moved = false
40
 
                 end
41
 
 
42
21
                 if the.keys:justPressed('escape', 'q') then
43
22
                    the.app:quit()
44
23
                 end
46
25
}
47
26
 
48
27
the.app = App:new {
49
 
   name = "LD28",
 
28
   name = "LD Warmup",
50
29
   onRun = function (self)
51
30
              print('Version: ' .. VERSION)
52
31