This commit is contained in:
Benjamín 2021-09-06 16:03:18 +02:00
parent d8ef457c22
commit a0c7caf727
3 changed files with 13 additions and 12 deletions

@ -93,7 +93,7 @@ class Multiscene(Scene):
subscene.progress()
def get_i_objects(self):
i_objects = copy.copy(self.i_objects)
i_objects = [[copy.copy(self.i_objects), self.mouse_pos]]
for subscene in self.subscenes:
i_objects += subscene.get_i_objects()

@ -56,4 +56,4 @@ class Scene(Screen):
pass
def get_i_objects(self):
return self.i_objects
return [[self.i_objects, self.mouse_pos]]

@ -18,16 +18,17 @@ class RopeInteractiveDot:
self.position = mouse_pos
if clicked:
for object_ in self.scene.get_i_objects():
if object_.__class__.__name__ == "Rope":
for node in object_.nodes:
if node.locked is False:
if math.sqrt(sum((node.position - self.position) ** 2)) < self.forcefield_range:
force_vector = node.position - self.position
full_force_vector = (force_vector / math.sqrt(sum(force_vector ** 2))) * self.forcefield_range
force_vector = full_force_vector - force_vector
force_vector /= self.forcefield_range / self.force
for object_batch in self.scene.get_i_objects():
for object_ in object_batch[0]:
if object_.__class__.__name__ == "Rope":
for node in object_.nodes:
if node.locked is False:
if math.sqrt(sum((node.position - self.position) ** 2)) < self.forcefield_range:
force_vector = node.position - self.position
full_force_vector = (force_vector / math.sqrt(sum(force_vector ** 2))) * self.forcefield_range
force_vector = full_force_vector - force_vector
force_vector /= self.forcefield_range / self.force
node.position += force_vector
node.position += force_vector