cgwalls
09-26-2008, 01:37 AM
Hey everyone well i'm working on this super simple javascript game where when you press a key a player gets a point and there's two players. the game was working perfectly until i had to restore my computer. For some reason it won't work anymore maybe it's because norton came preloaded on the computer? So i was hoping you guys could see if there's anything wrong with it.
<html>
<head>
<title>Score Battle</title>
<style>
#playingArea{
position: absolute;
border: 1px solid black;
width: 500;
height: 400;
background-color: rgb(192,192,192);
}
#player1{
position: absolute;
top: 50;
left: 180;
}
#player2{
position: absolute;
top: 50;
left: 280;
}
#div1{
position: absolute;
top: 100;
left: 200;
}
#div2{
position: absolute;
top: 100;
left: 300;
}
#won{
position: absolute;
top: 150;
left: 150;
}
</style>
<script type="text/javascript">
var a = 0;
var b = 0;
function add1() {
a += 1;
document.getElementById("div1").innerHTML = a;
}
function add2() {
b += 1;
document.getElementById("div2").innerHTML = b;
}
function ProcessKeypress(e)
{
if (e.keyCode) keycode=e.keyCode;
else keycode=e.which;
ch=String.fromCharCode(keycode);
if(ch=='q') add1();
else if(ch=='p') add2();
}
</script>
</head>
<body onKeyDown="ProcessKeypress(event);">
<div id="playingArea">
Controls:<br />Player 1: Q<br />Player 2: P
<div id="player1">
Player 1
</div>
<div id="player2">
Player 2
</div>
<div id="div1">
0
</div>
<div id="div2">
0
</div>
</div>
</body>
</html>
<html>
<head>
<title>Score Battle</title>
<style>
#playingArea{
position: absolute;
border: 1px solid black;
width: 500;
height: 400;
background-color: rgb(192,192,192);
}
#player1{
position: absolute;
top: 50;
left: 180;
}
#player2{
position: absolute;
top: 50;
left: 280;
}
#div1{
position: absolute;
top: 100;
left: 200;
}
#div2{
position: absolute;
top: 100;
left: 300;
}
#won{
position: absolute;
top: 150;
left: 150;
}
</style>
<script type="text/javascript">
var a = 0;
var b = 0;
function add1() {
a += 1;
document.getElementById("div1").innerHTML = a;
}
function add2() {
b += 1;
document.getElementById("div2").innerHTML = b;
}
function ProcessKeypress(e)
{
if (e.keyCode) keycode=e.keyCode;
else keycode=e.which;
ch=String.fromCharCode(keycode);
if(ch=='q') add1();
else if(ch=='p') add2();
}
</script>
</head>
<body onKeyDown="ProcessKeypress(event);">
<div id="playingArea">
Controls:<br />Player 1: Q<br />Player 2: P
<div id="player1">
Player 1
</div>
<div id="player2">
Player 2
</div>
<div id="div1">
0
</div>
<div id="div2">
0
</div>
</div>
</body>
</html>