/ld28

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

« back to all changes in this revision

Viewing changes to clone.lua

  • Committer: Josh C
  • Date: 2013-12-15 02:53:43 UTC
  • Revision ID: josh@9ix.org-20131215025343-wjhcv7nbmqffg4ga
oops, mobile goal file

Show diffs side-by-side

added added

removed removed

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