def circleSplit(self, cursor): buf = [] i = random.randint(0, len(self.circles) - 1) circ = self.circles[i] if circ.mass > INITIAL_MASS: self.circles[i].mass //= 2 self.circles.append(physics.circle(cursor['x'], cursor['y'], circ.mass // 2, circ.id, cursor['x'], cursor['y']))
def __init__(self, name, id, mass = INITIAL_MASS): self.name = name self.id = id self.mass = mass #FIXED THIS x = random.randint(0, FIELD_X) y = random.randint(0, FIELD_Y) self.circles = [physics.circle(x, y, mass, id, 0, 0, 0)] #self.circles = [(random.randint(0, 8000), random.randint(0, 4000), mass)] self.cursor = (x, y, 0) r = lambda: random.randint(0, 150) self.color = ('#%02X%02X%02X' % (r(),r(),r()))
def addCircle(self, mass = INITIAL_MASS): x = random.randint(0, FIELD_X) y = random.randint(0, FIELD_Y) self.mass += mass circ = physics.circle(x, y, mass, self.id, 0, 0, 0) self.circles.append(circ)