/ld28

To get this branch, use:
bzr branch http://9ix.org/bzr/ld28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
local dirs = {'left', 'right', 'up', 'down'}

NotPlayer = Fill:extend {
   fill = {255,0,0},
   width = 16, height = 16,
   queue = deque.new(),
   onNew = function(self)
              self.direction = dirs[math.random(1,4)]
           end,
   doMove = function(self)
               if math.random(1,4) == 1 then -- change direction ~25%
                  self.direction = dirs[math.random(1,4)]
               end

               if self.direction == 'left' then
                  self.x = self.x - self.width
               elseif self.direction == 'right' then
                  self.x = self.x + self.width
               elseif self.direction == 'up' then
                  self.y = self.y - self.height
               elseif self.direction == 'down' then
                  self.y = self.y + self.height
               end
            end
}