Comunidad de diseño web y desarrollo en internet online

codigo con accel y decrease...

Citar            
MensajeEscrito el 23 Feb 2006 09:49 pm
he creado un codigo para un simbolo esferico de altura 20 y anchura 20, la idea es que cuando pasas el raton rozandolo pues este incremente su velocidad dependiendo del angulo pero este codigo no me funciona :cry: os pediria que me ayudarais pofravorrrrr, hay algunos aspectos un poco inventados, y pongo death = false porque queria terminar el codigo haciendo que cuando pulses el simbolo este desaparezca. os pongo el codigo:

(EL PRINCIPAL PROBLEMA QUE ME DA ES QUE NO ME ACEPTA EL CORCHETE FINAL DE LO DE SI COINCIDEN LA X Y LA Y DEL OBJETO Y EL RATON, QUE ES EL CORCHETE SITUADO AL FINAAAAAAAAL DEL TODO, EL CUAL ME DICE QUE NO PINTA NADA, CUANDO LO QUE QUIERO ES CERRAR LA FUNCION DE CUANDO COINCIDAN ESTAS CIRCUNSTANCIAS...) GRACIAS POR AYUDARME POR ADELANTADO!!


onClipEvent (load){
dead = false;
speedR = 0;
speedL = 0;
speedD = 0;
speedU = 0;
top_speed = 10;
decay = 0.1;
accel_x = 0.25 * (Math.cos(Math.cos((_root._xmouse - this._x)*0.1));
if (accel_x<0) {
accel_x = -accel_x }
accel_y = 0.25 * (Math.sin(Math.sin((_root._ymouse - this._y)*0.1));
if (accel_y<0) {
accel_y = -accel_y }
}
onClipEvent (mouseMove) {
if (this.hitTest(_root._xmouse, _root._ymouse, false)){
// Right Control ---------------------------------------------------------------
if (this._x<430) {
if (speed<top_speed) {
speedR += accel_x
}
this._x += speedR;
} else if (this._x<_root._xmouse) {
speedR = 0
} else if (this._x>430) {
speedR = 0;
this._x = 430
} else if (speedR<0) {
speedR = 0;
} else {
if (speedR>0) {
speedR -= decay;
}
this._x += speedR;
}
// Left Control ---------------------------------------------------------------
if (this._x>20) {
if (speed<top_speed) {
speedL += accel_x
}
this._x -= speedL;
} else if (this._x>_root._xmouse) {
speedL = 0
} else if (this._x>20) {
speedL = 0;
this._x = 20
} else if (speedL<0) {
speedL = 0;
} else {
if (speedL>0) {
speedL -= decay;
}
this._x -= speedR;
}
// Down Control -------------------------------------------------------------
if (this._y<620) {
if (speed<top_speed) {
speedD += accel_y
}
this._y += speedD;
} else if (this._y<_root._ymouse) {
speedD = 0
} else if (this._y>620) {
speedD = 0;
this._y = 620
} else if (speedD<0) {
speedD = 0;
} else {
if (speedD>0) {
speedD -= decay;
}
this._y += speedD;
}
// Up Control ---------------------------------------------------------------
if (this._y>20) {
if (speed<top_speed) {
speedU += accel_y
}
this._y -= speedU;
} else if (this._y>_root._ymouse) {
speedU = 0
} else if (this._y>20) {
speedU = 0;
this._y = 20
} else if (speedU<0) {
speedU = 0;
} else {
if (speedU>0) {
speedU -= decay;
}
this._y -= speedU;
}
}


[hernán]Puse la etiqueta code, es más fácil leerlo así[/hernán]

Por elfeLrOuNd

16 de clabLevel



Genero:Masculino  



Ultima edición por elfeLrOuNd el 24 Feb 2006 04:42 pm, editado 1 vez

msie
Citar            
MensajeEscrito el 23 Feb 2006 11:38 pm
siento reescribir en el post, pero no puedo dejar que se vaya en la lejania y nadie conteste, es demasiado importante para mi.

Por elfeLrOuNd

16 de clabLevel



Genero:Masculino  

msie
Citar            
MensajeEscrito el 24 Feb 2006 03:43 pm
Ahora compila pero no va. :(
Aqui solo tu puedes aclararte con las variables. :crap:

Código :

onClipEvent (load) {
   dead = false;
   speedR = 0;
   speedL = 0;
   speedD = 0;
   speedU = 0;
   top_speed = 10;
   decay = 0.1;
   accel_x = 0.25*(Math.cos(Math.cos((_root._xmouse-this._x)*0.1)));
   if (accel_x<0) {
      accel_x = -accel_x;
   }
   accel_y = 0.25*(Math.sin(Math.sin((_root._ymouse-this._y)*0.1)));
   if (accel_y<0) {
      accel_y = -accel_y;
   }
}
onClipEvent (mouseMove) {
   if (this.hitTest(_root._xmouse, _root._ymouse, false)) {
      // Right Control ---------------------------------------------------------------  
      if (this._x<430) {
         if (speed<top_speed) {
            speedR += accel_x;
         }
         this._x += speedR;
      } else if (this._x<_root._xmouse) {
         speedR = 0;
      } else if (this._x>430) {
         speedR = 0;
         this._x = 430;
      } else if (speedR<0) {
         speedR = 0;
      } else {
         if (speedR>0) {
            speedR -= decay;
         }
         this._x += speedR;
      }
      // Left Control ---------------------------------------------------------------  
      if (this._x>20) {
         if (speed<top_speed) {
            speedL += accel_x;
         }
         this._x -= speedL;
      } else if (this._x>_root._xmouse) {
         speedL = 0;
      } else if (this._x>20) {
         speedL = 0;
         this._x = 20;
      } else if (speedL<0) {
         speedL = 0;
      } else {
         if (speedL>0) {
            speedL -= decay;
         }
         this._x -= speedR;
      }
      // Down Control -------------------------------------------------------------
      if (this._y<620) {
         if (speed<top_speed) {
            speedD += accel_y;
         }
         this._y += speedD;
      } else if (this._y<_root._ymouse) {
         speedD = 0;
      } else if (this._y>620) {
         speedD = 0;
         this._y = 620;
      } else if (speedD<0) {
         speedD = 0;
      } else {
         if (speedD>0) {
            speedD -= decay;
         }
         this._y += speedD;
      }
      // Up Control ---------------------------------------------------------------
      if (this._y>20) {
         if (speed<top_speed) {
            speedU += accel_y;
         }
         this._y -= speedU;
      } else if (this._y>_root._ymouse) {
         speedU = 0;
      } else if (this._y>20) {
         speedU = 0;
         this._y = 20;
      } else if (speedU<0) {
         speedU = 0;
      } else {
         if (speedU>0) {
            speedU -= decay;
         }
         this._y -= speedU;
      }
   }
}

Por Arz

14 de clabLevel



 

msie
Citar            
MensajeEscrito el 24 Feb 2006 04:48 pm
no entiendo lo que has cambiado... has puesto espacios?? el codigo deberia de funcionar... lo mas dificil de entender es la aceleracion en x y en y y lo resolvi mediante el teorema de pitagoras basicamente, quiero que la aceleracion total sea 0.25, x eso multiplico el resultado de la x del vector por 0.25 y la y del vector x 0.25

NO VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA :cry: :cry: :cry: :cry: :cry:
NO VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA :cry: :cry: :cry: :cry:
ES EL PRIMER CODIGO QUE CREO, ES NORMAL QUE NO VAYA, PERO NO ENTIENDO EL POR QUE... :cry: :cry: :cry:

Por elfeLrOuNd

16 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 24 Feb 2006 07:02 pm
no os preocupeis ya, ñ.ñ he solucionado el problema :D muchas gracias Arz, al final me ha tocado recurrir a otro codigo que no hace lo mismo pero despues de todo tenía que poner algo...
si sabeis solucionar el problema citado arriba os lo agradecería de todos modos ^^Uu

Por elfeLrOuNd

16 de clabLevel



Genero:Masculino  

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.