top of page

Flash: Videojuego del muro

  • Foto del escritor: Samir Ramirez
    Samir Ramirez
  • 14 dic 2008
  • 2 Min. de lectura

Hemos programado el Videojuego del muro en Flash (ActionScript). Se accede al juego desde este enlace.

También puedes acceder desde aquí al código fuente para el Flash. Este código (o el siguiente comentado) puedes compararlo con el código en LOGO del juego equivalente. Las imágenes y sonidos de este juego han sido descargados desde el Banco de Imágenes y Sonidos del CNICE.

Código del juego en ActionScript

A continuación escribo el código en ActionScript de este juego (de momento sin comentar, si tengo tiempo ya lo haré). Lo dejo por objetos (sólo aquellos que lleven código).

Código del Objeto Control

// Videojuego del muro // Raul Corzo, profesor del IES Jovellanos, Gijon // http://raultecnologia.wordpress.com onClipEvent (load) {  _global.aciertos = 0;  //Mouse.hide();  contador = 1;  this._visible = false;  _root.explosion._visible = false;  _root.ganador._visible = false;  _root.raultecnologia._visible = false;  _root.botonraul._visible = false;  _root.textoraul._visible = false;  {  for (i = 0; i < 7 ; i++)  {   for (j = 0; j < 6; j++)   { var nuevoRectangulo= _root.rectangulo.duplicateMovieClip(“rectangulo”+contador, contador); nuevoRectangulo._x = 100+58*i; nuevoRectangulo._y = 40+30*j; contador = contador+1;

 } } } }

Código objeto pelota

onClipEvent(load) {  _global.velx = 6;  _global.vely = -6; }

onClipEvent (enterFrame) {  if (this._y > 353)  {   _root.nave._visible = false;   _root.explosion._x = _root.nave._x;   _root.nave._x = 0;   _root.pelota._visible = false;   _root.explosion._visible = true;   this._y = -500;   _global.velx = 0;   _global.vely = 0;   miSonido = new Sound(this); miSonido.attachSound(“caida.wav”); miSonido.start();  }  this._x = this._x+_global.velx;  this._y = this._y+_global.vely;  if (_global.aciertos == 42)  {    _global.velx = 0;   _global.vely = 0;   _root.ganador._visible = true;  _root.botonraul._visible = true;  _root.textoraul._visible = true;  miSonido = new Sound(this); miSonido.attachSound(“aplauso.mp3”); miSonido.start(); _global.aciertos = 50;  } }

Código objeto nave

onClipEvent(mouseMove){

if (_global.aciertos < 42) {   this._x = _root._xmouse;   if (_root._xmouse > 450)  {   this._x = 450;  }  if (_root._xmouse < 100)  {   this._x = 100;  } } } onClipEvent(enterFrame) { if (hitTest(_root.pelota)) {  var distancia = _root.pelota._x – _root.nave._x;  _root.pelota._y = _root.pelota._y-3;  _global.vely = -_global.vely;  _global.velx = _global.velx+distancia/5;  miSonido = new Sound(this); miSonido.attachSound(“zippo.wav”); miSonido.start(); } }

Código objeto rectángulo

onClipEvent(enterFrame) { if (hitTest(_root.pelota)) {  _global.vely = -_global.vely;  _global.aciertos = _global.aciertos +1;  miSonido = new Sound(this); miSonido.attachSound(“moneda.wav”); miSonido.start();  this.removeMovieClip(); } }

Código objeto paredderecha

onClipEvent(enterFrame) { if (hitTest(_root.pelota)) {  _root.pelota._x = _root.pelota._x-3;  _global.velx = -_global.velx; } }

El código para paredizquierda y paredarriba es igual pero cambiando adecuadamente el rebote.

Comments


3025674909|

©2020 por SM-MANUFACTURING. Creada con Wix.com

bottom of page