def add_body(self, body='planet', pos=(0, 0), texture_index=None, vel=(0, 0), density=1, mass=100, fixed=False, light=0, temperature=0, **kwargs): # create new widget newplanet = Planet() # texture of new body, defaults to planet texture_list = self.texture_mapping[body] texture_index = texture_index or randint(0, len(texture_list) - 1) newplanet_texture = texture_list[texture_index] newplanet.set_base_image(newplanet_texture) # inform the engine newindex = self.tape.engine.create_planet( pos_x=pos[0], pos_y=pos[1], vel_x=vel[0], vel_y=vel[1], mass=mass, density=density ) # if engine says no, do nothing if newindex == -1: return radius = self.tape.engine.get_planet_radius(newindex) planet_d = { 'position_x': pos[0], 'position_y': pos[1], 'velocity_x': vel[0], 'velocity_y': vel[1], 'density': density, 'mass': mass, 'radius': radius, 'fixed': fixed, 'widget': newplanet, 'texture_index': texture_index, 'body': body } # fix body in keeper if neccessary if fixed: self.tape.engine.fix_planet(newindex) # write dict into planets-dict self.planets[newindex] = planet_d # modify planet widget newplanet.size = (radius * 2, radius * 2) newplanet.center = pos self.gamezone.add_widget(newplanet) self.future_changed = True