<html>
<style>
#playingArea
{
position: absolute;
top: 1;
left: 1;
border: 5px solid black;
width: 750;
height: 720;
z-index: 2;
}
#basket
{
position: absolute;
top: 650;
left: 228;
width: 64;
height: 16;
}
</style>
<script type="text/javascript" language="Javascript">
var basket;
var basketLeft = 228;
function keyListener(e)
{
e = window.event;
if (e.keyCode==37 && basketLeft > 0)
{
basketLeft -= 8;
basket.style.left = basketLeft + 'px' ;
}
if (e.keyCode==39 && basketLeft < 436)
{
basketLeft += 8;
basket.style.left = basketLeft + 'px' ;
}
}
function init()
{
basket=document.getElementById('basket');
document.onkeydown=keyListener;
fall();
}
grphcs=new Array(5)
Image0=new Image();
Image0.src=grphcs[0]="1.gif";
Image1=new Image();
Image1.src=grphcs[1]="2.gif";
Image2=new Image();
Image2.src=grphcs[2]="3.gif";
Image3=new Image();
Image3.src=grphcs[3]="4.gif";
Image4=new Image();
Image4.src=grphcs[4]="5.gif";
Amount=5;
Ypos=new Array();
Xpos=new Array();
Speed=new Array();
Step=new Array();
Cstep=new Array();
var Stop=false;
for(i=0;i<Amount;i++)
{
var P=Math.floor(Math.random()*grphcs.length);
rndPic=grphcs[P];
document.write('<img id="si'+i+'" src="'+rndPic+'"style="position:absolute;top:0px;left:0px">');
}
WinHeight=document.body.clientHeight;
WinWidth=document.body.clientWidth;
for(i=0;1<Amount;i++)
{
Ypos[i]=Math.round(Math.random()*WinHeight);
Xpos[i]=Math.round(Math.random()*WinWidth);
Speed[i]=Math.random()*5+3;
Cstep[i]=0;
Step[i]=Math.random()*0.1+0.05;
}
function fall()
{
if(Stop)
{clear();
return;
}
var WinHeight=document.body.clientHeight-100;
var WinWidth=document.body.clientWidth-500;
for(i=0;i<Amount;i++)
{
sy=Speed[i]*Math.sin(90*Math.PI/180);
sx=Speed[i]*Math.cos(Cstep[i]);
Ypos[i]+=sy;
Xpos[i]+=sx;
if(Ypos[i]>WinHeight)
{
Ypos[i]=60;
Xpos[i]=Math.round(Math.random()*WinWidth);
Speed[i]=Math.random()*5+3;
}
else
{
document.getElementById("si"+i).style.left=Math.min(WinWidth,Xpos[i])-200;
document.getElementById("si"+i).style.top=Ypos[i];
}
Cstep[i]+=Step[i];
}
setTimeout('fall()',20);
}
setTimeout("Stop=true",30000);
function clear()
{
for(i=0;i<Amount;i++)
document.getElementById("si"+i).style.display='none';
}
</script>
<body onload="init()";>
<div id= "basket">
<img src= "basket.jpg">
</div>
<div id= "playingArea">
</div>
</body>
</html>
i need to have the score added here every time the basket catches fruits..how? pls help! thank you! :(