Week #1 Assignment – Abdelrahman Mallasi

For this project, I chose the following from the two lists:

    • Create a random walker with dynamic probabilities
    • Walk through RGB or HSB space (as opposed to XYZ)

This project features a bee which appears when the user presses the mouse and disappears when the mouse is released. The bee has a 70% chance of following the cursor and moves through HSB space. I chose this concept to demonstrate the impact that humans can have with nature, whether it be positive or negative. This is illustrated by the fact that the bee only appears when the user interacts with the program, and it’s more likely to follow/be impacted the direction that the user chooses. 

  • A highlight of some code that I’m particularly proud of

    if (random(0,1) < 0.7) { // 70% chance of moving toward the mouse cursor
         // Calculate the vector pointing towards the cursor
         let mouseVector = createVector(mouseX, mouseY);
         let direction = p5.Vector.sub(mouseVector, this.position);
         let velocity = direction.mult(this.speed);
    
         // Normalize the direction vector
         direction.normalize();
    
         // Adjust the bee's position based on the velocity vector
         this.position.add(velocity);
       } else {
         let direction = p5.Vector.random2D().mult(random(5, 15)); // Move in a random direction
         this.position.add(direction);       // Adjust the bee's position based on the direction vector
    
       }
    

    I’m proud of the fact that I was able to implement the concepts we learned in Vectors into this assignment. I used vector mathematics to calculate the direction and velocity needed for the bee to move toward the cursor. I’m also proud of how I implemented the 70% probability by using conditional logic.

  • Embedded sketch

    Link of Sketch:https://editor.p5js.org/ahm9979/sketches/slZfNiW9H

  • Reflection and ideas for future work or improvement
    • Create a bee that looks more like an actual bee – with wings and black and yellow stripes for example
    • Add more interactive elements, such as moving flowers or a starry nightsky
    • What was most challenging about this assignment is organizing the code into different classes rather than writing everything under the draw function. It does make the code neater and easier to understand but it was a long process to get there.

 

Leave a Reply

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