Ver Mensaje Individual
  #7 (permalink)  
Antiguo 30/01/2006, 16:33
Avatar de julio archila
julio archila
 
Fecha de Ingreso: marzo-2005
Ubicación: Quetzaltenango, Guatemala
Mensajes: 272
Antigüedad: 19 años, 1 mes
Puntos: 0
aca un jueguito con codigo, a ver si les da una idea:
uso codigos para mover de derecha a izquierda, arriba abajo, incrementar tamaño, alfa, rotación, etc, lo que no uso es el HitTest, pero almenos les dejo una idea, si necesitan explicaciones del codigo o algo mas, yo les ayudare con gusto.

Código:
var cont:MovieClip;
var barra:MovieClip;
var form:TextFormat;
var velocidad:Number = 5;
var n:Number = 5;
var puntaje:Number = 0;
var nivel:Number = 0;
dibujarBarra(Stage.width/2, Stage.height-25);
crearMsgs();
iniciar();
function iniciar():Void {
	Mouse.hide();
	var dirx:Number = Math.floor(Math.random()*2);
	var diry:Number = 0;
	var x:Number = 0;
	var y:Number = 0;
	var a:Number = 2;
	n = 5;
	cont = undefined;
	cont = this.createEmptyMovieClip("c", 0);
	cont._x = Stage.width/2;
	cont._y = Stage.height/2;
	cont.onEnterFrame = function():Void  {
		barra._x = _root._xmouse;
		this._rotation -= 5;
		if (a<74) {
			a++;
			x = 80*Math.sin(a*42);
			y = 80*Math.cos(a*42);
			if (a<20) {
				cont.moveTo(x, y);
			}
			cont.lineStyle(0.5, 0x999999, 60);
			cont.lineTo(x, y);
		} else {
			if (a++<200) {
				a++;
				x = 40*Math.sin(a*-15);
				y = 40*Math.cos(a*-15);
				if (bol) {
					cont.lineStyle(1, 0x999999, 40);
				} else {
					cont.lineStyle(1, 0x999999, 40);
				}
				cont.curveTo(x*0.5, y*0.5, 0, 0);
				cont.lineTo(x, y);
			} else if (a<275) {
				texto.text = "Imagen Completa...";
				texto.setTextFormat(form);
			}
		}
		if (a>=275) {
			texto.text = "Listo para jugar!!";
			texto.setTextFormat(form);
			puntos.text = "Puntos ::>> "+puntaje;
			puntos.setTextFormat(form_pnt);
			level.text = "NIVEL "+nivel;
			level.setTextFormat(level_pnt);
			puntaje = 0;
			nivel = 1;
			this._xscale -= 1;
			this._yscale = this._xscale;
			if (this._xscale<=30) {
				texto.text = "JUGANDO!!";
				texto.setTextFormat(form);
				cont.onEnterFrame = function() {
					this._xscale = (2000/this._y);
					this._yscale = this._xscale;
					if (puntaje<=11 && puntaje>1) {
						nivel = 1;
						level.text = "NIVEL "+nivel;
						level.setTextFormat(level_pnt);
					}
					if (puntaje>=11 && puntaje<21) {
						nivel = 2;
						level.text = "NIVEL "+nivel;
						level.setTextFormat(level_pnt);
					}
					if (puntaje>=21 && puntaje<31) {
						nivel = 3;
						level.text = "NIVEL "+nivel;
						level.setTextFormat(level_pnt);
					}
					if (puntaje>=31 && puntaje<41) {
						nivel = 4;
						level.text = "NIVEL "+nivel;
						level.setTextFormat(level_pnt);
					}
					if (puntaje>=41 && puntaje<51) {
						nivel = 5;
						level.text = "NIVEL "+nivel;
						level.setTextFormat(level_pnt);
					}
					if (puntaje>=61 && puntaje<71) {
						nivel = 6;
						level.text = "NIVEL "+nivel;
						level.setTextFormat(level_pnt);
					}
					if (puntaje>=71 && puntaje<81) {
						nivel = 7;
						level.text = "NIVEL "+nivel;
						level.setTextFormat(level_pnt);
					}
					if (puntaje>=81 && puntaje<91) {
						nivel = 8;
						level.text = "NIVEL "+nivel;
						level.setTextFormat(level_pnt);
					}
					if (puntaje>=91 && puntaje<101) {
						nivel = 9;
						level.text = "NIVEL "+nivel;
						level.setTextFormat(level_pnt);
					}
					if (puntaje>=101 && puntaje>101) {
						nivel = 10;
						level.text = "NIVEL "+nivel;
						level.setTextFormat(level_pnt);
					}
					barra._x = _root._xmouse;
					if (dirx == 1) {
						cont._x += velocidad+Math.floor(puntaje/5);
					} else {
						cont._x -= velocidad+Math.floor(puntaje/10);
					}
					if (diry == 1) {
						cont._y += velocidad+Math.floor(puntaje/5);
					} else {
						cont._y -= velocidad+Math.floor(puntaje/10);
					}
					if (cont._x>=Stage.width-25) {
						disparar(cont.duplicateMovieClip("disparo"+n, n));
						n++;
						dirx = 0;
					}
					if (cont._y>=Stage.height-50) {
						if (cont._x>=barra._x-25 && cont._x<=barra._x-25+(barra._width) && cont._y>=barra._y-8) {
							var cont_color:Color = new Color(cont);
							cont_color.setRGB(random(0x666666));
							puntos.text = "Puntos ::>> "+puntaje;
							puntos.setTextFormat(form_pnt);
							puntaje += 1;
							diry = 0;
						} else if (cont._y>Stage.height+30) {
							texto.text = "Has perdido, Presiona La Barra Espaciadora para jugar de nuevo";
							texto.setTextFormat(form);
							puntos.text = "Puntaje Total ::>> "+puntaje;
							puntos.setTextFormat(form_pnt);
							delete this.onEnterFrame;
						}
					}
					if (cont._x<=25) {
						disparar(cont.duplicateMovieClip("disparo"+n, n));
						n++;
						dirx = 1;
					}
					if (cont._y<=25) {
						disparar(cont.duplicateMovieClip("disparo"+n, n));
						n++;
						diry = 1;
					}
				};
			}
		}
	};
}
function disparar(mc:MovieClip):Void {
	var color:Color = new Color("disparo"+n);
	mc.onEnterFrame = function():Void  {
		this._xscale += 10;
		this._yscale = this._xscale;
		this._alpha -= 10;
		color.setRGB(random(0xfff63));
		if (this._alpha<40) {
			this.removeMovieClip();
		}
	};
}
function dibujarBarra(x:Number, y:Number):Void {
	barra = this.createEmptyMovieClip("c", 1);
	barra.beginFill(0x006699, 100);
	barra.curveTo(-50, 0);
	barra.lineTo(50, 0);
	barra.lineTo(50, 20);
	barra.lineTo(-50, 20);
	barra.lineTo(-50, 0);
	barra.endFill();
	barra._x = x;
	barra._y = y;
}
function crearMsgs():Void {
	this.createTextField("texto", 2, 10, 10, 10, 10);
	form = new TextFormat();
	form.font = "verdana";
	form.bold = true;
	form.size = 14;
	form.color = 0xffffff;
	form.align = "center";
	with (texto) {
		text = "Formando imagen, espera...";
		setTextFormat(form);
		selectable = false;
		autoSize = true;
		background = true;
		backgroundColor = "0x003366";
	}
	this.createTextField("puntos", 3, 10, texto._y+20, 10, 10);
	puntos.autoSize = true;
	puntos.background = true;
	puntos.backgroundColor = "0x003366";
	puntos.selectable = false;
	form_pnt = new TextFormat();
	form_pnt.font = "verdana";
	form_pnt.size = 18;
	form_pnt.bold = true;
	form_pnt.color = 0xffffff;
	form_pnt.align = "left";
	this.createTextField("level", 4, 10, puntos._y+25, 10, 10);
	level.autoSize = true;
	level.background = true;
	level.backgroundColor = "0x003366";
	level.selectable = false;
	level_pnt = new TextFormat();
	level_pnt.font = "verdana";
	level_pnt.size = 16;
	level_pnt.bold = true;
	level_pnt.color = 0xffffff;
	level_pnt.align = "left";
}
var myListener:Object = new Object();
Key.addListener(myListener);
myListener.onKeyUp = function() {
	if (Key.getAscii() == Key.SPACE) {
		iniciar();
	}
};
Saludos ...
__________________
Julio Archila