2
image = 'data/player.png',
4
self.direction = dirs[math.random(1,4)]
1
NotPlayer = Fill:extend {
3
width = 16, height = 16,
6
5
doMove = function(self)
7
if math.random(1,4) == 1 then -- change direction ~25%
8
self.direction = dirs[math.random(1,4)]
6
local dir = math.random(1,4)
11
if self.direction == 'left' then
12
9
self.x = self.x - self.width
13
elseif self.direction == 'right' then
14
11
self.x = self.x + self.width
15
elseif self.direction == 'up' then
16
13
self.y = self.y - self.height
17
elseif self.direction == 'down' then
18
15
self.y = self.y + self.height
21
onCollide = function(self, other)
22
if other ~= the.view.map then
25
other:displaceDir(self,
26
util.dirToXY(self.direction),
27
- util.dirToPosNeg(self.direction))
30
if other == the.player then
31
self.image = 'data/player.png'
b'\\ No newline at end of file'