Add files via upload

This commit is contained in:
MattTheTekie 2023-07-16 15:09:18 -04:00 committed by GitHub
commit 810e9e465c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 1324 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

View file

@ -0,0 +1,332 @@
<html>
<head><style type="text/css">
.intro { font-size:10pt; font-style:italic }
.heading { font-size:14pt; font-weight:bold; font-family:sans-serif }
.title { font-size:18pt; font-weight:bold; background-color:navy; color:white; text-align:center; font-family:sans-serif }
</style>
<title>Battleship</title>
</head>
<body bgcolor="#ffffff">
<font face="verdana, arial, helvetica" size="3">Contributed to The Javascript Source by <a href="http://www.members.home.com/jasonhotchkiss">Jason Hotchkiss</a></font>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Jason Hotchkiss (jasonhotchkiss@home.com) -->
<!-- Web Site: http://www.members.home.com/jasonhotchkiss -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
/* Information used to draw the ships
*/
var ship = [[[1,5], [1,2,5], [1,2,3,5], [1,2,3,4,5]], [[6,10], [6,7,10], [6,7,8,10], [6,7,8,9,10]]];
/* Information used to draw sunk ships
*/
var dead = [[[201,203], [201,202,203], [201,202,202,203], [201,202,202,202,203]], [[204,206], [204,205,206], [204,205,205,206], [204,205,205,205,206]]];
/* Information used to describe ships
*/
var shiptypes = [["Minesweeper",2,4],["Frigate",3,4],[ "Cruiser",4,2],[ "Battleship",5,1]];
var gridx = 16, gridy = 16;
var player = [], computer = [], playersships = [], computersships = [];
var playerlives = 0, computerlives = 0, playflag=true, statusmsg="";
/* Function to preload all the images, to prevent delays during play
*/
var preloaded = [];
function imagePreload() {
var i,ids = [1,2,3,4,5,6,7,8,9,10,100,101,102,103,201,202,203,204,205,206];
window.status = "Preloading images...please wait";
for (i=0;i<ids.length;++i) {
var img = new Image, name = "batt"+ids[i]+".gif";
img.src = name;
preloaded[i] = img;
}
window.status = "";
}
/* Function to place the ships in the grid
*/
function setupPlayer(ispc) {
var y,x;
grid = [];
for (y=0;y<gridx;++y) {
grid[y] = [];
for (x=0;x<gridx;++x)
grid[y][x] = [100,-1,0];
}
var shipno = 0;
var s;
for (s=shiptypes.length-1;s>=0;--s) {
var i;
for (i=0;i<shiptypes[s][2];++i) {
var d = Math.floor(Math.random()*2);
var len = shiptypes[s][1], lx=gridx, ly=gridy, dx=0, dy=0;
if ( d==0) {
lx = gridx-len;
dx=1;
}
else {
ly = gridy-len;
dy=1;
}
var x,y,ok;
do {
y = Math.floor(Math.random()*ly);
x = Math.floor(Math.random()*lx);
var j,cx=x,cy=y;
ok = true;
for (j=0;j<len;++j) {
if (grid[cy][cx][0] < 100) {
ok=false;
break;
}
cx+=dx;
cy+=dy;
}
} while(!ok);
var j,cx=x,cy=y;
for (j=0;j<len;++j) {
grid[cy][cx][0] = ship[d][s][j];
grid[cy][cx][1] = shipno;
grid[cy][cx][2] = dead[d][s][j];
cx+=dx;
cy+=dy;
}
if (ispc) {
computersships[shipno] = [s,shiptypes[s][1]];
computerlives++;
}
else {
playersships[shipno] = [s,shiptypes[s][1]];
playerlives++;
}
shipno++;
}
}
return grid;
}
/* Function to change an image shown on a grid
*/
function setImage(y,x,id,ispc) {
if ( ispc ) {
computer[y][x][0] = id;
document.images["pc"+y+"_"+x].src = "batt"+id+".gif";
}
else {
player[y][x][0] = id;
document.images["ply"+y+"_"+x].src = "batt"+id+".gif";
}
}
/* Function to insert HTML source for a grid
*/
function showGrid(ispc) {
var y,x;
for (y=0;y<gridy;++y) {
for (x=0;x<gridx;++x) {
if ( ispc )
document.write ('<a href="javascript:gridClick('+y+','+x+');"><img name="pc'+y+'_'+x+'" src="batt100.gif" width=16 height=16></a>');
else
document.write ('<a href="javascript:void(0);"><img name="ply'+y+'_'+x+'" src="batt'+player[y][x][0]+'.gif" width=16 height=16></a>');
}
document.write('<br>');
}
}
/* Handler for clicking on the grid
*/
function gridClick(y,x) {
if ( playflag ) {
if (computer[y][x][0] < 100) {
setImage(y,x,103,true);
var shipno = computer[y][x][1];
if ( --computersships[shipno][1] == 0 ) {
sinkShip(computer,shipno,true);
alert("You sank my "+shiptypes[computersships[shipno][0]][0]+"!");
updateStatus();
if ( --computerlives == 0 ) {
alert("You win! Press the Refresh button on\n"+
"your browser to play another game.");
playflag = false;
}
}
if ( playflag ) computerMove();
}
else if (computer[y][x][0] == 100) {
setImage(y,x,102,true);
computerMove();
}
}
}
/* Function to make the computers move. Note that the computer does not cheat, oh no!
*/
function computerMove() {
var x,y,pass;
var sx,sy;
var selected = false;
/* Make two passes during 'shoot to kill' mode
*/
for (pass=0;pass<2;++pass) {
for (y=0;y<gridy && !selected;++y) {
for (x=0;x<gridx && !selected;++x) {
/* Explosion shown at this position
*/
if (player[y][x][0]==103) {
sx=x; sy=y;
var nup=(y>0 && player[y-1][x][0]<=100);
var ndn=(y<gridy-1 && player[y+1][x][0]<=100);
var nlt=(x>0 && player[y][x-1][0]<=100);
var nrt=(x<gridx-1 && player[y][x+1][0]<=100);
if ( pass == 0 ) {
/* On first pass look for two explosions
in a row - next shot will be inline
*/
var yup=(y>0 && player[y-1][x][0]==103);
var ydn=(y<gridy-1 && player[y+1][x][0]==103);
var ylt=(x>0 && player[y][x-1][0]==103);
var yrt=(x<gridx-1 && player[y][x+1][0]==103);
if ( nlt && yrt) { sx = x-1; selected=true; }
else if ( nrt && ylt) { sx = x+1; selected=true; }
else if ( nup && ydn) { sy = y-1; selected=true; }
else if ( ndn && yup) { sy = y+1; selected=true; }
}
else {
/* Second pass look for single explosion -
fire shots all around it
*/
if ( nlt ) { sx=x-1; selected=true; }
else if ( nrt ) { sx=x+1; selected=true; }
else if ( nup ) { sy=y-1; selected=true; }
else if ( ndn ) { sy=y+1; selected=true; }
}
}
}
}
}
if ( !selected ) {
/* Nothing found in 'shoot to kill' mode, so we're just taking
potshots. Random shots are in a chequerboard pattern for
maximum efficiency, and never twice in the same place
*/
do{
sy = Math.floor(Math.random() * gridy);
sx = Math.floor(Math.random() * gridx/2)*2+sy%2;
} while( player[sy][sx][0]>100 );
}
if (player[sy][sx][0] < 100) {
/* Hit something
*/
setImage(sy,sx,103,false);
var shipno = player[sy][sx][1];
if ( --playersships[shipno][1] == 0 ) {
sinkShip(player,shipno,false);
alert("I sank your "+shiptypes[playersships[shipno][0]][0]+"!");
if ( --playerlives == 0 ) {
knowYourEnemy();
alert("I win! Press the Refresh button on\n"+
"your browser to play another game.");
playflag = false;
}
}
}
else {
/* Missed
*/
setImage(sy,sx,102,false);
}
}
/* When whole ship is hit, show it using changed graphics
*/
function sinkShip(grid,shipno,ispc) {
var y,x;
for (y=0;y<gridx;++y) {
for (x=0;x<gridx;++x) {
if ( grid[y][x][1] == shipno )
if (ispc) setImage(y,x,computer[y][x][2],true);
else setImage(y,x,player[y][x][2],false);
}
}
}
/* Show location of all the computers ships - when player has lost
*/
function knowYourEnemy() {
var y,x;
for (y=0;y<gridx;++y) {
for (x=0;x<gridx;++x) {
if ( computer[y][x][0] == 103 )
setImage(y,x,computer[y][x][2],true);
else if ( computer[y][x][0] < 100 )
setImage(y,x,computer[y][x][0],true);
}
}
}
/* Show how many ships computer has left
*/
function updateStatus() {
var f=false,i,s = "Computer has ";
for (i=0;i<computersships.length;++i) {
if (computersships[i][1] > 0) {
if (f) s=s+", "; else f=true;
s = s + shiptypes[computersships[i][0]][0];
}
}
if (!f) s = s + "nothing left, thanks to you!";
statusmsg = s;
window.status = statusmsg;
}
function setStatus() {
window.status = statusmsg;
}
/* Start the game!
*/
imagePreload();
player = setupPlayer(false);
computer = setupPlayer(true);
document.write("<center><table><tr><td align=center><p class='heading'>COMPUTER'S FLEET</p></td>"+
"<td align=center><p class='heading'>PLAYER'S FLEET</p></td></tr><tr><td>");
showGrid(true);
document.write("</td><td>");
showGrid(false);
document.write("</td></tr></table></center>");
updateStatus();
setInterval("setStatus();", 500);
// End -->
</script>
<p class="intro">"...We have located the enemy fleet under the command of Admiral KompŸter,
but do not yet have visual contact. We suggest the best course of action is to fire
at random into their vicinity and listen for the impact of the shells...</p>
<p class="intro">...Our intelligence sources indicate the composition of the enemy fleet is the same
as our own, and has likewise been forced to resort to the same tactics as ourselves. In accordance with
the rules of war, fire will be exchanged one shell at a time and vessels lost will be announced
immediately...</p>
<p class="intro">...As per your orders you have been placed directly in command of the fleet's guns. Select the target
location by clicking in the left-hand grid above. The right hand grid shows the status of our own fleet.
Information as to the remaining strength of the enemy will be relayed directly to your status bar...</p>
<p class="intro">...We believe this battle will not be over until one or other fleet is sunk in it's entirety. Our gunners
await your commands. We're counting on you, Sir..."</p>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
<hr>
<FONT face="Verdana, Arial, Helvetica"><a href="http://www.tammyyee.com/games.html">More Javascript Games</a></font><P>
<FONT face="Verdana, Arial, Helvetica" color="red"><h3>Menu:</h3></font><br>
<FONT face="Verdana, Arial, Helvetica"><a href="http://www.tammyyee.com/keiki.html">The Keiki Page</a> / <a href="http://www.tammyyee.com/color.html">Coloring</a> / <a href="http://www.tammyyee.com/games.html">Javascript Games</a> / <a href="http://www.tammyyee.com/origami.html">Origami</a> / <a href="http://www.tammyyee.com/puzzle.html">Puzzles To Print</a> / <a href="http://www.tammyyee.com/turtletalk.html">Turtle Talk</a> / <a href="http://www.tammyyee.com/keikilinks.html">Keiki Links</a> / <a href="http://www.tammyyee.com/school.html">Hawaii Schools</a> / <a href="http://www.tammyyee.com/index.html">Home</a></font></center>
</body>
</html>

