Page is a not externally linkable
cybernoob - 11:42 am on May 4, 2012 (gmt 0)
i cant get the time to tick down to 0 from 30 seconds, it only ticks down to 29, and im assuming the global variable never changes from 30, so each time the clock "ticks" it goes down to 29 from 30, effectively staying at 29 indefinitely
----------------------------------------
<!DOCTYPE html>
<html lang="en">
<head>
<title>assignment 6</title>
<style type="text/css">
body {
color:#000000;
background-color:#FFFFFF;
}
a { color:#0000FF; }
a:visited { color:#800080; }
a:hover { color:#008000; }
a:active { color:#FF0000; }
#gameContainer{border:solid;width:50%;height:200px; margin-left:25%; margin-right:25%;}
#buttonBox{border:solid; margin-left:20%; margin-top:5px;float:left;}
#emptySpace{float:left; margin-top:5px; width:10%; }
#statsBox{border:solid; margin-top:5px; float:left; margin-right:20%;}
</style>
<script type="text/javascript">
/*
var time=30;
var score=0;
var highScore=0;
var play=false;
function play(time,score,highScore,play){
play=true;
time=30;
score=0;
}
function buttonPress(score){
score+=1;
}
*/
var time=30;
var play=true;
//var t=setInterval(clock(),1000);
function startClock(){
var t=setInterval(clock(time,play),1000)
}
function clock(time,play){
//alert("hi");
if(time>0){
time=time-1;
document.getElementById("time").innerHTML=time;
return time;
}
else{
clearInterval(t);
play=false;
return;
}
//setTimeout(alert("hi"),1000);
}
</script>
</head>
<body>
<div id="gameContainer">
<div id="game">
<div id="buttonBox"><button id="button" onclick="buttonPress();">Click Me!</button></div>
<div id="emptySpace"></div>
<div id="statsBox">
Time:<div id="time">30</div>
Score:<div id="score">0</div>
High Score:<div id="highScore">0</div>
<button id="play" onclick="startClock();">play!</button>
</div>
</div>
</div>
</body>
</html>