/ld28

To get this branch, use:
bzr branch http://9ix.org/bzr/ld28

« back to all changes in this revision

Viewing changes to player.lua

  • Committer: Josh C
  • Date: 2013-12-14 05:24:01 UTC
  • Revision ID: josh@9ix.org-20131214052401-8b2cma95lsvw7avq
rename NotPlayer to Clone cuz they're clones, and it's way too early 
for a class name like NotPlayer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Player = Tile:extend {
2
 
   image = 'data/player.png',
 
1
local dirs = {'left', 'right', 'up', 'down'}
 
2
 
 
3
Player = Fill:extend {
 
4
   fill = {255,0,0},
 
5
   width = 16, height = 16,
3
6
   queue = deque.new(),
4
7
   onNew = function(self)
5
 
              local delay = {0,1,2}
6
 
              for _ = 1, delay[the.view.level] do
 
8
              for _ = 1, 2 do
7
9
                 self.queue:push_right(dirs[math.random(1,4)])
8
10
              end
9
11
           end,
21
23
                       --print('key: ' .. keys[1])
22
24
                       self.queue:push_right(keys[1])
23
25
 
24
 
                       self.direction = self.queue:pop_left()
25
 
                       if self.direction == 'left' then
 
26
                       local inst = self.queue:pop_left()
 
27
                       if inst == 'left' then
26
28
                          self.x = self.x - self.width
27
 
                       elseif self.direction == 'right' then
 
29
                       elseif inst == 'right' then
28
30
                          self.x = self.x + self.width
29
 
                       elseif self.direction == 'up' then
 
31
                       elseif inst == 'up' then
30
32
                          self.y = self.y - self.height
31
 
                       elseif self.direction == 'down' then
 
33
                       elseif inst == 'down' then
32
34
                          self.y = self.y + self.height
33
35
                       end
34
36
 
35
37
                       self.moved = true
36
38
                    end
37
39
                 end
38
 
              end,
39
 
   onCollide = function(self, other)
40
 
                  if other ~= the.view.map and other ~= the.goalPerson then
41
 
                     --print('collision')
42
 
 
43
 
                     other:displaceDir(self,
44
 
                                       util.dirToXY(self.direction),
45
 
                                       - util.dirToPosNeg(self.direction))
46
 
                  end
47
 
               end
 
40
              end
48
41
}
 
 
b'\\ No newline at end of file'