View file

@ -0,0 +1,34 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Index of /keiki_page/javascript_games/battle</TITLE>
</HEAD>
<BODY>
<H1>Index of /keiki_page/javascript_games/battle</H1>
<PRE><IMG SRC="/icons/blank.gif" ALT=" "> <A HREF="?N=D">Name</A> <A HREF="?M=A">Last modified</A> <A HREF="?S=A">Size</A> <A HREF="?D=A">Description</A>
<HR>
<A HREF="/keiki_page/javascript_games/"><IMG SRC="/icons/back.gif" ALT="[DIR]"></A> <A HREF="/keiki_page/javascript_games/">Parent Directory</A> 09-Apr-2002 10:14 -
<A HREF="batt1.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt1.gif">batt1.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt10.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt10.gif">batt10.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt100.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt100.gif">batt100.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt101.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt101.gif">batt101.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt102.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt102.gif">batt102.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt103.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt103.gif">batt103.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt2.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt2.gif">batt2.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt201.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt201.gif">batt201.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt202.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt202.gif">batt202.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt203.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt203.gif">batt203.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt204.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt204.gif">batt204.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt205.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt205.gif">batt205.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt206.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt206.gif">batt206.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt3.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt3.gif">batt3.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt4.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt4.gif">batt4.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt5.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt5.gif">batt5.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt6.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt6.gif">batt6.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt7.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt7.gif">batt7.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt8.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt8.gif">batt8.gif</A> 26-Jan-2001 13:07 1k
<A HREF="batt9.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="batt9.gif">batt9.gif</A> 26-Jan-2001 13:07 1k
<A HREF="battleship.html"><IMG SRC="/icons/text.gif" ALT="[TXT]"></A> <A HREF="battleship.html">battleship.html</A> 26-Jan-2001 13:07 10k
</PRE><HR>
<ADDRESS>Apache/1.3.34 Server at www.tammyyee.com Port 80</ADDRESS>
</BODY></HTML>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

