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