mirror of
https://github.com/csd4ni3l/simulator-games.git
synced 2026-01-01 04:13:44 +01:00
Fix boids not being spawned with settings values
This commit is contained in:
@@ -18,7 +18,7 @@ class Boid(arcade.Sprite):
|
|||||||
self.small_radius = 100
|
self.small_radius = 100
|
||||||
self.large_radius = 250
|
self.large_radius = 250
|
||||||
|
|
||||||
def calculate_separation(self, neighbours: list[int, arcade.math.Vec2, arcade.math.Vec2]):
|
def calculate_separation(self, neighbours):
|
||||||
steeraway_vectors = [arcade.math.Vec2(*self.position) - neighbour[2] for neighbour in neighbours]
|
steeraway_vectors = [arcade.math.Vec2(*self.position) - neighbour[2] for neighbour in neighbours]
|
||||||
|
|
||||||
if not steeraway_vectors:
|
if not steeraway_vectors:
|
||||||
@@ -26,7 +26,7 @@ class Boid(arcade.Sprite):
|
|||||||
|
|
||||||
return (sum(steeraway_vectors) / len(steeraway_vectors)).normalize()
|
return (sum(steeraway_vectors) / len(steeraway_vectors)).normalize()
|
||||||
|
|
||||||
def calculate_alignment(self, neighbours: list[int, arcade.math.Vec2, arcade.math.Vec2]):
|
def calculate_alignment(self, neighbours):
|
||||||
directions = [neighbour[1] for neighbour in neighbours]
|
directions = [neighbour[1] for neighbour in neighbours]
|
||||||
|
|
||||||
if not directions:
|
if not directions:
|
||||||
@@ -34,7 +34,7 @@ class Boid(arcade.Sprite):
|
|||||||
|
|
||||||
return (sum(directions) / len(directions)).normalize()
|
return (sum(directions) / len(directions)).normalize()
|
||||||
|
|
||||||
def calculate_cohesion(self, neighbours: list[int, arcade.math.Vec2, arcade.math.Vec2]):
|
def calculate_cohesion(self, neighbours):
|
||||||
positions = [neighbour[2] for neighbour in neighbours]
|
positions = [neighbour[2] for neighbour in neighbours]
|
||||||
|
|
||||||
if not positions:
|
if not positions:
|
||||||
|
|||||||
@@ -57,6 +57,13 @@ class Game(arcade.gui.UIView):
|
|||||||
|
|
||||||
def create_boid(self, x, y):
|
def create_boid(self, x, y):
|
||||||
boid = Boid(self.current_boid_num, x, y)
|
boid = Boid(self.current_boid_num, x, y)
|
||||||
|
|
||||||
|
boid.w_alignment = self.settings["boid_simulator"]["w_alignment"]
|
||||||
|
boid.w_separation = self.settings["boid_simulator"]["w_separation"]
|
||||||
|
boid.w_cohesion = self.settings["boid_simulator"]["w_cohesion"]
|
||||||
|
boid.large_radius = self.settings["boid_simulator"]["large_radius"]
|
||||||
|
boid.small_radius = self.settings["boid_simulator"]["small_radius"]
|
||||||
|
|
||||||
self.boid_sprites.append(boid)
|
self.boid_sprites.append(boid)
|
||||||
self.current_boid_num += 1
|
self.current_boid_num += 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user