View file

@ -0,0 +1,443 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META NAME="description" content="CarChamp is a PC-Game written in HTML and JavaScript">
<META NAME="author" content="JavaScript-Clone 2004: Lutz Tautenhahn">
<META NAME="keywords" content="Game, CarChamp, Streich, Stroke, JavaScript">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="imagetoolbar" CONTENT="false">
<title>CarChamp</title>
<script language="JavaScript">
var n, m, IsOver=true, StartTime, EndTime, Level=1, MaxLevel=39, Size=6, IsAni=false, NMoves, Start=0, Clicks;
CarBgPic=new Image();
CarBgPic.src="car_bg.gif";
Car2vPic=new Array(7);
for (n=0; n<7; n++)
Car2vPic[n]=new Array(2);
for (n=0; n<7; n++)
{ for (m=0; m<2; m++)
{ Car2vPic[n] = new Image();
Car2vPic[n].src = "car2v"+n+m+".gif";
}
}
Car2hPic=new Array(6);
for (n=0; n<6; n++)
Car2hPic[n]=new Array(2);
for (n=0; n<6; n++)
{ for (m=0; m<2; m++)
{ Car2hPic[n] = new Image();
Car2hPic[n].src = "car2h"+n+m+".gif";
}
}
Car3vPic=new Array(6);
for (n=0; n<6; n++)
Car3vPic[n]=new Array(3);
for (n=0; n<6; n++)
{ for (m=0; m<3; m++)
{ Car3vPic[n] = new Image();
Car3vPic[n].src = "car3v"+n+m+".gif";
}
}
Car3hPic=new Array(6);
for (n=0; n<6; n++)
Car3hPic[n]=new Array(3);
for (n=0; n<6; n++)
{ for (m=0; m<3; m++)
{ Car3hPic[n] = new Image();
Car3hPic[n].src = "car3h"+n+m+".gif";
}
}
Fld=new Array(Size);
for (n=0; n<Size; n++)
Fld[n]=new Array(Size);
Cars=new Array(MaxLevel);
n=0;
Cars[n++]=new Array(2,3,2,4, 0,0,0,2, 0,4,1,4, 1,1,3,1, 1,2,2,2, 1,5,2,5, 2,0,3,0, 3,2,3,4, 3,5,4,5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0,1,1, 2,5,3,5, 2,0,4,0, 3,3,5,3, 3,1,3,2, 4,4,4,5, 5,0,5,2);
TmpCars=new Array();
CarNum=new Array(19);
Solution = new Array(MaxLevel);
n=0;
Solution[n++]=new Array(3,5, 3,2, 5,1, 1,2, 2,2, 1,1, 2,1, 0,0, 3,0, 2,0, 2,4, 2,3, 2,2);
Solution[n++]=new Array(2,5, 0,5, 0,0, 0,1, 0,2, 2,2, 3,1, 2,1, 4,0, 1,0, 2,0, 2,4, 2,3, 2,2);
Solution[n++]=new Array(0,5, 3,5, 5,5, 5,1, 5,2, 4,0, 4,1, 4,2, 1,2, 2,2, 0,0, 1,0, 2,0, 2,4, 2,3, 2,2);
Solution[n++]=new Array(2,5, 5,5, 4,5, 3,5, 3,2, 1,2, 2,2, 2,4, 0,4, 0,2, 0,0, 1,0, 3,0, 2,0, 2,1, 2,3, 2,2);
Solution[n++]=new Array(2,5, 5,5, 4,5, 3,5, 3,2, 1,2, 2,2, 3,2, 2,1, 2,4, 2,3, 0,4, 0,2, 0,0, 1,0, 3,0, 2,0, 2,2);
Solution[n++]=new Array(3,5, 3,3, 3,1, 0,1, 1,1, 2,1, 0,5, 0,4, 0,3, 2,3, 2,5, 2,4, 2,3, 0,3, 0,0, 3,0, 2,0, 2,2);
Solution[n++]=new Array(0,5, 3,5, 3,2, 4,0, 4,1, 4,2, 5,0, 5,1, 5,2, 0,2, 1,2, 2,2, 1,1, 2,1, 2,0, 2,4, 2,3, 2,2);
Solution[n++]=new Array(1,2, 1,4, 1,3, 3,3, 2,3, 5,3, 4,3, 4,1, 4,2, 4,3, 2,3, 3,3, 2,2, 2,5, 2,4, 2,3, 5,3, 5,0, 2,0, 2,2);
Solution[n++]=new Array(3,3, 3,5, 1,5, 0,5, 5,5, 4,5, 3,5, 2,5, 3,3, 5,3, 5,0, 5,1, 5,2, 2,2, 1,1, 2,1, 1,0, 2,0, 2,4, 2,3, 2,2);
Solution[n++]=new Array(2,0, 0,0, 0,1, 0,3, 0,2,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, 3,2, 3,0, 0,0, 0,3, 3,3, 4,5, 3,5, 3,1, 3,2, 3,3, 5,2, 5,5, 5,4, 5,3, 0,3, 1,3, 2,3, 0,5, 2,5, 2,1, 2,2, 2,3, 4,2, 5,3, 4,3, 4,0, 4,1, 4,2, 4,3, 1,3, 2,3, 2,2, 2,5, 2,4, 2,3, 5,3, 5,0, 1,0, 2,0, 2,2);
function sign(vv)
{ if (vv>0) return(1);
if (vv<0) return(-1);
return(0);
}
function Init(ss)
{ var nn, tt=parseInt(ss)-1;
if (IsAni) return;
IsOver=false;
if (tt>=0) Level=tt;
else tt=Level;
TmpCars.length=0;
for (nn=0; nn<Cars[tt].length; nn++)
TmpCars[nn]=Cars[tt][nn];
CarNum[0]=6;
if (ss>0)
{ Start=Math.floor(Math.random()*1000)%6;
for (nn=1; nn<19; nn++) CarNum[nn]=(Start+nn)%6;
}
UpdateFld();
RefreshScreen();
NMoves=0;
window.document.Options.Moves.value=NMoves;
Now = new Date();
StartTime = Now.getTime() / 1000;
// Clicks="";
}
function UpdateFld()
{ var nn, ii, jj;
for (ii=0; ii<Size; ii++)
{ for (jj=0; jj<Size; jj++)
Fld[ii][jj]=-1;
}
for (nn=0; 4*nn<TmpCars.length; nn++)
{ ii=TmpCars[4*nn];
jj=TmpCars[4*nn+1];
Fld[ii][jj]=nn;
do
{ ii+=sign(TmpCars[4*nn+2]-TmpCars[4*nn]);
jj+=sign(TmpCars[4*nn+3]-TmpCars[4*nn+1]);
Fld[ii][jj]=nn;
}
while ((ii!=TmpCars[4*nn+2])||(jj!=TmpCars[4*nn+3]));
}
}
function GetFld(ii, jj)
{ if (ii<0) return(-2);
if (ii>=Size) return(-2);
if (jj<0) return(-2);
if (jj>=Size) return(-2);
return(Fld[ii][jj]);
}
function Clicked(ii, jj)
{ var ddi, ddj, nn;
if (IsAni) return;
if (IsOver) return;
// Clicks+=ii+","+jj+", ";
for (nn=0; 4*nn<TmpCars.length; nn++)
{ if ((ii==TmpCars[4*nn])&&(jj==TmpCars[4*nn+1]))
{ ddi=sign(TmpCars[4*nn+2]-TmpCars[4*nn]);
ddj=sign(TmpCars[4*nn+3]-TmpCars[4*nn+1]);
if (GetFld(TmpCars[4*nn+2]+ddi,TmpCars[4*nn+3]+ddj)==-1)
{ NMoves++;
window.document.Options.Moves.value=NMoves;
MoveCar(nn,ddi,ddj);
}
return;
}
if ((ii==TmpCars[4*nn+2])&&(jj==TmpCars[4*nn+3]))
{ ddi=sign(TmpCars[4*nn]-TmpCars[4*nn+2]);
ddj=sign(TmpCars[4*nn+1]-TmpCars[4*nn+3]);
if (GetFld(TmpCars[4*nn]+ddi,TmpCars[4*nn+1]+ddj)==-1)
{ NMoves++;
window.document.Options.Moves.value=NMoves;
MoveCar(nn,ddi,ddj);
}
return;
}
}
}
function MoveCar(nn,ddi,ddj)
{ ii=TmpCars[4*nn];
jj=TmpCars[4*nn+1];
Fld[ii][jj]=-1;
document.images[ii+Size*jj].src = CarBgPic.src;
do
{ ii+=sign(TmpCars[4*nn+2]-TmpCars[4*nn]);
jj+=sign(TmpCars[4*nn+3]-TmpCars[4*nn+1]);
Fld[ii][jj]=-1;
document.images[ii+Size*jj].src = CarBgPic.src;
}
while ((ii!=TmpCars[4*nn+2])||(jj!=TmpCars[4*nn+3]));
TmpCars[4*nn]+=ddi;
TmpCars[4*nn+1]+=ddj;
TmpCars[4*nn+2]+=ddi;
TmpCars[4*nn+3]+=ddj;
ii=TmpCars[4*nn];
jj=TmpCars[4*nn+1];
Fld[ii][jj]=nn;
if (TmpCars[4*nn]==TmpCars[4*nn+2])
document.images[ii+Size*jj].src = "car"+eval(TmpCars[4*nn+3]-TmpCars[4*nn+1]+1)+"v"+CarNum[nn]+eval(jj-TmpCars[4*nn+1])+".gif";
else
document.images[ii+Size*jj].src = "car"+eval(TmpCars[4*nn+2]-TmpCars[4*nn]+1)+"h"+CarNum[nn]+eval(ii-TmpCars[4*nn])+".gif";
do
{ ii+=sign(TmpCars[4*nn+2]-TmpCars[4*nn]);
jj+=sign(TmpCars[4*nn+3]-TmpCars[4*nn+1]);
Fld[ii][jj]=nn;
if (TmpCars[4*nn]==TmpCars[4*nn+2])
document.images[ii+Size*jj].src = "car"+eval(TmpCars[4*nn+3]-TmpCars[4*nn+1]+1)+"v"+CarNum[nn]+eval(jj-TmpCars[4*nn+1])+".gif";
else
document.images[ii+Size*jj].src = "car"+eval(TmpCars[4*nn+2]-TmpCars[4*nn]+1)+"h"+CarNum[nn]+eval(ii-TmpCars[4*nn])+".gif";
}
while ((ii!=TmpCars[4*nn+2])||(jj!=TmpCars[4*nn+3]));
OverTest();
}
function OverTest()
{ var nn;
if (IsOver) return;
if (TmpCars[1]!=0) return;
IsOver=true;
Now = new Date();
EndTime = Now.getTime() / 1000;
nn=Math.floor(EndTime - StartTime);
// ww=window.open();
// ww.document.writeln(Clicks);
if (Level+1==MaxLevel)
alert("Super, you solved this game with "+NMoves+" moves in "+nn+ " seconds !");
else
{ if (confirm("Super, you solved this game with "+NMoves+" moves in "+nn+ " seconds !\nDo you want to try the next level ?"))
{ document.Options.SelectLevel.selectedIndex=eval(Level+1);
Init(Level+2);
}
}
}
function RefreshScreen()
{ var nn, mm;
for (nn=0; nn < Size; nn++)
{ for (mm=0; mm < Size; mm++)
document.images[nn+Size*mm].src = CarBgPic.src;
}
for (nn=0; 4*nn<TmpCars.length; nn++) MoveCar(nn,0,0);
}
function Show()
{ if (IsAni) return;
if (Solution[Level].length==0)
{ alert("Sorry, there is no solution available.");
return;
}
alert("Show is not solve !");
Init(-2);
IsAni=true;
IsOver=true;
setTimeout("Animation("+Level+",0)",500);
}
function Animation(tt, mm)
{ if (! IsOver) return;
if (mm==Solution[tt].length)
{ IsAni=false;
return;
}
NMoves++;
window.document.Options.Moves.value=NMoves;
var ii, jj, ddi, ddj, nn;
ii=Solution[tt][mm];
jj=Solution[tt][mm+1];
for (nn=0; 4*nn<TmpCars.length; nn++)
{ if ((ii==TmpCars[4*nn])&&(jj==TmpCars[4*nn+1]))
{ ddi=sign(TmpCars[4*nn+2]-TmpCars[4*nn]);
ddj=sign(TmpCars[4*nn+3]-TmpCars[4*nn+1]);
if (Fld[TmpCars[4*nn+2]+ddi][TmpCars[4*nn+3]+ddj]==-1) MoveCar(nn,ddi,ddj);
}
else
{ if ((ii==TmpCars[4*nn+2])&&(jj==TmpCars[4*nn+3]))
{ ddi=sign(TmpCars[4*nn]-TmpCars[4*nn+2]);
ddj=sign(TmpCars[4*nn+1]-TmpCars[4*nn+3]);
if (Fld[TmpCars[4*nn]+ddi][TmpCars[4*nn+1]+ddj]==-1) MoveCar(nn,ddi,ddj);
}
}
}
setTimeout("Animation("+tt+","+eval(mm+2)+")",500);
}
function Help()
{ alert("This is a clone of the games 'Rush Hour' and 'Car Jam'."+
"\nYour task is to move the black car to the exit."+
"\nClick on a car to push it."+
"\nGood luck!");
}
</script>
</head>
<BODY bgcolor=#eeeeee>
<DIV ALIGN=center>
<form name="Options">
<br>
<table border=0 cellpadding=0 cellspacing=0 bgcolor=#888888>
<script language="JavaScript">
document.open();
document.writeln("<tr>");
document.write("<td bgcolor=#888888>&nbsp;&nbsp;&nbsp;&nbsp;</td>");
for (n=0; n < 2; n++) document.write("<td width=45 bgcolor=#888888>&nbsp;&nbsp;&nbsp;&nbsp;</td>");
document.write("<th width=45 bgcolor=#eeeeee><font size='1'>EXIT</font></th>");
for (n=4; n < Size+1; n++) document.write("<td width=45 bgcolor=#888888>&nbsp;&nbsp;&nbsp;&nbsp;</td>");
document.write("<td bgcolor=#888888>&nbsp;&nbsp;&nbsp;&nbsp;</td>");
document.writeln("</tr>");
document.writeln("<tr>");
document.write("<td height=45 bgcolor=#888888>&nbsp;&nbsp;&nbsp;&nbsp;</td>");
document.write("<td colspan="+Size+" rowspan="+Size+">");
for (m=0; m < Size; m++)
{ document.write("<nobr>");
for (n=0; n < Size; n++)
document.write("<img src='car_bg.gif' border=0 onMouseDown='Clicked("+n+","+m+")'>");
document.write("</nobr>");
if (m<Size-1) document.write("<br>");
}
document.write("</td>");
document.write("<td bgcolor=#888888>&nbsp;&nbsp;&nbsp;&nbsp;</td>");
document.writeln("</tr>");
for (m=0; m < Size-1; m++)
{ document.writeln("<tr>");
document.write("<td height=45 bgcolor=#888888>&nbsp;&nbsp;&nbsp;&nbsp;</td>");
document.write("<td bgcolor=#888888>&nbsp;&nbsp;&nbsp;&nbsp;</td>");
document.writeln("</tr>");
}
document.writeln("<tr>");
for (n=0; n < Size+2; n++) document.write("<td bgcolor=#888888>&nbsp;&nbsp;&nbsp;&nbsp;</td>");
document.writeln("</tr>");
document.close();
</script>
</table>
<br>
<table noborder><tr>
<td align=center><SELECT name="SelectLevel" onChange="Init(this.options[selectedIndex].value)" SIZE=1>
<OPTION VALUE=1>Level 1
<OPTION VALUE=2>Level 2
<OPTION VALUE=3>Level 3
<OPTION VALUE=4>Level 4
<OPTION VALUE=5>Level 5
<OPTION VALUE=6>Level 6
<OPTION VALUE=7>Level 7
<OPTION VALUE=8>Level 8
<OPTION VALUE=9>Level 9
<OPTION VALUE=10>Level 10
<OPTION VALUE=11>Level 11
<OPTION VALUE=12>Level 12
<OPTION VALUE=13>Level 13
<OPTION VALUE=14>Level 14
<OPTION VALUE=15>Level 15
<OPTION VALUE=16>Level 16
<OPTION VALUE=17>Level 17
<OPTION VALUE=18>Level 18
<OPTION VALUE=19>Level 19
<OPTION VALUE=20>Level 20
<OPTION VALUE=21>Level 21
<OPTION VALUE=22>Level 22
<OPTION VALUE=23>Level 23
<OPTION VALUE=24>Level 24
<OPTION VALUE=25>Level 25
<OPTION VALUE=26>Level 26
<OPTION VALUE=27>Level 27
<OPTION VALUE=28>Level 28
<OPTION VALUE=29>Level 29
<OPTION VALUE=30>Level 30
<OPTION VALUE=31>Level 31
<OPTION VALUE=32>Level 32
<OPTION VALUE=33>Level 33
<OPTION VALUE=34>Level 34
<OPTION VALUE=35>Level 35
<OPTION VALUE=36>Level 36
<OPTION VALUE=37>Level 37
<OPTION VALUE=38>Level 38
<OPTION VALUE=39>Level 39
</SELECT>
</td><td>
<input type=button value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" width=40 style="width:35;background-color:#FFFFFF" name="Moves">
</td></tr></table>
<table noborder><tr>
<td><input type=button value="Repeat" width=70 style="width:70" onClick="javascript:Init(0)"></td>
<td><input type=button value="Show" width=70 style="width:70" onClick="javascript:Show()"></td>
<td><input type=button value="Help" width=70 style="width:70" onClick="javascript:Help()"></td>
</tr></table>
</form>
</DIV>
<script language="JavaScript">
Init(1);
</script>
</BODY>
</HTML>

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

