1
Computer Game Development - The Indie Alley / Re: Javascript Random Number Guessing Game Project
« on: November 09, 2011, 05:20:40 PM »
This is all the Code i have so far. But im confused on how to do these
e. A textbox to display the number of guesses in the current round.
f. A textbox to display the number of rounds played.
g. A textbox to display the number of rounds won.
h. A textbox to display the average number of tries it takes the user to guess the number correctly.
I'll keep working on it but id be glad if any of you have any tips/suggestions.
<html>
<head>
<title> Project 3 </title>
<script type="text/Javascript">
<!-- created by Alejandro Suero -->
var numRand = 0
function startGame()
{numRand=Math.floor(Math.random()*101)
alert("Im thinking of a number between 1-100")
}
function checkGuess(frmGuess)
{ if(frmGuess.txtGuess.value == numRand){
alert("Winner");
}
else if(frmGuess.txtGuess.value < numRand) {
alert("Too Low")
}
else if(frmGuess.txtGuess.value > numRand) {
alert("Too High")
}
}
</script>
</head>
<body>
<form name=frmGuess>
<center><input type=button value="start game" onClick="startGame()"></center>
<input type="text" name=txtGuess > Enter Guess
<input type=button value="Guess" onClick="checkGuess(frmGuess)">
</form>
</body>
</html>
e. A textbox to display the number of guesses in the current round.
f. A textbox to display the number of rounds played.
g. A textbox to display the number of rounds won.
h. A textbox to display the average number of tries it takes the user to guess the number correctly.
I'll keep working on it but id be glad if any of you have any tips/suggestions.
<html>
<head>
<title> Project 3 </title>
<script type="text/Javascript">
<!-- created by Alejandro Suero -->
var numRand = 0
function startGame()
{numRand=Math.floor(Math.random()*101)
alert("Im thinking of a number between 1-100")
}
function checkGuess(frmGuess)
{ if(frmGuess.txtGuess.value == numRand){
alert("Winner");
}
else if(frmGuess.txtGuess.value < numRand) {
alert("Too Low")
}
else if(frmGuess.txtGuess.value > numRand) {
alert("Too High")
}
}
</script>
</head>
<body>
<form name=frmGuess>
<center><input type=button value="start game" onClick="startGame()"></center>
<input type="text" name=txtGuess > Enter Guess
<input type=button value="Guess" onClick="checkGuess(frmGuess)">
</form>
</body>
</html>