<script LANGUAGE="JavaScript">
// ---- Make array
function MakeArray( n){ this.length = n;
for (var i = 1; i <= n; i++) {
this[i] = 0
}
return this
}
// ----- poor man's random number
var d0 = new Date();
var r0 = d0.getSeconds();
function poor_rand(){
d1 = new Date();
r0 = (r0 * r0 + r0 + d1.getSeconds()) % 3721 ;
return r0 % width_n;
}
// ---- Parameters of game
var height_n = 8;
var width_n =5;
// ---- state of game
var enemy = new MakeArray( width_n); // enemy positions
var wtime; // wait time
var score; // points
var gameover; // in case of gameover set to true
// ----- Make the battlefield.
document.write( "
");
document.write( "
");
// ----- game main timer event
// ----- enemy come one step
function come(){
var n = poor_rand();
document.fm2.elements[ width_n * enemy[n+1] + n].checked = true;
enemy[n+1]++;
if( enemy[n+1] < height_n){
setTimeout("come()", wtime);
}else{
gameover = true;
document.fm1.message.value = "GAME OVER:" + score ;
}
}
// ----- Fire the n th beam
function fire( n){
if( gameover ) return;
for( var i=0; i
50){ wtime -= 10};
}
// ---- initialize & start game
function game_start(){
for( var n=0; n
</script>