Bonjour à tous,

Voilà je me suis mit depuis peu au flash(flash mx 2004 pro), et j'essaye de faire un jeu pour mon site.C'est un labyrinthe. Je commence juste et j'arrive à détecter les collisions et a faire que mon rond s'arrete contre le mur. Mais le probleme c'est que je serais amener à avoir une bonne cinquentaine de mur dans mon labyrinthe. J'aimerais avoir un code plus optimisé au lieu d'avoir ue ligne ou il il y a 50 instructions. Je vous fais voir mon code, je débute alors si il il y a quelquechose qui va pas dite le moi merci beaucoup.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
onClipEvent (enterFrame) 
{
	 if (Key.isDown(Key.RIGHT)) this._x += 5; 
	 if (Key.isDown(Key.LEFT)) this._x -= 5;
	 if (Key.isDown(Key.DOWN)) this._y += 5; 
	 if (Key.isDown(Key.UP)) this._y -= 5;
 
//test de collision si collision on inverse la poussée qui devient nulle
		if (this.hitTest(_root.mur1) || this.hitTest(_root.mur2) || this.hitTest(_root.mur3) || this.hitTest(_root.mur4) || this.hitTest(_root.mur5) || this.hitTest(_root.mur6) || this.hitTest(_root.mur7))
	 	{			
	if (Key.isDown(Key.RIGHT)) this._x-=5 ;
	if (Key.isDown(Key.LEFT)) this._x+=5 ;
	if (Key.isDown(Key.DOWN)) this._y -= 5;
	if (Key.isDown(Key.UP)) this._y += 5;
	}
}
Pour l'instant je n'ai que 7 murs et la ligne et dejà très longue, y'a t-il un moyen pour optimiser ce code??

Merci

@+