Week 9: Flock System


Inspiration

The allure of motion and interaction in coding has always captivated creative minds. Inspired by the elegance of pursuing entities within a simulated environment, I embarked on a journey to create a scenario where two ships engage in a chase, using the p5.js library to bring this dynamic scenario to life.

Description

In my canvas, I introduce two protagonists: the main ship and the chasing ship. The main ship, stationed at the center, exudes confidence with its robust speed capabilities. On the other hand, the chasing ship, eager and agile, strives to emulate the movements of the main ship.

The code orchestrates this chase by employing principles of physics and steering behaviors. The main ship moves freely while the chasing ship dynamically adjusts its course to follow the main ship’s trajectory. It utilizes the update() method, considering the position of the main ship, and then employs acceleration and steering vectors to mimic its movements.

Challenges

The core challenge was harmonizing the pursuit behavior of the chasing ship. Calculating the optimal steering force to smoothly follow the main ship without overshooting or lagging required precision and fine-tuning. Managing the ship’s speed and acceleration while ensuring a balanced chase added complexity to the code.

Additionally, synchronizing the rotation of the ships to simulate their heading accurately while maintaining a sleek and responsive visual representation demanded meticulous handling of angles and shapes.

Leave a Reply

Your email address will not be published. Required fields are marked *