1
GoalPerson = Tile:extend {
2
image = 'data/goal.png',
4
self.direction = dirs[math.random(1,4)]
6
doMove = function(self)
7
if math.random(1,4) ~= 1 then -- take a step ~2/3
8
if math.random(1,4) == 1 then -- change direction ~25%
9
self.direction = dirs[math.random(1,4)]
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
23
onCollide = function(self, other)
24
if other ~= the.view.map then
27
other:displaceDir(self,
28
util.dirToXY(self.direction),
29
- util.dirToPosNeg(self.direction))
32
if other == the.player then
33
if the.view.level == 1 or the.view.level ==2 then
34
the.player.active = false
35
the.view:fade({0,0,0}):andThen(function()
36
the.app.view = SlowView:new {
37
level = the.view.level + 1
40
elseif the.view.level == 3 then
41
the.app.view = WinView:new()
43
error('where did you find another level?')
b'\\ No newline at end of file'