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