Full version: jsB@nk » Multimedia » Events » Flying Stars I
URL: https://www.javascriptbank.com/flying-stars.html
Take your webpage into the stars with this 3D animation starfield script! The stars travel towards you in an incessant manner. This JavaScript uses NO images.
Full version: jsB@nk » Multimedia » Events » Flying Stars I
URL: https://www.javascriptbank.com/flying-stars.html
<script language="JavaScript1.2"><!-- Begin// written by Matthew Musgrove// [email protected] no = 50;var speed = .001;var ns4up = (document.layers) ? 1 : 0;var ie4up = (document.all) ? 1 : 0;var s, x, y, sn, cs;var a, r, cx, cy;var i, doc_width = 800, doc_height = 600;if (ns4up) {doc_width = self.innerWidth;doc_height = self.innerHeight;}else if (ie4up) {doc_width = document.body.clientWidth;doc_height = document.body.clientHeight;}x = new Array();y = new Array();a = new Array();r = new Array();s = new Array();sn = new Array();cs = new Array();cx = doc_width/2;cy = doc_height/2;s = 8;for (i = 0; i < no; ++ i) { initStar();if (ns4up) {if (i == 0) {document.write("<layer name=\"dot"+ i +"\" left=\"1\" ");document.write("top=\"1\" visibility=\"show\">");document.write("<font size=\"+1\">.</font></layer>");}else {document.write("<layer name=\"dot"+ i +"\" left=\"1\" ");document.write("top=\"1\" visibility=\"show\">");document.write("<font size=\"+1\">.</font></layer>"); }}else if (ie4up) {if (i == 0) {document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");document.write("visible; TOP: 15px; LEFT: 15px;\">");document.write("<font size=\"+1\">.</font></div>");}else {document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");document.write("visible; TOP: 15px; LEFT: 15px;\">");document.write("<font size=\"+1\">.</font></div>");}}}function initStar() {a[i] = Math.random() * 360;r[i] = Math.random() * ((doc_height - 100) / 2) + 1;sn[i] = Math.sin(a[i]);cs[i] = Math.cos(a[i]);x[i] = r[i] * sn[i] + cx;y[i] = r[i] * cs[i] + cy;}function makeStar() {a[i] = Math.random() * 360;r[i] = Math.random() * 4 + 1;sn[i] = Math.sin(a[i]);cs[i] = Math.cos(a[i]);x[i] = r[i] * sn[i] + cx;y[i] = r[i] * cs[i] + cy;}function updateStar() {r[i] += s;x[i] = r[i] * sn[i] + cx;y[i] = r[i] * cs[i] + cy;}function snowNS() {for (i = 0; i < no; ++ i) {updateStar();if ((x[i] <= 50) || (x[i] >= (doc_width - 50)) || (y[i] <= 50) || (y[i] >= (doc_height - 50))) {makeStar();doc_width = self.innerWidth;doc_height = self.innerHeight;}document.layers["dot"+i].top = y[i];document.layers["dot"+i].left = x[i];}setTimeout("snowNS()", speed);}function snowIE() {for (i = 0; i < no; ++ i) {updateStar();if ((x[i] <= 50) || (x[i] >= (doc_width - 50)) || (y[i] <= 50) || (y[i] >= (doc_height - 50))) {makeStar();doc_width = document.body.clientWidth;doc_height = document.body.clientHeight;}document.all["dot"+i].style.pixelTop = y[i];document.all["dot"+i].style.pixelLeft = x[i];}setTimeout("snowIE()", speed);}if (ns4up) {snowNS();}else if (ie4up) {snowIE();}// End --></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->