Ver Mensaje Individual
  #5 (permalink)  
Antiguo 12/11/2005, 21:46
Juanchooo
 
Fecha de Ingreso: diciembre-2004
Mensajes: 272
Antigüedad: 19 años, 4 meses
Puntos: 4
A ver aqui va otro...

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();



function init() {
	nMonstruos=10;
	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.text=00;
	
	
	var mouse:Object = new Object();
	mouse.onMouseDown = function() {
		doBullet();
	};
	Mouse.addListener(mouse);
}
////////
_root.onEnterFrame = function() {
	shot._x = _root._xmouse;
};
////
////

////
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(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 = this.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);
	//
	for (var i = 1; i<nMonstruos; i++) {
		todos.bot.duplicateMovieClip("clip"+i, nMonstruos+i);
		bot = todos["clip"+i];
		bot._x = 50*i;
		monstruos.push(bot._name);
	}
	//
	var loop:MovieClip = this.createEmptyMovieClip("loop", this.getNextHighestDepth());
	dirx = 5;
	diry = 0;
	loop.onEnterFrame = function() {
		todos._x += dirx;
		if (todos._x>50) {
			dirx = -5;
			todos._y += 10;
		}
		if (todos._x<0) {
			dirx = 5;
			todos._y += 10;
		}
	};
}
init();