Game Development Reference
In-Depth Information
protected var _highlightIndex:int = -1;
public function Tunnel(radius:Number, depth:int = 10,
sides:int = 8) {
_radius = radius;
_sides = sides;
_depth = depth;
createTunnel();
}
protected function createTunnel():void {
_tunnelTiles = new Array();
var tempTile:TunnelTile = new TunnelTile();
_tileHeight = tempTile.height;
_tileWidth = (_radius * Math.tan(Math.PI/_sides)) * 2;
var angle:Number = (Math.PI * 2) / _sides;
for (var j:int = 0; j
_depth; j++) {
var tileSet:Array = new Array();
for (var i:int = 0; i
<
_sides; i++) {
tempTile = new TunnelTile();
tempTile.width = _tileWidth;
tempTile.x = Math.cos(i*angle) * _radius;
tempTile.y = Math.sin(i*angle) * _radius;
tempTile.z = j * _tileHeight;
tempTile.rotationX = 90;
tempTile.rotationZ = i * Math.round(radians
ToDegrees(angle)) + 90;
tileSet.push(tempTile);
addChild(tempTile);
var ct:ColorTransform = tempTile.transform.
colorTransform;
ct.redMultiplier *= (_depth - j)/_depth;
ct.greenMultiplier *= (_depth - j)/_depth;
ct.blueMultiplier *= (_depth - j)/_depth;
tempTile.transform.colorTransform = ct;
<
}
_tunnelTiles.push(tileSet);
}
}
protected function radiansToDegrees(value:Number):Number {
return value * (180/Math.PI);
}
protected function degreesToRadians(value:Number):Number {
return value * (Math.PI/180);
}
Search Nedrilad ::




Custom Search