Cleaned up drunken walk, closes #11
This commit is contained in:
@@ -17,12 +17,14 @@ function DrunkenWalk:initialize(w, h)
|
||||
end
|
||||
|
||||
function DrunkenWalk:update()
|
||||
self.curr_x = self.curr_x + math.random(-1, 1)
|
||||
self.curr_y = self.curr_y + math.random(-1, 1)
|
||||
while self.curr_x >= self.map_w or self.curr_x < 0 or self.curr_y >= self.map_h or self.curr_y < 0 do
|
||||
self.curr_x = self.curr_x + math.random(-1, 1)
|
||||
self.curr_y = self.curr_y + math.random(-1, 1)
|
||||
new_x = self.curr_x + math.random(-1, 1)
|
||||
new_y = self.curr_y + math.random(-1, 1)
|
||||
while new_x >= self.map_w or new_x < 0 or new_y >= self.map_h or new_y < 0 do
|
||||
new_x = self.curr_x + math.random(-1, 1)
|
||||
new_y = self.curr_y + math.random(-1, 1)
|
||||
end
|
||||
self.curr_x = new_x
|
||||
self.curr_y = new_y
|
||||
visualizer.map:draw_floor(self.curr_x, self.curr_y)
|
||||
self.iterations = self.iterations - 1
|
||||
if self.iterations == 0 then
|
||||
|
||||
Reference in New Issue
Block a user