<!DOCTYPE html>
<html>
<head>
<meta name="keywords" content="photography,art,design,addison,photo"/>
<meta name="description" content="I take photos."/>
<meta charset="utf-8" />
<title>Addison Bean | Photography & Design</title>
<link rel="stylesheet" type="text/css" href="css/abd.css"/>
<link rel="stylesheet" type="text/css" href="css/gsquares.dark.css"/>
<!--[if IE]>
<style type="text/css>
li.menu {
font-family:Trebuchet MS, Helvetica, sans-serif;
}
</style>
<![endif]-->
<!--favicon won't show up-->
<link rel="Shortcut Icon" href="favicon.ico"/>
<style type="text/css">
#scores {
color: #fff;
}
</style>
</head>
<body>
<div id="container"><br />
<div id="scores">
<div id="player1_score"><p>Player 1: 0</p></div>
<div id="player2_score"><p>Player 2: 0</p></div>
</div>
<button id="player1_go">Player 1</button>
<button id="player2_go">Player 2</button>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
GAMESTATE = {
answer: Math.floor(Math.random()*11),
player1_score: 0,
player2_score: 0
}
console.log(GAMESTATE.answer);
$('#player1_go').click(function(event){
console.log(GAMESTATE.answer);
var player1_answer = prompt('Guess a number between 0 and 10.','');
if(player1_answer == GAMESTATE.answer){
alert('right on dude!');
GAMESTATE.player1_score += 1;
updateScores();
} else {
alert('you got it wrong bro, the answer is: ' + GAMESTATE.answer);
}
GAMESTATE.answer = Math.floor(Math.random()*11),
event.preventDefault();
});
$('#player2_go').click(function(event){
console.log(GAMESTATE.answer);
var player1_answer = prompt('PLAYER 1: Guess a number between 0 and 10.','');
var player2_answer = prompt('PLAYER 2: Guess a number between 0 and 10.','');
if(player1_answer == GAMESTATE.answer){
alert('PLAYER 1: right on dude!');
GAMESTATE.player1_score += 1;
updateScores();
} else {
alert('PLAYER 1: you got it wrong bro, the answer is: ' + GAMESTATE.answer);
}
if(player2_answer == GAMESTATE.answer){
alert('PLAYER 2: right on dude!');
GAMESTATE.player2_score += 1;
updateScores();
} else {
alert('PLAYER 2: you got it wrong bro, the answer is: ' + GAMESTATE.answer);
}
GAMESTATE.answer = Math.floor(Math.random()*11),
event.preventDefault();
});
updateScores = function(){
$('#player1_score').html('<p>Player 1: ' + GAMESTATE.player1_score + '</p>');
$('#player2_score').html('<p>Player 2: ' + GAMESTATE.player2_score + '</p>');
}
});
</script>
</body>
</html>