From 2073a3e277364fc1ee5c7f9e4c90c783fc9f2809 Mon Sep 17 00:00:00 2001 From: Frederic Date: Sat, 9 Dec 2017 09:40:39 +0100 Subject: [PATCH] improved shape generation, added random to bounceoff --- generators/unrath.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generators/unrath.py b/generators/unrath.py index c8f96e1..156edb0 100755 --- a/generators/unrath.py +++ b/generators/unrath.py @@ -36,7 +36,11 @@ class Unrath: shapesize = random.randint(2, 5) while len(self.shape) < shapesize: p = random.sample(self.shape, 1)[0] - self.shape.add((p[0]+random.randint(0, 1), p[1]+random.randint(0, 1))) + self.shape.add((p[0]+random.randint(-1, 1), + p[1]+random.randint(-1, 1))) + minx = min(map(lambda p: p[0], self.shape)) + miny = min(map(lambda p: p[1], self.shape)) + self.shape = {(p[0]+abs(minx), p[1]+abs(miny)) for p in self.shape} self.shapewidth = max(map(lambda p: p[0], self.shape)) shapeheight = max(map(lambda p: p[1], self.shape)) @@ -69,7 +73,7 @@ class Unrath: else: slow = unrath fast = self - slow.speed = fast.speed * 1.1 + slow.speed = fast.speed * (1.1 + random.random()/10) slow.update(dt, True) if not collision: self.pos = newpos