⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 co32018.html

📁 puzzle game cool stuff check this out
💻 HTML
字号:
<html>
<head>
<title> Welcome to Romeo & Juliet Puzzle Game !</title>

<hr size=3 width=60% align=center>
<center><h1>
<script>
var message="Welcome to Romeo & Juliet Puzzle Game ! "
var neonbasecolor="#663300"
var neontextcolor="#996666"
var flashspeed=100  
var n=0
if (document.all){
document.write('<font color="'+neonbasecolor+'">')
for (m=0;m<message.length;m++)
document.write('<span id="neonlight">'+message.charAt(m)+'</span>')
document.write('</font>')


var tempref=document.all.neonlight
}
else
document.write(message)

function neon(){


if (n==0){
for (m=0;m<message.length;m++)
tempref[m].style.color=neonbasecolor
}

tempref[n].style.color=neontextcolor

if (n<tempref.length-1)
n++
else{
n=0
clearInterval(flashing)
setTimeout("beginneon()",1500)
return
}
}

function beginneon(){
if (document.all)
flashing=setInterval("neon()",flashspeed)
}
beginneon()
</script>

</h1>
</center>
<hr size=3 width=60% align=center>
<br>
<table border=10 bordercolor=#663300 cellspacing=15 cellpadding=20 align=center>
<tr align=right bgcolor=#996666><th>
<p><font face="arial" color="yellow"><h2>How to Play</h2><td align=left>
<font color="yellow">You see these two snails. They are Romeo and Juliet. Juliet is on her balcony, waiting the arrival of her love; but Romeo has been 
dining and cannot, for the life of him, remember the number of her house. The squares represent 64 houses, and the amorous swain 
visits every house once and only once before reaching his beloved. Now, make him do this with the least possible turnings. The snail 
can move up, down and across the board and through the diagonals.</font></p>
</tr>
</table>


<center>
<style>
#chess td { width:40px; height:40px; font-size: 35px; text-align: center; color:#999999; }
#chess img { width:36px; height:36px; }
.a { background-color:#996666; }
.b { background-color:#663300; }
.initial2{font-weight:bold;background-color:yellow}
</style>


<script language="JavaScript">


Function.prototype.Extends = function (parentClass)
{
  var Bs = new Function();
  Bs.prototype = parentClass.prototype;
  this.prototype = new Bs();
  this.prototype.Super = parentClass;
  this.prototype.SuperMethod = _$$SuperMethod;
  this.prototype.constructor = this;
}
function _$$SuperMethod(o)
{
  var method = this.Super.prototype[o];
  o = this;
  Function.prototype.call.apply(method,arguments);
}



////////////////////////////////////////////////////////////////

function Chessboard()	// chessboard represents 64 houses
{
  this.xlen = 8;
  this.ylen = 8;
  this.cheArr = [];
  this.setArr();
}

Chessboard.prototype.setArr = function ()
{
  for(var iy=0; iy<this.ylen; iy++)
  {
    this.cheArr[iy] = [];
    for(var ix=0; ix<this.xlen; ix++)
      this.cheArr[iy][ix] = false;
  }
}

Chessboard.prototype.write = function ()
{
  var str = '<table id="chess" border="0" cellspacing="0" cellpadding="0">';
  for(var iy=0; iy<this.ylen; iy++)
  {
    str += "<tr>";
    for(var ix=0; ix<this.xlen; ix++)
      str += '<td onclick="bluSnail.go('+ix+','+iy+');" class="'+["a","b"][(ix+iy)%2]+'"></td>';
    str += "</tr>";
  }
  str += '</table>';
  document.getElementById("chessBox").innerHTML = str;
}

Chessboard.prototype.getTd = function (x,y)
{
  return document.getElementById("chess").rows[y].cells[x];
}

/////////////////////////////////////////////////////

function Snail(x,y,url)	 // snail as chessman
{
  this.x = x;
  this.y = y;
  this.url = url;
  this.obj = document.createElement("img");
  this.obj.src = this.url;
  this.move();
}

Snail.prototype.move = function ()
{
  che.getTd(this.x,this.y).appendChild(this.obj);
}

////////////////////////////////////////////////////////

function BlueSnail(x,y,url)	
{
  this.Super(x,y,url);
  this.step = 0;
  this.turn = -1;
  this.tX = 0;
  this.tY = 0;
  this.ok = false;
  document.getElementById("stepBox").innerText = 0;
  document.getElementById("turnBox").innerText = 0;
}

BlueSnail.Extends(Snail);  // blue snail as romeo

BlueSnail.prototype.go = function (x,y)
{
  if(this.ok || Math.abs(x-this.x)>1 || Math.abs(y-this.y)>1 || che.cheArr[y][x]) 
    return;
  document.getElementById("stepBox").innerText = ++this.step;
  this.ifTurn(x,y);
  if(this.win(x,y))
    return;
  var jo = che.getTd(this.x,this.y);
  this.x = x;
  this.y = y;
  this.move();
  jo.innerText = "+";
}

BlueSnail.prototype.move = function ()
{
  che.cheArr[this.y][this.x] = true;
  this.SuperMethod("move");
}

BlueSnail.prototype.win = function (x,y)
{
  if(x==gulSnail.x && y==gulSnail.y)
  {
    this.ok = true;
    if(this.step<63)
      alert("Be patient! You have to say hi to every house before you see her again. You have visited "+this.step+" houses,and made "+this.turn+" turns. Start a new game and take it easy."); 
    else
      alert("Congratulations! You finally see Juliet again after "+this.turn+" turns. But this is not the shortest way, start a new game and try again."); 
  }
  return this.ok;
}

BlueSnail.prototype.ifTurn = function (x,y)
{
  x-=this.x;
  y-=this.y;
  if(this.tX!=x || this.tY!=y)
    document.getElementById("turnBox").innerText = ++this.turn;
  this.tX=x;
  this.tY=y;
}

/////////////////////////////////////////////////

var che, gulSnail, bluSnail;

function play()
{
  che = new Chessboard();
  che.write();
  gulSnail = new Snail(2,2,img="juliet.gif");
  bluSnail = new BlueSnail(5,5,img="romeo.gif");
}

function change(color){
var el=event.srcElement
if (el.tagName=="INPUT"&&el.type=="button")
event.srcElement.style.backgroundColor=color
}

</script>
</head>

<body>
<br>
<div id="chessBox">
</div> 
<br><form onMouseover="change('#996666')" onMouseout="change('yellow')">
<p><font face="arial" size=5 color="#996666">
House:<span id="stepBox"></span>   Turn:<span id="turnBox"></span> <p>
<input type="button" value="Start New Game" class="initial2" onclick="play()" id=flashit>	

<script>

if (document.all&&document.all.flashit){

var flashelement=document.all.flashit
if (flashelement.length==null)
flashelement[0]=document.all.flashit

function changecolor(which){
if (flashelement[which].style.color=='')
flashelement[which].style.color="#663300"
else
flashelement[which].style.color=""
}


if (flashelement.length==null)
setInterval("changecolor(0)",1000)
else
for (i=0;i<flashelement.length;i++){
var tempvariable='setInterval("changecolor('+i+')",'+'1000)'
eval(tempvariable)
}
}
</script>


</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -