In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

[INFINITY TANK BATTLE] ロックバスター

ロックバスター
* 
* ドット絵はこちらからお借りしました
* http://www12.atwiki.jp/rockman7/pages/8.html
* 
* @author alumican.net<Yukiya Okuda>
* 
*********************************************************************************
* このコードを新着弾一覧http://flash-games.wonderfl.net/tank/list/bullets
* に表示させるためにはinfinite-tank-bullet
* というタグを追加してください
/**
 * Copyright alumican_net ( http://wonderfl.net/user/alumican_net )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/jwFq
 */

// forked from 9re's Wonderfl Tank Game BulletRenderer Sample 1
/**
 * ロックバスター
 * 
 * ドット絵はこちらからお借りしました
 * http://www12.atwiki.jp/rockman7/pages/8.html
 * 
 * @author alumican.net<Yukiya Okuda>
 * 
 *********************************************************************************
 * このコードを新着弾一覧http://flash-games.wonderfl.net/tank/list/bullets
 * に表示させるためにはinfinite-tank-bullet
 * というタグを追加してください
 */
package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.display.Shape;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.utils.Dictionary;
	
	import net.wonderfl.game.infinity_tank.development.*;
	import net.wonderfl.math.*;
	import net.wonderfl.utils.SequentialLoader;
	
	[SWF(backgroundColor="#000000")]
	public class BulletRenderer extends BulletRendererBase
	{
		//----------------------------------------
		//CLASS CONSTANTS
		
		private const PI:Number        = Math.PI;
		private const PI2:Number       = PI * 2;
		private const TO_RADIAN:Number = PI / 180;
		private const TO_DEGREE:Number = 180 / PI;
		
		
		
		
		
		//----------------------------------------
		//VARIABLES
		
		private var _clearTransform:ColorTransform;
		
		private var _loaders:Array;
		
		private var _bulletBmds:Array;
		private var _bulletList:Dictionary;
		
		
		
		
		
		//----------------------------------------
		//STAGE INSTANCES
		
		
		
		
		
		//----------------------------------------
		//CONSTRUCTOR
		
		public function BulletRenderer()
		{
			//Wonderfl.capture_delay(3.7);
			Wonderfl.disable_capture();
			
			//画像の読み込み
			_loaders = new Array();
			SequentialLoader.loadImages(
				[
					"http://lab.alumican.net/wonderfl/tank/rockman_bullet.png"
				]
				, _loaders, _imageLoadComplete);
			
			_clearTransform = new ColorTransform(1, 1, 1, 0);
			_bulletList = new Dictionary(true);
		}
		
		private function _imageLoadComplete():void
		{
			//画像の取り出し
			var src:Array = _loaders.map(
				function ($ldr:Loader, $index:int, $arr:Array):BitmapData
				{
					var bmd:BitmapData = new BitmapData($ldr.width, $ldr.height, true, 0x0);
					bmd.draw($ldr);
					return bmd;
				}
			);
			
			var bmds:Array = new Array();
			var width:uint = 60;
			var height:uint = 60;
			var n:uint = src[0].width / width;
			for (var i:uint = 0; i < n; ++i) 
			{
				var bmd:BitmapData = new BitmapData(width, height, true, 0x0);
				bmd.draw(src[0], new Matrix(1, 0, 0, 1, -i * width, 0));
				bmds.push(bmd);
			}
			
			//弾リスト
			_bulletBmds = 
			[
			    [ bmds[0] ],
			    [ bmds[1], bmds[2], bmds[3], bmds[4] ],
			    [ bmds[5], bmds[6], bmds[7], bmds[8], bmds[9], bmds[10] ]
			];
		}
		
		override public function draw($bitmapData:BitmapData):void
		{
			$bitmapData.lock();
			
			//クリア
			$bitmapData.colorTransform($bitmapData.rect, _clearTransform);
			
			//弾丸の描画
			var matrix:Matrix = new Matrix();
			var step:uint;
			var element:Object;
			var bullet:BoundBox = _scene.myBulletList;
			do
			{
				element = _bulletList[bullet];
				
				if (element == null)
				{
					element       = new Object();
					element.type  = uint( Math.random() * _bulletBmds.length );
					element.step  = step = 0;
					element.total = _bulletBmds[element.type].length - 1;
					
					_bulletList[bullet] = element;
				}
				else
				{
					step = element.step;
				}
				
				matrix.identity();
				matrix.translate(-30, -30);
				matrix.rotate(bullet.rotation);
				matrix.translate(
					bullet.position.x,
					bullet.position.y
				);
				
				$bitmapData.draw(_bulletBmds[element.type][step], matrix, null, null, null, true);
				
				//アニメーションステップを進める
				if (step < element.total) ++element.step;
			}
			while (bullet = bullet.next);
			
			$bitmapData.unlock();
		}
	}
}