Too heavy on the cpu

Hi,

Look, I´m having problems building this site:

www.printaporter.net/ai/index.htm

It´s preatty raw still so I´m not looking for comments on how the splash screen sucks :slight_smile:
My problem is that my solution for collision detection gets very heavy on the cpu at times (well, most of the time actually :red: )

I´m posting the code below. I think its preaty self explanatory but if ya´all have any Qs i´m here to give the As. All of the goBungalow and the such are mc´s for switching screens, the limits for limiting movement and that´s it preatty much.

I don´t know, i´ll be thinking about it now but if anyone has an idea on how to reorganize the site so it asks less of the cpu that would be great.


onClipEvent(enterFrame){

//modify coordinates to fit with the _root coordinates
x = _parent.dudePos._x + 90;
y = _parent.dudePos._y + 10;

//check for collision

//thease are for switching screens
if((_parent.goBungalows3.hitTest(x,y,true))){
	_global.startingPoint = 3;
	loadMovie("bungalows.swf",_root.mainContainer);
}
if((_parent.goCruze1.hitTest(x,y,true))){
	_global.startingPoint = 1;
	loadMovie("cruze.swf",_root.mainContainer);
}

//this one´s for activating the mask
if((_parent.activateMask.hitTest(x,y,true))){
	_parent.dudeMask._x = this._x;
	_parent.dudeMask._y = this._y;
}else{
	_parent.dudeMask._x = 0;
	_parent.dudeMask._y = 0;
}
if((_parent.activateMaskAlt.hitTest(x,y,true))){
	_parent.dudeMaskAlt._x = this._x;
	_parent.dudeMaskAlt._y = this._y;
}else{
	_parent.dudeMaskAlt._x = 0;
	_parent.dudeMaskAlt._y = 0;
}

//these are for limiting the movement 
if ((_parent.limitUp.hitTest(x,y,true))){
	noGoUp = true;
}else{
	noGoUp = false;
}
if ((_parent.limitDown.hitTest(x,y,true))){
	noGoDown = true;
}else{
	noGoDown = false;
}
if ((_parent.limitLeft.hitTest(x,y,true))){
	noGoLeft = true;
}else{
	noGoLeft = false;
}
if ((_parent.limitRight.hitTest(x,y,true))){
	noGoRight = true;
}else{
	noGoRight = false;
}

// stop animation on collision

// El paisano desliza sin animacion si sigue un limite. NO VALE.

//if(noGoUp || noGoDown || noGoLeft || noGoRight){
//	this.gotoAndStop(1);
//}

//Key Actions
	
	//idle
	if(!Key.isDown(Key.UP)&&!Key.isDown(Key.DOWN)&&!Key.isDown(Key.LEFT)&&!Key.isDown(Key.RIGHT)){
		this.gotoAndStop(1);
	}
	
	//up
	if(!noGoUp && Key.isDown(Key.UP) && !Key.isDown(Key.DOWN) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)){
		this.gotoAndStop(2);
		this._x-=2;
		this._y-=1;
	}
	
	//down
	if(!noGoDown && Key.isDown(Key.DOWN) && !Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)){
		this.gotoAndStop(3);
		this._x+=2;
		this._y+=1;
	}
	
	//right
	if(!noGoRight && Key.isDown(Key.RIGHT) && !Key.isDown(Key.UP) && !Key.isDown(Key.DOWN) && !Key.isDown(Key.LEFT)){
		this.gotoAndStop(5);
		this._x+=2;
		this._y-=1;
	}
	
	//left
	if(!noGoLeft && Key.isDown(Key.LEFT) && !Key.isDown(Key.UP) && !Key.isDown(Key.DOWN) && !Key.isDown(Key.RIGHT)){
		this.gotoAndStop(4);
		this._x-=2;
		this._y+=1;
	}
	
	//up+left
	if(!noGoUp && !noGoLeft && Key.isDown(Key.UP) && Key.isDown(Key.LEFT)){
		this.gotoAndStop(4);
		this._x-=2;
	}
	
	//up+right
	if(!noGoUp && !noGoRight && Key.isDown(Key.UP) && Key.isDown(Key.RIGHT)){
		this.gotoAndStop(5);
		this._y-=2;
	}
	
	//down+left
	if(!noGoDown && !noGoLeft && Key.isDown(Key.DOWN) && Key.isDown(Key.LEFT)){
		this.gotoAndStop(3);
		this._y+=2;
	}
	
	//down+right
	if(!noGoDown && !noGoRight && Key.isDown(Key.DOWN) && Key.isDown(Key.RIGHT)){
		this.gotoAndStop(5);
		this._x+=2;
	}
// End of Key Actions
}