2
image = 'data/player.png',
3
width = 16, height = 16,
4
5
onNew = function(self)
6
for _ = 1, delay[the.view.level] do
7
self.queue:push_right(dirs[math.random(1,4)])
7
local dirs = {'left', 'right', 'up', 'down', ''}
8
self.queue:push_right(dirs[math.random(1,5)])
10
11
onUpdate = function(self)
11
12
local keys = {the.keys:allJustPressed()}
14
for _, dir in ipairs(dirs) do
15
if dir == keys[1] then
21
--print('key: ' .. keys[1])
22
self.queue:push_right(keys[1])
24
self.direction = self.queue:pop_left()
25
if self.direction == 'left' then
26
self.x = self.x - self.width
27
elseif self.direction == 'right' then
28
self.x = self.x + self.width
29
elseif self.direction == 'up' then
30
self.y = self.y - self.height
31
elseif self.direction == 'down' then
32
self.y = self.y + self.height
14
self.queue:push_right(keys[1])
16
local inst = self.queue:pop_left()
17
if inst == 'left' then
18
self.x = self.x - self.width
19
elseif inst == 'right' then
20
self.x = self.x + self.width
21
elseif inst == 'up' then
22
self.y = self.y - self.height
23
elseif inst == 'down' then
24
self.y = self.y + self.height
39
onCollide = function(self, other)
40
if other ~= the.view.map and other ~= the.goalPerson then
43
other:displaceDir(self,
44
util.dirToXY(self.direction),
45
- util.dirToPosNeg(self.direction))
b'\\ No newline at end of file'