<html>
<body>
<div style="position:absolute;left:500px;">
<input type="button" id="button1" style = "position:absolute;left:100px;top:0px;" value="-" onclick="my_func()">
<input type="button" id="button2" style = "position:absolute;left:100px;top:50px;" value="-" onclick="my_func()">
<input type="button" id="button3" style = "position:absolute;left:50px;top:25px;" value="-" onclick="my_func()">
<input type="button" id="button4" style = "position:absolute;left:150px;top:25px;" value="-" onclick="my_func()">
</div>
<div style="position:absolute;left:500px;top:150px;" id="result">
</div>
<script>
var counter = 0;
var timerId = setInterval(function() {
rn = Math.floor(Math.random()*4);
if (rn == 0)
{
document.getElementById("button1").value ="+";
}
else
{
document.getElementById("button1").value ="-";
}
if (rn == 1)
{
document.getElementById("button2").value ="+";
}
else
{
document.getElementById("button2").value ="-";
}
if (rn == 2)
{
document.getElementById("button3").value ="+";
}
else
{
document.getElementById("button3").value ="-";
}
if (rn == 3)
{
document.getElementById("button4").value ="+";
}
else
{
document.getElementById("button4").value ="-";
}
counter = counter - 1;
if (counter < -1) document.getElementById("result").innerHTML ="вы проиграли";
if (counter > 5) document.getElementById("result").innerHTML ="вы выиграли";
},1000);
function my_func()
{
if (document.getElementById("button1").value =="+") counter = counter + 2 ;
if (document.getElementById("button2").value =="+") counter = counter + 2 ;
if (document.getElementById("button3").value =="+") counter = counter + 2 ;
if (document.getElementById("button4").value =="+") counter = counter + 2 ;
}
</script>
</body>
</html>
|