Lights Out |
| Turn out all the lights, if you can, by clicking on the light bulbs. Each time you click on a light bulb, it changes its state (on or off), as well as the state of the bulb above, below, left and right. |
\n'
document.write(temp);
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var lightbulbs = new Array(5);
var counter;
function init(){
lightbulbs[0] = new Array(5);
lightbulbs[1] = new Array(5);
lightbulbs[2] = new Array(5);
lightbulbs[3] = new Array(5);
lightbulbs[4] = new Array(5);
counter=0;
for (x=0;x<5;++x){
for (y=0;y<5;++y){
lightbulbs[x][y]=Math.round(Math.random());
}
}
}
function update(){
var lightsoutObj = InternetExplorer ? lightsout : document.lightsout;
for (x=0;x<5;++x){
for (y=0;y<5;++y){
lightsoutObj.TGotoFrame("_flash0/bulb"+x+y, lightbulbs[x][y]);
}
}
}
function bulbs(xpos, ypos){
if ((lightbulbs[xpos][ypos])==0){
lightbulbs[xpos][ypos]=1;
}else{
lightbulbs[xpos][ypos]=0;
}
if (xpos>0){
lightbulbs[xpos-1][ypos]=(lightbulbs[xpos-1][ypos])-1;
if (lightbulbs[xpos-1][ypos]==-1){
lightbulbs[xpos-1][ypos]=1;
}
}
if (ypos>0){
lightbulbs[xpos][ypos-1]=(lightbulbs[xpos][ypos-1])-1;
if (lightbulbs[xpos][ypos-1]==-1){
lightbulbs[xpos][ypos-1]=1;
}
}
if (xpos<4){
lightbulbs[xpos+1][ypos]=(lightbulbs[xpos+1][ypos])-1;
if (lightbulbs[xpos+1][ypos]==-1){
lightbulbs[xpos+1][ypos]=1;
}
}
if (ypos<4){
lightbulbs[xpos][ypos+1]=(lightbulbs[xpos][ypos+1])-1;
if (lightbulbs[xpos][ypos+1]==-1){
lightbulbs[xpos][ypos+1]=1;
}
}
}
function lightsout_DoFSCommand(command, args) {
var lightsoutObj = InternetExplorer ? lightsout : document.lightsout;
var temp1 = 0;
var temp2 = 0;
if (command=="update"){
update();
}
if (command=="flipswitch"){
bulbs(parseInt(String(args).charAt(0)), parseInt(String(args).charAt(1)));
update();
}
}
// -->