Juego PONG
Publicado por Pernilongo (1 intervención) el 21/12/2002 20:55:00
hola:
Tengo un problema que no consigo que la pelota colisione con la pala en el código que escribo a continuación.
Agradezco cualquier ayuda ya que no me acude nada más.
Gracias
Pernilongo
código:
<HTML>
<HEAD>
<TITLE>Posicionamiento</TITLE>
<SCRIPT>
<!--
var posicionx=20
var posiciony=50
function movePala(){
var xpos = window.event.x;
//if ((ypos >= 50) && (ypos <= 230))
pala.style.posLeft = xpos;
}
function MoverBola() {
var xp = bola.style.posLeft;
var yp = bola.style.posTop;
var colision = document.elementFromPoint(xp,yp);
bola.style.pixelLeft = parseInt(bola.style.pixelLeft) + posicionx;
bola.style.pixelTop = parseInt(bola.style.pixelTop) - posiciony;
if (bola.style.pixelTop>640){
bola.style.pixelTop =640
bola.style.pixelLeft=1000
location.reload(true);
}
if(bola.style.pixelTop<15){
posiciony=posiciony*-1
}
if(bola.style.pixelLeft>1080){
posicionx=posicionx*-1
}
if(bola.style.pixelLeft<5){
posicionx=posicionx*-1
}
setTimeout('MoverBola()',100);
}
//-->
</SCRIPT>
<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)=
Tengo un problema que no consigo que la pelota colisione con la pala en el código que escribo a continuación.
Agradezco cualquier ayuda ya que no me acude nada más.
Gracias
Pernilongo
código:
<HTML>
<HEAD>
<TITLE>Posicionamiento</TITLE>
<SCRIPT>
<!--
var posicionx=20
var posiciony=50
function movePala(){
var xpos = window.event.x;
//if ((ypos >= 50) && (ypos <= 230))
pala.style.posLeft = xpos;
}
function MoverBola() {
var xp = bola.style.posLeft;
var yp = bola.style.posTop;
var colision = document.elementFromPoint(xp,yp);
bola.style.pixelLeft = parseInt(bola.style.pixelLeft) + posicionx;
bola.style.pixelTop = parseInt(bola.style.pixelTop) - posiciony;
if (bola.style.pixelTop>640){
bola.style.pixelTop =640
bola.style.pixelLeft=1000
location.reload(true);
}
if(bola.style.pixelTop<15){
posiciony=posiciony*-1
}
if(bola.style.pixelLeft>1080){
posicionx=posicionx*-1
}
if(bola.style.pixelLeft<5){
posicionx=posicionx*-1
}
setTimeout('MoverBola()',100);
}
//-->
</SCRIPT>
<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)=
Valora esta pregunta


0