Ver Mensaje Individual
  #8 (permalink)  
Antiguo 17/11/2005, 10:26
Avatar de drake1983
drake1983
 
Fecha de Ingreso: febrero-2005
Ubicación: Cuba
Mensajes: 125
Antigüedad: 19 años, 1 mes
Puntos: 0
Aqui va uno de un novato!!!

Bueno soy nuevo en AS BATTLE, no se si será mucho pero aqui les dejo algo:
Código:
//Teclas de Accion:
//Mouse y click
var shot:MovieClip;
var sizeShot:Number = 10;
var lis:Object = {};
var count:Number;
var nMonstruos:Number;
var nMonstruosRestantes:Number;
var score = Number;
var monstruos:Array = Array();
var dirx:Number = 5;
var diry:Number = 0;
var fuerza:Number = 0.01;
var velocidad:Number = 0;
function init() {
	nMonstruos = 40;
	nMonstruosRestantes = nMonstruos;
	score = 0;
	mostritos();
	Stage.scaleMode = "noScale";
	count = 5;
	shot = drawTri(sizeShot, 0x990000);
	shot._y = Stage.height-sizeShot;
	this.createTextField("s", this.getNextHighestDepth(), 10, 380, 50, 20);
	this.createTextField("scoreTxt", this.getNextHighestDepth(), 40, 380, 50, 20);
	s.text = "Score:";
	scoreTxt.autoSize = true;
	scoreTxt.text = 00;
	var mouse:Object = new Object();
	mouse.onMouseDown = function() {
		doBullet();
	};
	Mouse.addListener(mouse);
}
////////
function doBullet() {
	var tiro = this.createEmptyMovieClip("a"+count++, count++, {_x:shot._x, _y:shot._y});
	tiro.moveTo(shot._x, shot._y);
	tiro.lineStyle(0);
	tiro.lineTo(shot._x, shot._y);
	tiro.lineTo(shot._x, (shot._y-10));
	tiro.onEnterFrame = moveShot;
}
/////
function moveShot() {
	if (this._alpha>0) {
		this._y -= 15;
		this._alpha -= 2;
		hazFallado(this._name);
	} else {
		this.removeMovieClip();
	}
}
///
function hazFallado(obj) {
	var leDiste:Number = 0;
	for (var i = 0; i<nMonstruosRestantes; i++) {
		if (_root[obj].hitTest(_root.todos[monstruos[i]])) {
			_root.todos[monstruos[i]].removeMovieClip();
			leDiste = 1;
			score += 50;
			scoreTxt.text = score;
		}
		if (leDiste) {
			monstruos[i] = monstruos[i+1];
		}
		if (shot.hitTest(_root.todos[monstruos[i]])) {
			_root.todos.removeMovieClip();
			shot.removeMovieClip();
			scoreTxt.textColor = 0xFF0000;
			scoreTxt.text = "Chocaste con "+score+" puntos";
			fin();
		}
	}
	if (leDiste) {
		nMonstruosRestantes--;
	}
}
///////////
function drawTri(size:Number, color:Number) {
	var shot:MovieClip = this.createEmptyMovieClip("shot", 2);
	shot.lineStyle(1, color);
	shot.beginFill(color);
	shot.moveTo(0, size);
	shot.lineTo(0, size);
	shot.lineTo(size, size);
	shot.lineTo((size/2), 0);
	shot.lineTo(0, size);
	return shot;
}
///
function mostritos() {
	var todos:MovieClip = _root.createEmptyMovieClip("todos", this.getNextHighestDepth());
	var bot:MovieClip = todos.createEmptyMovieClip("bot", this.getNextHighestDepth());
	todos.bot.beginFill(0xcccccc, 100);
	todos.bot.moveTo(0, 0);
	todos.bot.lineTo(25, 0);
	todos.bot.lineTo(25, 20);
	todos.bot.lineTo(20, 20);
	todos.bot.lineTo(20, 10);
	todos.bot.lineTo(15, 10);
	todos.bot.lineTo(15, 20);
	todos.bot.lineTo(10, 20);
	todos.bot.lineTo(10, 10);
	todos.bot.lineTo(5, 10);
	todos.bot.lineTo(5, 20);
	todos.bot.lineTo(0, 20);
	todos.bot.lineTo(0, 0);
	todos.bot.endFill();
	monstruos.push(bot._name);
	//
	mi_x = 0;
	mi_y = 0;
	je = true;
	for (var i = 1; i<nMonstruos; i++) {
		todos.bot.duplicateMovieClip("clip"+i, nMonstruos+i);
		bot = todos["clip"+i];
		if (mi_x>5) {
			if (je) {
				mi_x = 0.5;
				je = false;
			} else {
				mi_x = 0;
				je = true;
			}
			mi_y += 1;
		}
		bot._x = 100*mi_x;
		bot._y = 20*mi_y;
		mi_x += 1;
		monstruos.push(bot._name);
	}
	//
	todos.onEnterFrame = caminen;
}
function caminen() {
	shot._x += (_root._xmouse-shot._x)*0.1;
	shot._y += (_root._ymouse-shot._y)*0.1;
	velocidad += fuerza;
	this._y += velocidad;
	this._x += dirx;
	if (this._x>50) {
		dirx = -5;
		this._y += 10;
	} else if (this._x<0) {
		dirx = 5;
		this._y += 5;
	}
	if (this._y>Stage.height) {
		this.unloadMovie();
		scoreTxt.text = "Total: "+score+" puntos";
		fin();
	}
	for (var i = 0; i<nMonstruosRestantes; i++) {
		if (shot.hitTest(_root.todos[monstruos[i]])) {
			_root.todos.removeMovieClip();
			shot.removeMovieClip();
			scoreTxt.textColor = 0xFF0000;
			scoreTxt.text = "Chocaste con "+score+" puntos";
			fin();
		}
	}
}
function fin():Void {
	_root.createEmptyMovieClip("ventana_mc", this.getNextHighestDepth());
	with (ventana_mc) {
		beginFill(0xFFCCCC, 50);
		lineStyle(3, 0x0000);
		moveTo(100, 100);
		lineTo(500, 100);
		lineTo(500, 200);
		lineTo(100, 200);
		lineTo(100, 100);
		endFill();
		this.createTextField("mensaje_txt", this.getNextHighestDepth(), 150, 150, 400, 50);
		if (score == 2000) {
			mensaje_txt.text = "FELICIDADES, LE DISTE A TODOS LOS MONSTRUOS";
			mensaje_txt.textColor = 0x0000FF;
		} else {
			mensaje_txt.text = "OOPS!!!! PERDISTE!!!";
			mensaje_txt.textColor = 0x990000;
		}
	}
}
init();
__________________
Nada que perder...