code a space scene in js
snippet in javascript

code a space scene in js

user1532

//{
var OuterSpace = function(){
var s = 300;
var v = 100;
var n = 200;
var w = 10;
var r = 30;
var U = 100;
var keys = [];
keyPressed = function(){
    keys[keyCode] = true;
};
keyReleased = function(){
    keys[keyCode] = false;
};

var Background = function(){
var color1 = color(122, 122, 122);
var color2 = color(31, 34, 46);
for (var i = 0; i < width; i++) {
    stroke(lerpColor(color1, color2, i / width));
    line(-5, i, 600, i);
}

};
var MovingStars = function(){
noStroke();
fill(184, 184, 184);
ellipse(v,random(200,400),w,15);
ellipse(s,random(200,501),w,15);
ellipse(v,random(200,300),w,15);
ellipse(s,random(229,200),w,15);
ellipse(v,random(360,250),w,15);
ellipse(s,random(200,20),w,15);
ellipse(v,random(200,0),w,15);
ellipse(s,random(552,200),w,15);
ellipse(v,random(200,200),w,15);
ellipse(s,random(200,200),15,15);
ellipse(v,random(430,200),15,15);
ellipse(s,random(278,200),15,15);
ellipse(v,random(200,200),15,15);
ellipse(s,random(200,200),15,15);
ellipse(v,random(200,200),15,15);
ellipse(s,random(200,200),15,15);
ellipse(v,random(200,200),15,15);
ellipse(s,random(200,200),15,15);
ellipse(v,random(200,200),15,15);
ellipse(s,random(200,200),15,15);
};
var Stars = function(){
for(var s = 0; s < 400; s++){
        fill(255, 255, 255);
        ellipse(random(0, 400), random(0, 400), 5, 5);
}
};
draw = function() {
    s-=0.87;
    v-=0.87;
    n-=0.87;
    w+=0.03;
    if(mouseIsPressed){
        Program.restart();
    }
  
Background();
MovingStars();
Stars();
};
};
mouseClicked = function() {
    OuterSpace();
};
//}

//All the code