x.fillStyle='white'; x.font='bold 10px Arial'; x.fillText('10',px+14,py+39); } function j(){p.vy=-11; p.kick=12;} setInterval(()=>{ f++; if(p.kick>0)p.kick--; p.vy+=0.6; p.y+=p.vy; if(f%75==0){o.push({x:360,h:80+Math.random()*140}); if(Math.random()>0.4)balls.push({x:375,y:470-Math.random()*100,r:8,t:false})} for(let b of o){b.x-=5; if(p.x+30>b.x&&p.x520-b.h)location.reload()} for(let b of balls){b.x-=5; if(!b.t&&Math.hypot(p.x+25-b.x,p.y+20-b.y)<28){b.t=true;score+=10; p.kick=15;}} o=o.filter(b=>b.x>-30); balls=balls.filter(b=>b.x>-30&&!b.t); if(p.y>480){p.y=480;p.vy=0} x.clearRect(0,0,360,600); x.fillStyle='#87CEEB'; x.fillRect(0,0,360,520); x.fillStyle='#2ecc71'; x.fillRect(0,520,360,80); x.fillStyle='white'; x.font='16px Arial'; x.fillText('SKORE: '+score,10,20); for(let b of o){x.fillStyle='#e74c3c'; x.fillRect(b.x,520-b.h,25,b.h)} for(let b of balls){x.beginPath(); x.arc(b.x,b.y,b.r,0,6.28); x.fillStyle='white'; x.fill(); x.strokeStyle='black'; x.stroke()} drawCapy(p.x,p.y); },16); c.ontouchstart=j; onclick=j;