bzr branch
http://9ix.org/bzr/ld28
5
by Josh C
move clones a little more like players move |
1 |
local dirs = {'left', 'right', 'up', 'down'} |
2 |
||
7
by Josh C
rename NotPlayer to Clone cuz they're clones, and it's way too early |
3 |
Clone = Fill:extend { |
3
by Josh C
add a couple other clones that move randomly |
4 |
fill = {255,0,0}, |
5 |
width = 16, height = 16, |
|
6 |
queue = deque.new(), |
|
5
by Josh C
move clones a little more like players move |
7 |
onNew = function(self) |
8 |
self.direction = dirs[math.random(1,4)] |
|
9 |
end, |
|
3
by Josh C
add a couple other clones that move randomly |
10 |
doMove = function(self) |
5
by Josh C
move clones a little more like players move |
11 |
if math.random(1,4) == 1 then -- change direction ~25% |
12 |
self.direction = dirs[math.random(1,4)] |
|
13 |
end |
|
3
by Josh C
add a couple other clones that move randomly |
14 |
|
5
by Josh C
move clones a little more like players move |
15 |
if self.direction == 'left' then |
3
by Josh C
add a couple other clones that move randomly |
16 |
self.x = self.x - self.width |
5
by Josh C
move clones a little more like players move |
17 |
elseif self.direction == 'right' then |
3
by Josh C
add a couple other clones that move randomly |
18 |
self.x = self.x + self.width |
5
by Josh C
move clones a little more like players move |
19 |
elseif self.direction == 'up' then |
3
by Josh C
add a couple other clones that move randomly |
20 |
self.y = self.y - self.height |
5
by Josh C
move clones a little more like players move |
21 |
elseif self.direction == 'down' then |
3
by Josh C
add a couple other clones that move randomly |
22 |
self.y = self.y + self.height |
23 |
end |
|
9
by Josh C
collision |
24 |
end, |
25 |
onCollide = function(self, other) |
|
10
by Josh C
collide w/ the map |
26 |
if other ~= the.view.map then |
27 |
--print('collision') |
|
28 |
||
29 |
other:displaceDir(self, |
|
30 |
util.dirToXY(self.direction), |
|
31 |
- util.dirToPosNeg(self.direction)) |
|
32 |
end |
|
9
by Josh C
collision |
33 |
end |
3
by Josh C
add a couple other clones that move randomly |
34 |
} |