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

if (isHit) { gameover(); }

GAME :: 避けゲーっぽいの

操作はマウスを動かすのみです。上方から降り注ぐ流星をひたすら避け続けます。
Level 5 付近から結構きついです(主観)。
Get Adobe Flash player
by daniwell 12 Feb 2012
/**
 * Copyright daniwell ( http://wonderfl.net/user/daniwell )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5XmH
 */

/**
 * GAME :: 避けゲーっぽいの
 * 
 * 操作はマウスを動かすのみです。上方から降り注ぐ流星をひたすら避け続けます。
 * Level 5 付近から結構きついです(主観)。
 */
package  
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.ColorTransform;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.ui.Mouse;
	
	[SWF(backgroundColor = "0x333333", frameRate = "30", width = "465", height = "465")]
	public class Evade extends Sprite
	{
		private const WIDTH :uint = 390 / 3;
		private const HEIGHT:uint = 465 / 3;
		
		private var bmd :BitmapData;
		private var bmp :Bitmap;
		
		private var particles :Vector.<Vector.<Particle>> = new Vector.<Vector.<Particle>>(WIDTH);
		
		private var pos :int = 0;
		private var numList :Vector.<uint> = new Vector.<uint>(WIDTH);
		private var scoreText :TextField;
		private var tx :TextField = new TextField();
		
		private var lv :uint;
		private var speed :Number;
		private var particleNum :uint;
		
		public function Evade() 
		{
			graphics.beginFill(0x333333); graphics.drawRect(0,0,465,465);
			
			bmd = new BitmapData(WIDTH, HEIGHT, false, 0);
			bmp = new Bitmap(bmd);
			bmp.scaleX = bmp.scaleY = 3;
			addChild(bmp);
			
			scoreText = new TextField();
			tx = new TextField();
			tx.autoSize = scoreText.autoSize = "left";
			tx.defaultTextFormat = scoreText.defaultTextFormat = new TextFormat("_等幅", 10, 0xffffff);
			
			scoreText.x = 395;
			scoreText.y = 435;
			addChild(scoreText);
			
			tx.text = "CLICK TO RESTART";
			tx.x = (465 - tx.width) / 2;
			tx.y = (465 - tx.height) / 2;
			addChild(tx);
			
			initialize();
		}
		private function initialize():void
		{
			var i:uint, j:uint, len:uint = 0;
			
			tx.visible = false;
			lv = pos = 0;
			
			for (i = 0; i < WIDTH; i++)
			{
				if (particles[i]) len = particles[i].length;
				for (j = 0; j < len; j++) particles[i][j] = null;
				
				numList[i] = i;
				particles[i] = new Vector.<Particle>();
			}
			for (i = 0; i < WIDTH; i++)
			{
				var tmp:uint = numList[i];
				var r :uint = Math.random() * WIDTH;
				numList[i] = numList[r];
				numList[r] = tmp;
			}
			
			Mouse.hide();
			stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
		}
		
		private function addParticle():void
		{
			if (particleNum < pos) return;
			
			var n :uint = numList[pos % WIDTH];
			var p:Particle = new Particle();
			
			p.x = n;
			p.y = 0;
			p.vy = Math.random() * speed + 1;
			particles[n].push(p);
		}
		
		private function enterFrameHandler(e:Event):void
		{
			if (lv < Level.max && Level.counts[lv] <= pos)
			{
				speed = Level.speeds[lv];
				particleNum = Level.nums[lv];
				lv ++;	// level up
			}
			
			addParticle();
			pos ++;
			
			scoreText.text = "level: " + lv + "\nscore: " + pos;
			
			var i:uint, j:uint, len:uint = 0;
			var p:Particle;
			
			bmd.lock();
			bmd.colorTransform(bmd.rect, new ColorTransform (0.4, 0.4, 0.4));
			
			for (i = 0; i < WIDTH; i++)
			{
				len = particles[i].length;
				
				for (j = 0; j < len; j++)
				{
					p = particles[i][j];
					p.py = p.y;
					p.y += p.vy;
					if (HEIGHT <= p.y)
					{
						p.vy = Math.random() * speed + 1;
						p.y = 0;
					}
					bmd.setPixel(p.x, p.y, 0xffffff);
				}
			}
			
			var mX :int = mouseX / 3;
			var mY :int = mouseY / 3;
			if (mX < 0) mX = 0; else if (WIDTH <= mX) mX = WIDTH - 1;
			
			// 衝突判定
			len = particles[mX].length;
			for (j = 0; j < len; j++)
			{
				p = particles[mX][j];
				if ( p.py <= mY && mY <= p.y )
				{
					Mouse.show();
					tx.visible = true;
					stage.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
					stage.addEventListener(MouseEvent.CLICK, clickHandler);
				}
			}
			
			bmd.setPixel(mX, mY, 0xff6600);	// mouse
			bmd.unlock();
		}
		private function clickHandler(e:MouseEvent):void
		{
			stage.removeEventListener(MouseEvent.CLICK, clickHandler);
			initialize();
		}
	}
}

class Particle
{
	public var x :Number = 0;
	public var y :Number = 0;
	public var vy:Number = 0;
	public var py:Number = 0; // previous y
}
/* Level 毎の 速さ調整 & 個数 管理 */
class Level
{
	public static const max :uint = 10;
	public static const counts :Array = [  0, 400, 800, 1200, 1500, 2000, 2500, 3000, 5000, 10000]; // pos
	public static const speeds :Array = [  0, 0.5,   1,    1,  1.5,  1.8,    2,  2.5,    3,     3]; // Particle 速さ
	public static const nums   :Array = [130, 150, 150,  180,  180,  200,  200,  200,  220,   260]; // Particle 個数
}