Lab 02 — Coding Basics
Creating and updating variables and if conditions.
Description
Created a sketch that has a circle moving across the canvas. The circle changes color randomly when it hits the border of the canvas. The circle also changes direction when it hits the border of the canvas. The circle also changes direction and color randomly when the mouse is pressed. One of the difficulties I faced was getting the circle to change size and stay within the canvas, so growing and shrinking is turned off so the circle stays a constant size.
Learning Notes
Learnt about variables and how to use them in p5.js. Learnt about if conditions and how to use them to change the behavior of the sketch. Learnt about the mousePressed() function and how to use it to reset the position of the circle on mouse click.
View the Codebase