View file

@ -0,0 +1,491 @@
<HTML>
<HEAD>
<TITLE>Checkers</TITLE>
</HEAD>
<body bgcolor="#ffffff">
<table align="left" border="0" cellpadding="1" cellspacing="1" width="100" height="100%"><FONT face="Times New Roman,Times">
<tbody>
<tr><td align="center" BGCOLOR="#FF9900"><h3>Games</h3></td></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/keiki_page/javascript_games/battle/battleship.html">Battleship</a></TD></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/keiki_page/javascript_games/checkers_/checkers.html">Checkers</a></TD></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/keiki_page/javascript_games/connect4_/connect4.html">Connect 4</a></TD></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/keiki_page/javascript_games/math.html">Math Quiz</a></td></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/keiki_page/javascript_games/memory_/memory.html">Memory</a></td></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/keiki_page/javascript_games/PEG_/peg.html">Peg</a></td></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/keiki_page/javascript_games/pika.html">Pikachu</a></td></tr>
<tr><TD align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/keiki_page/javascript_games/tictactoe_/tictactoe.html">Tic Tac Toe</a></td></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/keiki_page/javascript_games/pres.html">U.S. Presidents</a></td></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/keiki_page/javascript_games/zodiac.html">Zodiac</a></td></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/games.html">Games Index</a></td></tr>
<tr><td align="center" BGCOLOR="#FF9900"><h3>Menu</h3></td></tr>
<tr><TD BGCOLOR="#FFCC00" align="center"><a href="http://www.tammyyee.com/keiki.html">Keiki Page</a></TD></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/color.html">Coloring</a></td></tr>
<tr><td align="center" BGCOLOR="#FFCC00"><a href="http://www.tammyyee.com/origami.html">Origami</a></td></tr>
<tr><TD BGCOLOR="#FFCC00" align="center"><a href="http://www.tammyyee.com/puzzle.html">Puzzles</a></td></tr>
<tr><TD BGCOLOR="#FFCC00" align="center"><a href="http://www.tammyyee.com/turtletalk.html">Turtle Talk</a></TD></tr>
<tr><TD BGCOLOR="#FFCC00" align="center"><a href="http://www.tammyyee.com/keikilinks.html">Keiki Links</a></TD></tr>
<tr><td bgcolor="#FFCC00" align="center"><a href="http://www.tammyyee.com/school.html">Schools</a></td></TR>
<tr><td bgcolor="#FFCC00" align="center"><a href="http://www.tammyyee.com/index.html">Home</a></td></TR>
</tbody></table>
<FONT face="Times New Roman,Times">
<center><h3>Checkers</h3></center>
<center>
<script language="JavaScript1.1">
<!--
version = 1.1;
// -->
</script>
<script language="JavaScript">
<!--
if (version == null)
document.write("Your browser doesn't have JavaScript 1.1 capabilities. "
+ "This checkers game script only works on Netscape 3+ and MSIE 4+.");
// -->
</script>
<script language="JavaScript1.1">
<!--
// Checkers Game
// black.gif
// gray.gif
// you1.gif -- normal piece (player/red)
// you2.gif -- highlighted piece
// you1k.gif -- kinged normal piece
// you2k.gif -- kinged highlighted piece
// me1.gif -- normal piece (computer/black)
// me2.gif -- highlighted piece
// me1k.gif -- kinged normal piece
// me2k.gif -- kinged highlighted piece
function preload() {
this.length = preload.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = new Image();
this[i].src = preload.arguments[i];
}
}
var pics = new preload("black.gif","gray.gif",
"you1.gif","you2.gif","you1k.gif","you2k.gif",
"me1.gif","me2.gif","me1k.gif","me2k.gif");
var black = -1; // computer is black
var red = 1; // visitor is red
var square_dim = 35;
var piece_toggled = false;
var my_turn = false;
var double_jump = false;
var comp_move = false;
var game_is_over = false;
var safe_from = safe_to = null;
var toggler = null;
var togglers = 0;
function Board() {
board = new Array();
for (var i=0;i<8; i++) {
board[i] = new Array();
for (var j=0;j<8;j++)
board[i][j] = Board.arguments[8*j+i];
}
board[-2] = new Array(); // prevents errors
board[-1] = new Array(); // prevents errors
board[8] = new Array(); // prevents errors
board[9] = new Array(); // prevents errors
}
var board;
Board(1,0,1,0,1,0,1,0,
0,1,0,1,0,1,0,1,
1,0,1,0,1,0,1,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,-1,0,-1,0,-1,0,-1,
-1,0,-1,0,-1,0,-1,0,
0,-1,0,-1,0,-1,0,-1);
function message(str) {
if (!game_is_over)
document.disp.message.value = str;
}
function moveable_space(i,j) {
// calculates whether it is a gray (moveable)
// or black (non-moveable) space
return (((i%2)+j)%2 == 0);
}
function Coord(x,y) {
this.x = x;
this.y = y;
}
function coord(x,y) {
c = new Coord(x,y);
return c;
}
document.write("<table border=0 cellspacing=0 cellpadding=0 width="+(square_dim*8+8)
+"<tr><td><img src='black.gif' width="+(square_dim*8+8)
+" height=4><br></td></tr>");
for(var j=0;j<8;j++) {
document.write("<tr><td><img src='black.gif' width=4 height="+square_dim+">");
for(var i=0;i<8;i++) {
if (moveable_space(i,j))
document.write("<a href='javascript:clicked("+i+","+j+")'>");
document.write("<img src='");
if (board[i][j]==1) document.write("you1.gif");
else if (board[i][j]==-1) document.write("me1.gif");
else if (moveable_space(i,j)) document.write("gray.gif");
else document.write("black.gif");
document.write("' width="+square_dim+" height="+square_dim
+" name='space"+i+""+j+"' border=0>");
if (moveable_space(i,j)) document.write("</a>");
}
document.write("<img src='black.gif' width=4 height="+square_dim+"></td></tr>");
}
document.write("<tr><td><img src='black.gif' width="+(square_dim*8+8)
+" height=4><br></td></tr></table><br>"
+"<form name='disp'><textarea name='message' wrap=virtual rows=2 cols=40></textarea><br><input "
+"type=button value=\"Start the Game Over\" onClick=\"location.href+=''\"></form>");
function clicked(i,j) {
if (my_turn) {
if (integ(board[i][j])==1) toggle(i,j);
else if (piece_toggled) move(selected,coord(i,j));
else message("First click one of your red pieces, then click where you want to move it");
} else {
message("It's not your turn yet. Hang on a sec!");
}
}
function toggle(x,y) {
if (my_turn) {
if (piece_toggled)
draw(selected.x,selected.y,"you1"+((board[selected.x][selected.y]==1.1)?"k":"")+".gif");
if (piece_toggled && (selected.x == x) && (selected.y == y)) {
piece_toggled = false;
if (double_jump) { my_turn = double_jump = false; computer(); }
} else {
piece_toggled = true;
draw(x,y,"you2"+((board[x][y]==1.1)?"k":"")+".gif");
}
selected = coord(x,y);
} else {
if ((piece_toggled) && (integ(board[selected_c.x][selected_c.y])==-1))
draw(selected_c.x,selected_c.y,"me1"+((board[selected_c.x][selected_c.y]==-1.1)?"k":"")+".gif");
if (piece_toggled && (selected_c.x == x) && (selected_c.y == y)) {
piece_toggled = false;
} else {
piece_toggled = true;
draw(x,y,"me2"+((board[x][y]==-1.1)?"k":"")+".gif");
}
selected_c = coord(x,y);
}
}
function draw(x,y,name) {
document.images["space"+x+""+y].src = name;
}
function integ(num) {
if (num != null)
return Math.round(num);
else
return null;
}
function abs(num) {
return Math.abs(num);
}
function sign(num) {
if (num < 0) return -1;
else return 1;
}
function concatenate(arr1,arr2) {
// function tacks the second array onto the end of the first and returns result
for(var i=0;i<arr2.length;i++)
arr1[arr1.length+i] = arr2[i];
return arr1;
}
function legal_move(from,to) {
if ((to.x < 0) || (to.y < 0) || (to.x > 7) || (to.y > 7)) return false;
piece = board[from.x][from.y];
distance = coord(to.x-from.x,to.y-from.y);
if ((distance.x == 0) || (distance.y == 0)) {
message("You may only move diagonally.");
return false;
}
if (abs(distance.x) != abs(distance.y)) {
message("Invalid move.");
return false;
}
if (abs(distance.x) > 2) {
message("Invalid move.");
return false;
}
if ((abs(distance.x) == 1) && double_jump) {
return false;
}
if ((board[to.x][to.y] != 0) || (piece == 0)) {
return false;
}
if ((abs(distance.x) == 2)
&& (integ(piece) != -integ(board[from.x+sign(distance.x)][from.y+sign(distance.y)]))) {
return false;
}
if ((integ(piece) == piece) && (sign(piece) != sign(distance.y))) {
return false;
}
return true;
}
function move(from,to) {
my_turn = true;
if (legal_move(from,to)) {
piece = board[from.x][from.y];
distance = coord(to.x-from.x,to.y-from.y);
if ((abs(distance.x) == 1) && (board[to.x][to.y] == 0)) {
swap(from,to);
} else if ((abs(distance.x) == 2)
&& (integ(piece) != integ(board[from.x+sign(distance.x)][from.y+sign(distance.y)]))) {
double_jump = false;
swap(from,to);
remove(from.x+sign(distance.x),from.y+sign(distance.y));
if ((legal_move(to,coord(to.x+2,to.y+2)))
|| (legal_move(to,coord(to.x+2,to.y-2)))
|| (legal_move(to,coord(to.x-2,to.y-2)))
|| (legal_move(to,coord(to.x-2,to.y+2)))) {
double_jump = true;
message("You may complete the double jump or click on your piece to stay still.");
}
}
if ((board[to.x][to.y] == 1) && (to.y == 7)) king_me(to.x,to.y);
selected = to;
if (game_over() && !double_jump) {
setTimeout("toggle("+to.x+","+to.y+");my_turn = double_jump = false;computer();",1000);
}
}
return true;
}
function king_me(x,y) {
if (board[x][y] == 1) {
board[x][y] = 1.1; // king you
draw(x,y,"you2k.gif");
} else if (board[x][y] == -1) {
board[x][y] = -1.1; // king me
draw(x,y,"me2k.gif");
}
}
function swap(from,to) {
if (my_turn || comp_move) {
dummy_src = document.images["space"+to.x+""+to.y].src;
document.images["space"+to.x+""+to.y].src = document.images["space"+from.x+""+from.y].src;
document.images["space"+from.x+""+from.y].src = dummy_src;
}
dummy_num = board[from.x][from.y];
board[from.x][from.y] = board[to.x][to.y];
board[to.x][to.y] = dummy_num;
}
function remove(x,y) {
if (my_turn || comp_move)
draw(x,y,"gray.gif");
board[x][y] = 0;
}
function Result(val) {
this.high = val;
this.dir = new Array();
}
function move_comp(from,to) {
toggle(from.x,from.y);
comp_move = true;
swap(from,to);
if (abs(from.x-to.x) == 2) {
remove(from.x+sign(to.x-from.x),from.y+sign(to.y-from.y));
}
if ((board[to.x][to.y] == -1) && (to.y == 0)) king_me(to.x,to.y);
setTimeout("selected_c = coord("+to.x+","+to.y+");piece_toggled = true;",900);
setTimeout("bak=my_turn;my_turn=false;toggle("+to.x+","+to.y+");my_turn=bak;",1000);
if (game_over()) {
setTimeout("comp_move = false;my_turn = true;togglers=0;",600);
message("Ok. It's your turn. You may make your move.");
}
return true;
}
function game_over() { // make sure game is not over (return false if game is over)
comp = you = false;
for(var i=0;i<8;i++) {
for(var j=0;j<8;j++) {
if(integ(board[i][j]) == -1) comp = true;
if(integ(board[i][j]) == 1) you = true;
}
}
if (!comp) message("You beat me!");
if (!you) message("Gotcha! Game over.");
game_is_over = (!comp || !you)
return (!game_is_over);
}
// the higher the jump_priority, the more often the computer will take the jump over the safe move
var jump_priority = 10;
function computer() {
// step one - prevent any jumps
for(var j=0;j<8;j++) {
for(var i=0;i<8;i++) {
if (integ(board[i][j]) == 1) {
if ((legal_move(coord(i,j),coord(i+2,j+2))) && (prevent(coord(i+2,j+2),coord(i+1,j+1)))) {
return true;
} if ((legal_move(coord(i,j),coord(i-2,j+2))) && (prevent(coord(i-2,j+2),coord(i-1,j+1)))) {
return true;
}
} if (board[i][j] == 1.1) {
if ((legal_move(coord(i,j),coord(i-2,j-2))) && (prevent(coord(i-2,j-2),coord(i-1,j-1)))) {
return true;
} if ((legal_move(coord(i,j),coord(i+2,j-2))) && (prevent(coord(i+2,j-2),coord(i+1,j-1)))) {
return true;
}
}
}
}
// step two - if step one not taken, look for jumps
for(var j=7;j>=0;j--) {
for(var i=0;i<8;i++) {
if (jump(i,j))
return true;
}
}
safe_from = null;
// step three - if step two not taken, look for safe single space moves
for(var j=0;j<8;j++) {
for(var i=0;i<8;i++) {
if (single(i,j))
return true;
}
}
// if no safe moves, just take whatever you can get
if (safe_from != null) {
move_comp(safe_from,safe_to);
} else {
message("You beat me!!");
game_is_over = true;
}
safe_from = safe_to = null;
return false;
}
function jump(i,j) {
if (board[i][j] == -1.1) {
if (legal_move(coord(i,j),coord(i+2,j+2))) {
move_comp(coord(i,j),coord(i+2,j+2));
setTimeout("jump("+(i+2)+","+(j+2)+");",500);
return true;
} if (legal_move(coord(i,j),coord(i-2,j+2))) {
move_comp(coord(i,j),coord(i-2,j+2));
setTimeout("jump("+(i-2)+","+(j+2)+");",500);
return true;
}
} if (integ(board[i][j]) == -1) {
if (legal_move(coord(i,j),coord(i-2,j-2))) {
move_comp(coord(i,j),coord(i-2,j-2));
setTimeout("jump("+(i-2)+","+(j-2)+");",500);
return true;
} if (legal_move(coord(i,j),coord(i+2,j-2))) {
move_comp(coord(i,j),coord(i+2,j-2));
setTimeout("jump("+(i+2)+","+(j-2)+");",500);
return true;
}
}
return false;
}
function single(i,j) {
if (board[i][j] == -1.1) {
if (legal_move(coord(i,j),coord(i+1,j+1))) {
safe_from = coord(i,j);
safe_to = coord(i+1,j+1);
if (wise(coord(i,j),coord(i+1,j+1))) {
move_comp(coord(i,j),coord(i+1,j+1));
return true;
}
} if (legal_move(coord(i,j),coord(i-1,j+1))) {
safe_from = coord(i,j);
safe_to = coord(i-1,j+1);
if (wise(coord(i,j),coord(i-1,j+1))) {
move_comp(coord(i,j),coord(i-1,j+1));
return true;
}
}
} if (integ(board[i][j]) == -1) {
if (legal_move(coord(i,j),coord(i+1,j-1))) {
safe_from = coord(i,j);
safe_to = coord(i+1,j-1);
if (wise(coord(i,j),coord(i+1,j-1))) {
move_comp(coord(i,j),coord(i+1,j-1));
return true;
}
} if (legal_move(coord(i,j),coord(i-1,j-1))) {
safe_from = coord(i,j);
safe_to = coord(i-1,j-1);
if (wise(coord(i,j),coord(i-1,j-1))) {
move_comp(coord(i,j),coord(i-1,j-1));
return true;
}
}
}
return false;
}
function possibilities(x,y) {
if (!jump(x,y))
if (!single(x,y))
return true;
else
return false;
else
return false;
}
function prevent(end,s) {
i = end.x;
j = end.y;
if (!possibilities(s.x,s.y))
return true;
else if ((integ(board[i-1][j+1])==-1) && (legal_move(coord(i-1,j+1),coord(i,j)))) {
return move_comp(coord(i-1,j+1),coord(i,j));
} else if ((integ(board[i+1][j+1])==-1) && (legal_move(coord(i+1,j+1),coord(i,j)))) {
return move_comp(coord(i+1,j+1),coord(i,j));
} else if ((board[i-1][j-1]==-1.1) && (legal_move(coord(i-1,j-1),coord(i,j)))) {
return move_comp(coord(i-1,j-1),coord(i,j));
} else if ((board[i+1][j-1]==-1.1) && (legal_move(coord(i+1,j-1),coord(i,j)))) {
return move_comp(coord(i+1,j-1),coord(i,j));
} else {
return false;
}
}
function wise(from,to) {
i = to.x;
j = to.y;
n = (j>0);
s = (j<7);
e = (i<7);
w = (i>0);
if (n&&e) ne = board[i+1][j-1]; else ne = null;
if (n&&w) nw = board[i-1][j-1]; else nw = null;
if (s&&e) se = board[i+1][j+1]; else se = null;
if (s&&w) sw = board[i-1][j+1]; else sw = null;
eval(((j-from.y != 1)?"s":"n")+((i-from.x != 1)?"e":"w")+"=0;");
if ((sw==0) && (integ(ne)==1)) return false;
if ((se==0) && (integ(nw)==1)) return false;
if ((nw==0) && (se==1.1)) return false;
if ((ne==0) && (sw==1.1)) return false;
return true;
}
message("You may begin! Select a piece to move.");
my_turn = true;
// -->
</script><P>
THIS SCRIPT BROUGHT TO YOU BY <a href="http://www.javafile.com">JAVAFILE.COM</a>
<hr>
</center>
<br clear="left">
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

