Bleend’s Blog

Bleend’s Blog

Blog Personal de Bleend, humor, cosas interesantes, diseño y programación.

« Física en FLash: Mov. Armónico Inframortiguado

Reestructuración del blog »

Física en Flash: Movimiento parabólico

Estos era un día en las vacaciones del Gato que me dijo si me animaba a hacer un juego estilo "bowman", entre los dos; en flash.

Yo, otro que no tenia nada que hacer, le dije que sí. Hice esto, y se lo pasé para que continuara, pero:
Gato dijo: ******* (censurado)

Y ahí se quedó. Se lo pongo a Uds, mis visitantes favoritos, igual les es útil. ^^

Necesita tener Flash Player 7 o superior y JavaScript Activado. =)

El archivo Fla original, lo encontrarán aquí.

Actionscript:
  1. var t:Number = 0;
  2. var i:Number = 0;
  3. g = -10;
  4. Xox = 30;
  5. Xoy = 300;
  6. back.onPress = function() {
  7.     arkero.nextFrame;
  8.     arkero.play();
  9.     back.enabled = false;
  10.     Vox = (_xmouse/10);
  11.     Voy = ((400-_ymouse)/7);
  12.     angi = Math.atan(Vox/Voy);
  13.     p = _root.getNextHighestDepth();
  14.     attachMovie("flecha", "flecha"+i, p);
  15.     ref = _root["flecha"+i];
  16.     onEnterFrame = function () {
  17.         Aox = 0;
  18.         Aoy = +g;
  19.         //----------
  20.         Vx = Vox+Aox*t;
  21.         Vy = Voy+Aoy*t;
  22.         //----------
  23.         Xx = Xox+Vox*t+Aox*t*t/2;
  24.         Xy = Xoy-Voy*t-Aoy*t*t/2;
  25.         //----------
  26.         ang = Math.atan(Vx/Vy);
  27.         if (ang<0) {
  28.             ang += Math.PI;
  29.         }
  30.         ref._rotation = -angi*(180/Math.PI)+ang*(180/Math.PI)/2;
  31.         ref._x = Xx;
  32.         ref._y = Xy;
  33.         t += 0.1;
  34.         if (ref._y>350) {
  35.             p = _root.getNextHighestDepth();
  36.             arkero.gotoAndStop("rdy");
  37.             attachMovie("sangre", "sangre"+i, p);
  38.             _root["sangre"+i]._x = Xx;
  39.             _root["sangre"+i]._y = 350;
  40.             delete (onEnterFrame);
  41.             i++;
  42.             t = 0;
  43.             back.enabled = true;
  44.         }
  45.     };
  46. };

Related posts:
  1. Física en flash: Movimiento pendular
  2. Física en flash: El péndulo tridimensional
  3. Flash, Inteligencia Artificial + 3 en raya
  4. Física en FLash: Mov. Armónico Inframortiguado
  5. Dibujar trazos en un swf Flash



-----Separador-----

3 comments »
Leave a reply

:smile: :grin: :razz: :lol: :wink: :mrgreen: :neutral: :roll: :shock: :???: :cool: :oops: :twisted: :evil: :eek: :mad: :sad: :cry: :!: :idea: :arrow: