index = 0 score = 0 correct = 0 percentage = 0 quitearly = 0 hitreport = score+" ducks hit" boxes=new Array ("a","b","c","d") function swapImage(imgName,newSrc) { oldSrc=document.images[imgName].src oldImg=imgName document.images[imgName].src=newSrc } function swapBack() { document.images[oldImg].src=oldSrc } function storeresult() { setCookieEz("index",index); setCookieEz("correct",correct); setCookieEz("percentage",percentage); setCookieEz("hitreport",hitreport); setCookieEz("quitearly",quitearly); } function quit() { if (confirm("Are you sure you want to quit?")) {alert("The correct answer was actually \'"+document.duck[correctanswer].value+"\'!") quitearly=1 storeresult() location.href="continue.html"} } function fire() { duck.movie.TGotoFrame("_level0/explode",1);duck.movie.TPlay("_level0/explode"); } function feedback() { percentage = (Math.round(100*(correct/index))) document.duck.status.value = (15-index)+" shots remaining!" if (index==14) {document.duck.status.value = "Your final shot!"} if (index==15) {document.duck.status.value = "Game complete!"} hitreport = score+" ships hit" if (score==1) {hitreport = score+" ship hit"} shotreport = index+" shots" if (index==1) {shotreport = index+" shot"} document.duck.shootingstatus.value = percentage+"% - "+correct+" correct from "+shotreport document.duck.hitstatus.value = hitreport } function wrong() { duck.movie.TGotoFrame("_level0/feedback",3); } function moveon_correct() { document[index+2].src = "../images/duckhit1.gif" score++ feedback() if (index==15) {storeresult(); location.href="continue.html"; alert("Excellent - game complete.")} else{ response=Math.round(4 * Math.random()) if (response==0) {alert("Excellent answer!");} if (response==1) {alert("Well done - great answer");} if (response==2) {alert("Correct - and you got the ship!");} if (response==3) {alert("Good answer - continue on...");} if (response==4) {alert("Marvellous answer - well done!");} play()} } function moveon_correctmiss() { document[index+2].src = "../images/correct.gif" feedback() if (index==15) {storeresult(); location.href="continue.html"; alert("A good final answer, but you didn't hit the target!")} else { response=Math.round(2 * Math.random()) if (response==0) {alert("Good answer - a pity you missed the target!");} if (response==1) {alert("Correct answer - but no ship!");} if (response==2) {alert("Well answered, but a bad shot. ");} play()} } function moveon_miss() { document[index+2].src = "../images/wrong.gif" feedback() if (index==15) {storeresult(); location.href="continue.html"; alert("Incorrect final answer. You should have chosen "+document.duck[correctanswer].value+".")} else { response=Math.round(4 * Math.random()) if (response==0) {alert("Incorrect - you should have chosen: "+document.duck[correctanswer].value+".");} if (response==1) {alert("Sorry - the correct answer was: "+document.duck[correctanswer].value+".");} if (response==2) {alert("The ship sails away! The answer was: "+document.duck[correctanswer].value+".");} if (response==3) {alert("Not a good choice - the answer was: "+document.duck[correctanswer].value+".");} if (response==4) {alert("Unlucky - wrong answer. It was actually: "+document.duck[correctanswer].value+".");} play()} } function start() { play() } function play() { duck.movie.LoadMovie(0, "../armadashoot.swf"); duck.movie.TGotoFrame("_level0",0); duck.movie.TPlay("target"); duck.movie.TGotoFrame("_level0/feedback",0); duck.movie.play(); questionchoice=Math.round((availablegames-1) * Math.random()) document.duck.questionbox.value = game[questionchoice][index][0] document.duck.author.value = "Question by "+game[questionchoice][index][5] document.duck.a.value = "" document.duck.b.value = "" document.duck.c.value = "" document.duck.d.value = "" count=1 doit() } function doit() {for(n=1; n<=500; n++){ randnum=Math.round(3 * Math.random()) if (document.duck[boxes[randnum]].value == "") { document.duck[boxes[randnum]].value = game[questionchoice][index][count] if(count==1) {correctanswer=[boxes[randnum]]} count++}}} function checkanswer(x) { index++ if (x==correctanswer) { correct++ fire() } else { wrong() } }