/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:59:18 UTC
  • Revision ID: josh@9ix.org-20131214205918-w846mewpjguh3soj
align to grid

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
require 'version'
11
11
require 'player'
12
12
require 'clone'
13
 
require 'goal'
14
 
require 'goal_person'
15
 
 
16
 
dirs = {'left', 'right', 'up', 'down'}
17
13
 
18
14
GameView = View:extend {
19
15
   onNew = function (self)
28
24
              }
29
25
              self:add(the.player)
30
26
 
31
 
              the.goalPerson = GoalPerson:new{
32
 
                 x = math.random(2, tw-2) * 16,
33
 
                 y = math.random(2, th-2) * 16
34
 
              }
35
 
              self:add(the.goalPerson)
36
 
 
37
27
              the.clones = Group:new()
38
28
              self:add(the.clones)
39
 
              for _ = 1, 15 do
 
29
              for _ = 1, 14 do
40
30
                 the.clones:add(Clone:new {
41
31
                                   x = math.random(2, tw-2) * 16,
42
32
                                   y = math.random(2, th-2) * 16
46
36
   onUpdate = function(self, dt)
47
37
                 if the.player.moved then
48
38
                    -- this should encapsulate
49
 
 
50
 
                    the.clones:collide(the.player)
51
 
                    the.goalPerson:collide(the.player)
52
 
 
53
 
                    if self.level ~= 2 then
54
 
                       the.goalPerson:doMove()
55
 
                    end
56
 
 
57
39
                    for _, np in ipairs(the.clones.sprites) do
58
40
                       np:doMove()
59
41
                    end
60
42
 
61
 
                    -- yeah, again.  once for flip, twice for displace
62
 
                    the.clones:collide(the.player)
63
 
 
64
43
                    the.clones:collide(self.map)
65
44
                    the.player:collide(self.map)
66
 
                    the.goalPerson:collide(self.map)
67
45
 
68
46
                    the.clones:collide()
69
 
 
70
 
                    if math.random(1,6) == 1 then
71
 
                       local c = the.clones.sprites[math.random(the.clones:count())]
72
 
                       if self.level == 3 and not c.cured then
73
 
                          c.image = 'data/goal.png'
74
 
                       end
75
 
                    end
 
47
                    the.clones:collide(the.player)
76
48
 
77
49
                    the.player.moved = false
78
50
                 end
85
57
 
86
58
the.app = App:new {
87
59
   name = "LD28",
88
 
   fps = 30,
89
60
   onRun = function (self)
90
61
              print('Version: ' .. VERSION)
91
62
 
92
 
              self.view = GameView:new{level = 1}
 
63
              self.view = GameView:new()
93
64
 
94
65
              if DEBUG then
95
66
                 self.console:watch('VERSION', 'VERSION')
96
 
                 self.console:watch('level', 'the.view.level')
97
67
 
98
68
                 -- back off that dark overlay a bit
99
69
                 self.console.fill.fill[4] = 75