xxxxxxxxxx
110
let starX, starY;
let speed;
function setup() {
createCanvas(600, 600);
background(0);
starX = random(width);
starY = 0;
speed = random(40);
}
var xoff= 0.0;
var yoff = 0.0;
function drawStar(){
const radius1 = 15;
const radius2 = 7;
stroke(255);
//Draw the star
beginShape();
for (let i = 0; i < 5; i++) {
const angle1 = TWO_PI / 5 * i - HALF_PI;
const angle2 = TWO_PI / 5 * i + TWO_PI / 10 - HALF_PI;
const x1 = starX + cos(angle1) * radius1;
const y1 = starY + sin(angle1) * radius1;
const x2 = starX + cos(angle2) * radius2;
const y2 = starY + sin(angle2) * radius2;
vertex(x1, y1);
vertex(x2, y2);
}
endShape(CLOSE);
//Update the star position
starY += speed;
// Reset position at the end
if (starY > height + 15) {
starY = 0;
starX = random(width);
speed = random(40, 60);
}
}
let h = 500
function draw() {
background(0)
//NOISE
xoff = xoff + 0.01;
let n = noise(xoff) * width;
let j = h;
if(mouseIsPressed){
h -=1;
}
//Random stars in the background
var i;
var am = random(500,800);
for(i = 0;i<am;i++){
var cx = random(width);
var cy = random(height);
var weight = random(10)
strokeWeight(weight);
var a = random(30,150)
var b = random(30,150)
var c = random(30,150)
if(abs(n-cx) <40 && cy>j-75){
stroke(a+100,b+70,c+70)
point(cx,cy);
}
else{
stroke(a,b,c)
point(cx,cy);
}
}
//Star Behavior
fill(255, 255, 0);
strokeWeight(0);
for(var x = 0;x<2;x++){
//drawStar();
}
//STARSHIP
beginShape();//<---- TOP
fill(205,60,60);
curveVertex(n+15, j-30);
curveVertex(n+15, j-30);
curveVertex(n, j-50);
curveVertex(n-15, j-30);
curveVertex(n-15, j-30);
endShape();
//-----------
fill(220);//<---BODY
rectMode(CENTER);
rect (n,j,30,60);
fill(0);
ellipse (n,j-15,15,15);
fill(205,60,60);
ellipse (n,j-15,10,10);
fill(250,150,10);//<-----FIRE
triangle(n-15,j+35,n-20,j+50,n-5,j+35);
triangle(n+15,j+35,n+20,j+50,n+5,j+35)
}