Site hosted by Angelfire.com: Build your free website today!
'); write(''); write("

This game is a JavaScript-powered game. Your browser doesn't support some of the elements of JavaScript that are required to make it work.

Internet Explorer users should upgrade to version 4. Netscape Navigator users can upgrade to version 3."); } if(document.images) { window.onerror=null; var now = new Date(); var seed = now.getTime() % 0xffffffff; var randNum = new Array(); var no = 0; var cl_1 = ''; var cl_2 = ''; var clicks = 0; var user = 'u'; var user_score = 0; var jenny = 'j'; var jenny_score = 0; var cur_pl = user; var pairs = 0; var choice = ''; var cheat = false; var free = false; var klickat = 0; //ARRAY OF IMAGE NAMES var imgArray = new Array('a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'h1', 'h2', 'i1', 'i2', 'j1', 'j2'); } //TURNING IMAGES function img_swap(nowImage, nextImage) { document [nowImage].src = nextImage; } function turn_Img(imgName) { document.images[imgName].src = eval(imgName + '_on.src'); } function reset_Img() { document.images[cl_1].src = mem.src; document.images[cl_2].src = mem.src; } function clear_Img() { document.images[cl_1].src = blank.src; document.images[cl_2].src = blank.src; } //SCORE HANDLING function winner() { if(user_score == jenny_score) { if (confirm('It is a draw!\n\nPlay again?')) { location.href = script_url } } if(user_score > jenny_score) { if (confirm('Excellent! You beat Champ by ' + user_score + ' - ' + jenny_score + ' .\n\nPlay again?')) { location.href = script_url } } if(jenny_score > user_score) { if (confirm(jenny_score + ' - ' + user_score + ' to Champ!\n\nPlay again?')) { location.href = script_url } } } function setScore() { if(cur_pl == user) { user_score++; document.scoreboard.player1.value = user_score; if(user_score >= 2) { cheat = true } } else { jenny_score++; klickat = 0; document.scoreboard.player2.value = jenny_score; cheat = false; } if(pairs == imgArray.length / 2) { setTimeout('winner()', 1000) } } function pairCheck() { if(cl_1.charAt(0) == cl_2.charAt(0)) { pairs++; for(i = 0; i < imgArray.length; i++) { if(imgArray[i] == cl_1 || imgArray[i] == cl_2) { imgArray[i] = 'taken'; } } setTimeout('clear_Img()', 1000); return true; } else { return false; } } //CLICK HANDLING function makeMove() { if(cl_1 != cl_2) { turn_Img(cl_2); if(pairCheck()) { setTimeout('clear_Img()', 1000); clicks = 0; setScore(); setTimeout('setFree()', 1000); if(cur_pl == jenny) { setTimeout('handleClick("")', 2000); } } else { setTimeout('reset_Img()', 1000); clicks = 0; klickat++; if(cur_pl == user) { cur_pl = jenny; setTimeout('handleClick(" ")', 2000); } else { cur_pl = user; setTimeout('setFree()', 1000); } } } else { if(cur_pl == jenny) { handleClick(''); } else { free = true; } } } function setFree() { free = true } function handleClick(namn) { if(pairs < imgArray.length / 2) { if(clicks == 0) { if(cur_pl == user) { if(notClicked(namn)) { free = false; cl_1 = namn; clicks++; turn_Img(cl_1); free = true; } } else { if(reply()) { cl_1 = choice; clicks++; turn_Img(cl_1); setTimeout('handleClick("")', 1000); } } } else { if(cur_pl == jenny) { reply(); cl_2 = choice; makeMove(); } else { if(notClicked(namn)) { free = false; cl_2 = namn; makeMove(); } } } } } function notClicked(elm) { var status = false; for(i = 0; i < imgArray.length; i++) { if(imgArray[i] == elm) { status = true; } } return status; } function reply() { rand(imgArray.length); while((imgArray[no]) == 'taken') { rand(imgArray.length); } if((cheat == true && clicks == 1) || (klickat == 7)) { if(cl_1.charAt(1) == '2') { choice = cl_1.charAt(0) + '1'; } else { choice = cl_1.charAt(0) +'2'; } } else { choice = imgArray[no]; } return true; } function rand(n) { seed = (0x015a35 * seed) % 0x7fffffff; no = (seed >> 16) % n; } function get_random() { rand(imgArray.length); while(no == randNum[no]) { rand(imgArray.length); } randNum[no] = no; return no; } //--> Champ's Memory Match

Champ's Memory Match

This game is a JavaScript-powered game. Your browser doesn't support some of the elements of JavaScript that are required to make it work.

Internet Explorer users should upgrade to version 4 for Windows or 3 for Macintosh. Netscape Navigator users can upgrade to version 3.


JavaScript © 1998 Adam Kalsey
Game Graphics © 1999