Birds on the Beach
CODE
The following code is for the bird’s wings and body, I had to use the custom shape in order to make the wings. I really like how it ended up looking, but I did have a hard time making it symmetrical.
//Body
fill("#3f3737");
ellipse(200,200,60,100,10);
// Left Wing
beginShape();
vertex(176,215);
vertex(140,225);
vertex(125,245);
vertex(120,200);
vertex(125,180);
vertex(140,170);
vertex(155,160);
vertex(183,160);
endShape();
//Right Wing
beginShape();
vertex(222,215);
vertex(260,225);
vertex(270,245);
vertex(275,200);
vertex(265,180);
vertex(260,170);
vertex(230,160);
vertex(214,160);
endShape();
For the code that makes it move, I had a bit of a harder time…
class Bird{
constructor(x,y,yspeed) {
let nums = [1,2,3,5,10,25,50];
this.x = x;
this.y = y;
this.yspeed = random(nums);
}
move() {
this.y -= this.yspeed;
}
show() {
push();
translate(this.x,this.y);
As it can be seen, I only wanted it to move in the “y” axis, so there’s no “xspeed”. For the movement speed, I used an array of numbers, so it can go quite slow or super fast. Now, the most complicated thing was moving the whole bird, since when I first tried it, all the shapes that made up the bird simply merged. I spent no less than an hour trying to make it work, but I wasn’t successful. So I just googled “how to move shapes together in p5” and it led me to “translate”, and when I looked it up on the p5 guide, it gave me all the answers that I needed (kinda). I’m not really sure how it worked, I was just trying different combinations until I added the “this.x” and “this.y” values and it suddenly worked.
INSPIRATION
It isn’t based on anything specific, I just made the background look like a regular beach and tried my best to do a regular bird, although for this, I did have to sketch with a pen and paper how I could do the wings:

WHAT WOULD I IMPROVE?
For the next time, if I had more time, I´d like to be able to implement the pop function, as well as more randomness (maybe the bird’s color) into it, and I’d also add more detail to everything.
REFERENCES I USED