Browse Source

improved shape generation, added random to bounceoff

master
Fr3deric 7 years ago
parent
commit
2073a3e277
  1. 8
      generators/unrath.py

8
generators/unrath.py

@ -36,7 +36,11 @@ class Unrath:
shapesize = random.randint(2, 5) shapesize = random.randint(2, 5)
while len(self.shape) < shapesize: while len(self.shape) < shapesize:
p = random.sample(self.shape, 1)[0] 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)) self.shapewidth = max(map(lambda p: p[0], self.shape))
shapeheight = max(map(lambda p: p[1], self.shape)) shapeheight = max(map(lambda p: p[1], self.shape))
@ -69,7 +73,7 @@ class Unrath:
else: else:
slow = unrath slow = unrath
fast = self fast = self
slow.speed = fast.speed * 1.1 slow.speed = fast.speed * (1.1 + random.random()/10)
slow.update(dt, True) slow.update(dt, True)
if not collision: if not collision:
self.pos = newpos self.pos = newpos

Loading…
Cancel
Save