/ld28

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

« back to all changes in this revision

Viewing changes to notplayer.lua

  • Committer: Josh C
  • Date: 2013-12-14 05:03:13 UTC
  • Revision ID: josh@9ix.org-20131214050313-iy9l7xzj25f2gpej
more clones, no null movement

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
local dirs = {'left', 'right', 'up', 'down'}
2
 
 
3
 
Clone = Fill:extend {
 
1
NotPlayer = Fill:extend {
4
2
   fill = {255,0,0},
5
3
   width = 16, height = 16,
6
4
   queue = deque.new(),
7
 
   onNew = function(self)
8
 
              self.direction = dirs[math.random(1,4)]
9
 
           end,
10
5
   doMove = function(self)
11
 
               if math.random(1,4) == 1 then -- change direction ~25%
12
 
                  self.direction = dirs[math.random(1,4)]
13
 
               end
 
6
               local dir = math.random(1,4)
14
7
 
15
 
               if self.direction == 'left' then
 
8
               if dir == 1 then
16
9
                  self.x = self.x - self.width
17
 
               elseif self.direction == 'right' then
 
10
               elseif dir == 2 then
18
11
                  self.x = self.x + self.width
19
 
               elseif self.direction == 'up' then
 
12
               elseif dir == 3 then
20
13
                  self.y = self.y - self.height
21
 
               elseif self.direction == 'down' then
 
14
               elseif dir == 4 then
22
15
                  self.y = self.y + self.height
23
16
               end
24
 
            end,
25
 
   onCollide = function(self, other)
26
 
                  other:displace(self)
27
 
               end
 
17
            end
28
18
}
 
 
b'\\ No newline at end of file'