Act3


 <!DOCTYPE html>


<html>


<head>




<meta name="viewport" content="width=device-width, initial-scale=1">


<title> Counting Drill Game </title>


<style>


      


body {


max-width: 200px;


min-width: 580px;


 }


fieldset {


background-color: white;


margin: auto;


align-content: center;


padding: 60px;


width: 100px;


height: 600px;


}




buon {


background-color: darkcyan;


color: darkcyan;


border-radius: 10px;


width: 100px;


height: 50px;


}




.demo{


background-color:white;


color:darkgrey;


font-size: 20px;


}




html {


font-family: arial;


margin-left: 4%;


background-color: darkcyan;


    }




</style>


</head>








<body>




<h1> Counting Drill Game</h1>


<p> Count how many square on the screen! </p>




<fieldset>


<canvas id="myCanvas" width="900" height="200" style="border:none;">


</canvas>




<p id="demo" class="demo"> </p>


<label> How many shapes do you see? </label>


<input type="number" id="answer"> </input>




<button id="eraser" onclick="eraser()" > Next </button>


<button id="compare" onclick="compare();eraser()" > Answer </button>


<p> <b> Score: </b> </p> <div id="myScore"> 0 </div>


</fieldset>






<script type = "text/javascript">


var score=0;


function colors()


{




var canvas = document.getElementById("myCanvas");


var ctx = canvas.getContext("2d");


x=Math.round(Math.random()*10+1);


for(f=1; f<=x;f++)


{


switch(f)


{




case 1: c="#F86D66"; break


case 2: c="#F89766";break


case 3: c="#F8CE66"; break


case 4: c="#66F86A";break


case 5: c="#66B8F8"; break


case 6: c="#8766F8"; break


case 7: c="#8766F8"; break


case 8: c="#00FFE8"; break


case 9: c="#B48E4B"; break


case 10: c="#8B8985"; break


}






document.getElementById("compare").style.backgroundColor=c;


document.getElementById("compare").style.color="white";


document.getElementById("compare").style.width="200px";


document.getElementById("compare").style.height="100px";


document.getElementById("eraser").style.backgroundColor=c;


document.getElementById("eraser").style.color="white";


document.getElementById("eraser").style.width="200px";


document.getElementById("eraser").style.height="100px";




ctx.font = "25px calibri";


ctx.fillStyle=c;


ctx.fillRect(10+f*100,100, 50, 50);


}


}




function eraser()


{


var canvas = document.getElementById("myCanvas");


var ctx = canvas.getContext("2d");


ctx.clearRect(0,0,1200,300); 


colors();


}


colors()


function compare()


{




ans=document.getElementById("answer").value


if (ans==x) {


score += 1;




document.getElementById("myScore").innerHTML=score.toString()


document.getElementById("demo").innerHTML="Bravo! Your answer is correct!"


}


else {


document.getElementById("demo").innerHTML="Sorry, but your answer is wrong."


}


}




</script>


</body>


</html>

Comments

Popular posts from this blog

ACT2

ACT 1