1
local dirs = {'left', 'right', 'up', 'down'}
5
width = 16, height = 16,
9
self.queue:push_right(dirs[math.random(1,4)])
12
onUpdate = function(self)
13
local keys = {the.keys:allJustPressed()}
16
for _, dir in ipairs(dirs) do
17
if dir == keys[1] then
23
--print('key: ' .. keys[1])
24
self.queue:push_right(keys[1])
26
self.direction = self.queue:pop_left()
27
if self.direction == 'left' then
28
self.x = self.x - self.width
29
elseif self.direction == 'right' then
30
self.x = self.x + self.width
31
elseif self.direction == 'up' then
32
self.y = self.y - self.height
33
elseif self.direction == 'down' then
34
self.y = self.y + self.height
41
onCollide = function(self, other)
42
if other ~= the.view.map then
45
other:displaceDir(self,
46
util.dirToXY(self.direction),
47
- util.dirToPosNeg(self.direction))
b'\\ No newline at end of file'