View file

@ -0,0 +1,24 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Index of /keiki_page/javascript_games/checkers_</TITLE>
</HEAD>
<BODY>
<H1>Index of /keiki_page/javascript_games/checkers_</H1>
<PRE><IMG SRC="/icons/blank.gif" ALT=" "> <A HREF="?N=D">Name</A> <A HREF="?M=A">Last modified</A> <A HREF="?S=A">Size</A> <A HREF="?D=A">Description</A>
<HR>
<A HREF="/keiki_page/javascript_games/"><IMG SRC="/icons/back.gif" ALT="[DIR]"></A> <A HREF="/keiki_page/javascript_games/">Parent Directory</A> 09-Apr-2002 10:14 -
<A HREF="black.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="black.gif">black.gif</A> 26-Jan-2001 13:16 1k
<A HREF="checkers.html"><IMG SRC="/icons/text.gif" ALT="[TXT]"></A> <A HREF="checkers.html">checkers.html</A> 14-May-2001 09:22 16k
<A HREF="gray.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="gray.gif">gray.gif</A> 26-Jan-2001 13:16 1k
<A HREF="me1.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="me1.gif">me1.gif</A> 26-Jan-2001 13:16 1k
<A HREF="me1k.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="me1k.gif">me1k.gif</A> 26-Jan-2001 13:16 1k
<A HREF="me2.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="me2.gif">me2.gif</A> 26-Jan-2001 13:16 1k
<A HREF="me2k.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="me2k.gif">me2k.gif</A> 26-Jan-2001 13:16 1k
<A HREF="you1.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="you1.gif">you1.gif</A> 26-Jan-2001 13:16 1k
<A HREF="you1k.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="you1k.gif">you1k.gif</A> 26-Jan-2001 13:16 1k
<A HREF="you2.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="you2.gif">you2.gif</A> 26-Jan-2001 13:16 1k
<A HREF="you2k.gif"><IMG SRC="/icons/image2.gif" ALT="[IMG]"></A> <A HREF="you2k.gif">you2k.gif</A> 26-Jan-2001 13:16 1k
</PRE><HR>
<ADDRESS>Apache/1.3.34 Server at www.tammyyee.com Port 80</ADDRESS>
</BODY></HTML>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB