/ld28

To get this branch, use:
bzr branch http://9ix.org/bzr/ld28
18 by Josh C
clones turning into fake goals
1
Player = Tile:extend {
2
   image = 'data/player.png',
2 by Josh C
basic delayed movement
3
   queue = deque.new(),
4
   onNew = function(self)
16 by Josh C
moving goal, clones turning green...
5
              for _ = 1, math.random(1,3) do
4 by Josh C
more clones, no null movement
6
                 self.queue:push_right(dirs[math.random(1,4)])
2 by Josh C
basic delayed movement
7
              end
8
           end,
3 by Josh C
add a couple other clones that move randomly
9
   onUpdate = function(self)
10
                 local keys = {the.keys:allJustPressed()}
11
                 if keys[1] then
4 by Josh C
more clones, no null movement
12
                    local dirKey = false
13
                    for _, dir in ipairs(dirs) do
14
                       if dir == keys[1] then
15
                          dirKey = true
16
                       end
17
                    end
18
19
                    if dirKey then
20
                       --print('key: ' .. keys[1])
21
                       self.queue:push_right(keys[1])
22
12 by Josh C
player collide w/ map
23
                       self.direction = self.queue:pop_left()
24
                       if self.direction == 'left' then
4 by Josh C
more clones, no null movement
25
                          self.x = self.x - self.width
12 by Josh C
player collide w/ map
26
                       elseif self.direction == 'right' then
4 by Josh C
more clones, no null movement
27
                          self.x = self.x + self.width
12 by Josh C
player collide w/ map
28
                       elseif self.direction == 'up' then
4 by Josh C
more clones, no null movement
29
                          self.y = self.y - self.height
12 by Josh C
player collide w/ map
30
                       elseif self.direction == 'down' then
4 by Josh C
more clones, no null movement
31
                          self.y = self.y + self.height
32
                       end
33
34
                       self.moved = true
35
                    end
3 by Josh C
add a couple other clones that move randomly
36
                 end
12 by Josh C
player collide w/ map
37
              end,
38
   onCollide = function(self, other)
18 by Josh C
clones turning into fake goals
39
                  if other ~= the.view.map and other ~= the.goalPerson then
12 by Josh C
player collide w/ map
40
                     --print('collision')
41
42
                     other:displaceDir(self,
43
                                       util.dirToXY(self.direction),
44
                                       - util.dirToPosNeg(self.direction))
45
                  end
46
               end
2 by Josh C
basic delayed movement
47
}