After going through a creative block, I finally managed to create this:
Below is the code for the project:
let stars =[];
let rockets=[];
function setup() {
createCanvas(600, 700);
for (let i = 0; i < 100; i++) {
stars[i] = new Star(random(width), random(height), random(1, 5));
}
rocket = new Rocket(width / 2, height, 5);
moon = new Moon(500,100,50);
// Add mouse click event listener
mouseClicked = function() {
let x = mouseX;
let y = mouseY;
let rocket = new Rocket(x, y, 5);
rockets.push(rocket);
}
}
function draw() {
background(1,22,64);
//Drawing the stars
for (let star of stars) {
star.show();
}
//Drawing the moon
moon.show();
//Drawing the rockets
for (let i = 0; i < rockets.length; i++) {
rockets[i].update();
rockets[i].show();
}
}
//Class making the randomized stars in the background
class Star {
constructor(x, y, size) {
this.x = x;
this.y = y;
this.size = size;
}
//Drawing the stars
show() {
stroke(255);
strokeWeight(this.size);
point(this.x, this.y);
}
}
//Making the moon
class Moon {
constructor(x, y, diameter) {
this.x = x;
this.y = y;
this.diameter = diameter;
}
show() {
//The main body
noStroke()
fill(254, 252, 215);
ellipse(this.x, this.y, this.diameter, this.diameter);
// Adding shadows
fill(234, 232, 185);
ellipse(this.x + this.diameter / 4, this.y, this.diameter / 2, this.diameter / 2);
ellipse(this.x+5 - this.diameter / 4, this.y + this.diameter / 4, this.diameter / 2, this.diameter / 4);
}
}
//Class making the rocket
class Rocket {
constructor(x, y, velocity) {
this.x = x;
this.y = y;
this.velocity = velocity;
}
update() {
this.y -= this.velocity;
}
//Body of rocket
show() {
//Flames
noStroke()
fill(255,185,0)
ellipse(this.x,this.y+35,20,60)
//Side fins
fill(30,144,255);
arc(this.x,this.y + 36,40,40,PI,0,CHORD)
// Body
fill(255,0,0)
ellipse(this.x,this.y,30,80)
//Windows
fill(255);
ellipse(this.x,this.y-12.15,15)
fill(255);
ellipse(this.x,this.y+6.15,15)
//Front fin
fill(30,144,255);
ellipse(this.x,this.y+32,5,30)
}
}
I went through a creator’s block for a couple of days meaning I could not think what I should make for a project. Then one morning, during my CSO class, we watched a case study on a rocket ship: the Ariane 5. This gave me the idea of creating a rocket taking off into space as my project.
I’m especially proud of how my stars and rocket turned out. I always enjoyed looking at the night sky due to the presence of stars above and wanted to make sure the stars in my project would look at least somewhat pretty and I am quite happy with how they turned out. the rocket ship took some experimenting, but I finally settled on this design which gives a more cartoonish look, but I believe was the best one I made.
In the future, I can definitely add more by animating the flames in order to breath more life into the rocket. I also wanted to add sound effects, but I could not find any suitable sound effect for my rocket so ended up scrapping that idea though I am more than happy to revisit that in the future.