English Version            Русская версия

 [ Разделы сервера ]  [ Карта сервера ]  [ Новости сервера ] [ Обратная связь ]



Слой Object Definition содержит алгоритм, который создает лабиринт в памяти. Слой Implementation содержит код ActionScript, необходимый для создания визуального представления лабиринта, который мы создали в памяти. Слой Assets содержит клипы, необходимые для отображения лабиринта. Мы больше всего интересуемся кодом ActionScript в слое Object Definition, поскольку он содержит алгоритм AI для создания лабиринта. В этом кадре находится 75 строк кода, все для одной длинной функции. 1 maze ={}; 2 maze.createMaze =function(horizontal,vertical){ 3 this.rows =horizontal; 4 this.columns =vertical; 5 this.totalCells =this.rows*this.columns; 6 this.startRow =random(this.rows)+1; 7 this.startColumn =random(this.columns)+1; 8 this.cellsVisited =0; 9 this.currentCell ="cell"+this.startRow+"_" .+this.startColumn; 10 this [this.currentCell ] =={name:this.currentCell, .x:this.startRow,y:this.startColumn,exists:true}; 11 this.visitList =[]; 12 this.visitList.push(this [currentCell ]); 13 while (this.cellsVisited<this.totalCells){ 14 var cell =this [this.currentCell ]; 15 var neighbors =[]; 16 if (cell.x-1>0){ 17 //восточная ячейка 18 var x =cell.x-1; 19 var y =cell.y; 20 var westCell ="cell"+x+"_"+y; 21 if (!this [westCell ].exists){ 22 neighbors.push([westCell,"west", ."east",x,y ]); 23 } 24 } 25 if (cell.y-1>0){ 26 //северная ячейка 27 var x =cell.x; 28 var y =cell.y-1; 29 var northCell ="cell"+x+"_"+y; 30 if (!this [northCell ].exists){ 31 neighbors.push([northCell,"north", ."south",x,y ]); 32 } 33 } 34 if (cell.x+1<=this.rows){ 35 //восточная ячейка 36 var x =cell.x+1; 37 var y =cell.y; 38 var eastCell ="cell"+x+"_"+y; 39 if (!this [eastCell ].exists){ 40 neighbors.push([eastCell,"east",
Профильные карнизы в Алматы . новый год в тайланде 2013
Hosted by uCoz