/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 02:57:47 UTC
  • Revision ID: josh@9ix.org-20131214025747-etw31g9vii33qvey
zoetrope 1.4

Show diffs side-by-side

added added

removed removed

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