//record = 1000000 boardSize = 45 xs = 45 ys = boardSize x = 0 y = 0 oldX = 0 oldY = 0 function NW(x,y) { // press W if (y%2 == 0) { x -= 1; if (x<0){x=0;} } y -= 1; if (y < 0) {y=0;} return [x,y] } function R(x,y) { // press d x += 1; if (x>xs - 1) {x=xs - 1;} return [x,y] } function L(x,y) { // press a x -= 1; if (x<0) {x = 0;} return [x,y] } function NE(x,y) { // press E if (y%2 == 1) { x += 1; if (x>xs-1){x=xs-1;} } y -= 1; if (y < 0) {y=0;} return [x,y] } function SW(x,y) { // press Z if (y%2 == 0) { x -= 1; if (x<0){x=0;} } y += 1; if (y>= ys) {y=ys - 1;} return [x,y] } function SE(x,y) { // press x if (y%2 == 1) { x += 1; if (x>xs-1){x=xs-1;} } y += 1; if (y>= ys) {y=ys - 1;} return [x,y] } $(document).ready( function(){ timer = false function hex(x,y) { index = xs*y+x; return document.getElementsByTagName("polygon")[index]; } if ( (hex(0,1).style.fill=="red")&&(hex(1,0).style.fill=="red") ) { location.reload(); } if ( (hex(0,2).style.fill=="red")&&(hex(1,1).style.fill=="red")&&(hex(1,0).style.fill=="red") ) { location.reload(); } if ( (hex(xs-2,ys-1).style.fill=="red")&&(hex(xs-1,ys-2).style.fill=="red")&&(hex(xs-2,ys-2).style.fill=="red") ) { location.reload(); } if ( (hex(xs-2,ys-1).style.fill=="red")&&(hex(xs-1,ys-3).style.fill=="red")&&(hex(xs-2,ys-2).style.fill=="red") ) { location.reload(); } hex(xs-1,ys-1).title="0"; if (hex(xs-2,ys-1).style.fill == "green") { hex(xs-2,ys-1).title="1"; } for (x=0; x 5){ hex(x,y-5).scrollIntoView( { behavior: 'smooth' } ); } } else { x = oldX; y = oldY; }; $("#coords").html( "(" + x.toString() + "," + y.toString() +")" ); if ( (x==xs - 1) && (y==boardSize - 1) ) { newScore = (new Date().getTime())-startTime; //if (newScore < record) { // recordString = " New record!! The old one was " + record.toString(); // record = newScore; //} else { // recordString = "NOT a new record...The record is still " + record.toString(); //} alert( "You did it!\n" + (newScore/1000).toString() + " seconds.\n" //+ recordString ); }; } ); } );