1
local dirs = {'left', 'right', 'up', 'down'}
5
width = 16, height = 16,
8
self.direction = dirs[math.random(1,4)]
10
doMove = function(self)
11
if math.random(1,4) == 1 then -- change direction ~25%
12
self.direction = dirs[math.random(1,4)]
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
25
onCollide = function(self, other)
26
if other ~= the.view.map then
29
other:displaceDir(self,
30
util.dirToXY(self.direction),
31
- util.dirToPosNeg(self.direction))
b'\\ No newline at end of file'