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

Run & Hover

2つのリソースを同時に管理するゲームの試作


操作方法(How to Play)
・タッチ(Touch)
 ・タッチしてる間はMPを消費して浮上
 ・キーボードでも同様の操作が可能

ルール
・UI
 ・HP:0になるとGameOver
 ・MP:タッチによる浮上時に消費。0になると浮上不可
・Obj
 ・黒い玉:当たるとHPが2減少
 ・赤い+玉:HPを1回復
 ・青い+玉:MPを25回復


比較用
・Android版(Air)(あとで追加予定)
 ・https://play.google.com/store/apps/details?id=air.showohealer.game.airprototype
Get Adobe Flash player
by o_healer 10 Aug 2012
/**
 * Copyright o_healer ( http://wonderfl.net/user/o_healer )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/dDCN
 */

/*

「Run & Hover」

・2つのリソースを同時に管理するゲームの試作



操作方法(How to Play)

・タッチ(Touch)

 ・タッチしてる間はMPを消費して浮上

 ・キーボードでも同様の操作が可能



ルール

・UI

 ・HP:0になるとGameOver

 ・MP:タッチによる浮上時に消費。0になると浮上不可

・Obj

 ・黒い玉:当たるとHPが2減少

 ・赤い+玉:HPを1回復

 ・青い+玉:MPを25回復



実験目的

・「2つの操作を同時に行う」のではなく、「2つのリソース管理を同時に行う」ことによるゲーム性の確認

 ・2つの操作:マリオで言えば移動とジャンプによるモンスターへの攻撃や落とし穴の回避など

 ・2つのリソース:HPとMP


メモ

・コツ

 ・HPが減ってない状態で回復アイテムをとってもしょうがないので、多少は減らしてMPを節約した方が良い

 ・タッチしっぱなしで浮上するよりはポンポンと押した方がMPの減りが少なくて済む

・設計時にわかったこと

 ・ダメージが1だと、HP回復アイテムが見えたら浮上しなくてもリソースは±0なのでそれ一択になってしまう

  →2ダメージにすることで、HP-1かMP消費かの選択を迫ることができる

 ・MP回復アイテムは全回復だとありがたみが少ない

・その他

 ・リソース2つではまだ簡単すぎる?

  ・スコアもリソース化し、アイテムを取るとスコアが加算されるようにする?

  ・スコアアイテムは必ずしも毎回取れる必要はないので、完全にランダムに配置して良さそう



比較用

・Android版(Air)(あとで追加予定)

 ・https://play.google.com/store/apps/details?id=air.showohealer.game.airprototype



*/





/*

1プレイをもう少し短くしたい

*/



package {

    import flash.display.*;

    import flash.events.*;

    import flash.filters.*;

    import flash.geom.*;

    import flash.net.*;

    import flash.system.*;

    import flash.text.*;

    import net.wonderfl.utils.WonderflAPI;

 

    [SWF(width="465", height="465", frameRate="30", backgroundColor="0x000000")]

    public class ResourceRunner extends Sprite {



        //==File==

//*

        static public const BITMAP_URL:String = "http://assets.wonderfl.net/images/related_images/8/89/89a9/89a998f94943739576276929eaea9aff30c3353e";

/*/

        [Embed(source='Result.png')]

         private static var Bitmap_Graphic: Class;

//*/





        //==Const==



        //画面の大きさ

        static public const VIEW_W:int = 465;

        static public const VIEW_H:int = 465;



        //

        static public const PLAYER_MIN_Y:int = 32;//32 * 1

        static public const PLAYER_MAX_Y:int = 416;//32 * 13



        //

        static public const SCROLL_VEL_FAR :Number = 16;

        static public const SCROLL_VEL_NEAR:Number = 128;





        static public const I:int = -1;

        static public const GIMMICK_PATTERN:Vector.<Vector.<Vector.<int> > > = new <Vector.<Vector.<int> > >[

/*

            new <Vector.<int> >[

                new <int>[0,0,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,1,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,1,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,1,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,1,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,1,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,1,0,0,0,0,0,0],

            ],

//*/

            new <Vector.<int> >[

                new <int>[0,0,0,0,0,0,0,2,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,2,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,2,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,2,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,2,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,2,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,2,0,0,0,0],

                new <int>[0,1,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,1,0,I,0,0,0,0,0,0,0,0],

            ],

            new <Vector.<int> >[

                new <int>[0,2,2,2,2,2,2,2,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,1,1,1,1,1,1,1,0,I,0,0],

            ],

            new <Vector.<int> >[

                new <int>[0,0,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,0,0,0,0,0,0,0,0,0,0,0],

                new <int>[0,0,0,1,0,0,0,0,0,0,0,0],

                new <int>[0,0,0,1,0,0,0,0,0,0,0,0],

                new <int>[0,0,1,1,1,0,0,0,0,0,0,0],

                new <int>[0,0,1,1,1,0,0,0,0,0,0,0],

                new <int>[0,1,1,1,1,1,0,0,0,0,0,0],

                new <int>[0,1,1,1,1,1,0,I,0,0,0,0],

            ],

        ];





        //==Var==



        //Pseudo Singleton

        static public var Instance:ResourceRunner;



        //Layer

        public var m_Layer_Game:Sprite = new Sprite();

        public var m_Layer_UI:Sprite = new Sprite();



        //Player

        public var m_Player:Player;



        //BG

        public var m_BG_Far:Bitmap;

        public var m_BG_Near:Bitmap;



        //Gimmick

        public var m_Gimmick:Vector.<Gimmick> = new Vector.<Gimmick>();

        //

        public var m_CreateScrollX:Number = 512;



        //UI

        public var m_GaugeHP:Gauge_HP;

        public var m_GaugeMP:Gauge_MP;



        //Score

        public var m_Score:int = 0;

        public var m_NumberView_Score:NumberView;



        //Text

        public var m_Text_GameOver:TextField = new TextField();

        public var m_Text_Ranking:TextField = new TextField();



        //Flag

        public var m_IsGameOver:Boolean = false;





        //==Function==



        //Init

        public function ResourceRunner():void {

            if(stage != null){

                Load(null);

            }else{

                addEventListener(

                    Event.ADDED_TO_STAGE,//ステージに追加されたら

                    Load

                );

            }

        }

        public function Load(e:Event):void{

//*

            //wonderfl用:Bitmapを外部からロードする場合



            //Load

            var loader:Loader = new Loader();

            loader.load(new URLRequest(BITMAP_URL), new LoaderContext(true));//画像のロードを開始して

            loader.contentLoaderInfo.addEventListener(

                Event.COMPLETE,//ロードが完了したら

                function(e:Event):void{

                    OnLoad(loader.content);//それを保持した後

                }

            );

/*/

            //ローカル用:Bitmapを事前ロードできる場合



            //ブロック画像のセット(&その他初期化)

            OnLoad(new Bitmap_Graphic());

//*/

        }

        //OnLoad

        public function OnLoad(in_Graphic:DisplayObject):void{

            ImageManager.Init(in_Graphic);



            //Static Init

            ScoreWindowLoader.init(this, new WonderflAPI(loaderInfo.parameters));



            Init();

        }

        public function Init():void

        {

            //Pseudo Singleton

            {

                Instance = this;

            }



            //Layer

            {

                addChild(m_Layer_Game);

                addChild(m_Layer_UI);

            }



            //UI

            {

                const GaugeX:int = 8;

                const GaugeY:int = 8;

                const GaugeOffsetY:int = 24;



                m_GaugeHP = new Gauge_HP();

                m_GaugeHP.x = GaugeX;

                m_GaugeHP.y = GaugeY;

                m_Layer_UI.addChild(m_GaugeHP);



                m_GaugeMP = new Gauge_MP();

                m_GaugeMP.x = GaugeX;

                m_GaugeMP.y = GaugeY + GaugeOffsetY;

                m_Layer_UI.addChild(m_GaugeMP);

            }



            //BG

            {

                m_BG_Far = ImageManager.CreateBitmap_BG_Far(VIEW_W, VIEW_H);

                m_Layer_Game.addChild(m_BG_Far);



                m_BG_Near = ImageManager.CreateBitmap_BG_Near(VIEW_W, VIEW_H);

                m_Layer_Game.addChild(m_BG_Near);

            }



            //Player

            {

                const PlayerX:int = 32;

                m_Player = new Player(m_GaugeHP, m_GaugeMP);

                m_Player.x = PlayerX;

                m_Player.y = PLAYER_MAX_Y;

                m_Layer_Game.addChild(m_Player);

            }



            //Score

            {

                m_NumberView_Score = new NumberView(NumberView.COLOR_WHITE);

                m_NumberView_Score.SetVal(0);

                m_NumberView_Score.x = VIEW_W - 8;

                m_NumberView_Score.y = 8;

                addChild(m_NumberView_Score);

            }

            {

                var bmp:Bitmap = ImageManager.GetBitmap_LabelScore();

                bmp.x = VIEW_W/2;

                bmp.y = 8;



                addChild(bmp);

            }



            //Text

            {

                m_Text_GameOver.selectable = false;

                m_Text_GameOver.autoSize = TextFieldAutoSize.LEFT;

                m_Text_GameOver.defaultTextFormat = new TextFormat('Verdana', 32, 0xFFFF00, true);

                m_Text_GameOver.text = "GAME OVER";

                m_Text_GameOver.filters = [new GlowFilter(0xFF0000,1.0, 8,8)];

                m_Text_GameOver.x = VIEW_W/2 - m_Text_GameOver.textWidth/2;

                m_Text_GameOver.y = VIEW_H/2 - m_Text_GameOver.textHeight/2;

                m_Text_GameOver.visible = false;



                addChild(m_Text_GameOver);

            }

            {

                m_Text_Ranking.selectable = false;

                m_Text_Ranking.autoSize = TextFieldAutoSize.LEFT;

                m_Text_Ranking.defaultTextFormat = new TextFormat('_typewriter', 24, 0x000000, true);

                m_Text_Ranking.text ="";

                m_Text_Ranking.filters = [new GlowFilter(0xFFFFFF)];



                m_Text_Ranking.x = VIEW_W/2;

                m_Text_Ranking.y = 24;



                addChild(m_Text_Ranking);

            }





            //Touch

            {

                stage.addEventListener(KeyboardEvent.KEY_DOWN, OnKeyDown);

                stage.addEventListener(KeyboardEvent.KEY_UP, OnKeyUp);

                stage.addEventListener(MouseEvent.MOUSE_DOWN, OnMouseDown);

                stage.addEventListener(MouseEvent.MOUSE_UP,   OnMouseUp);

            }



            //Update

            {

                addEventListener(Event.ENTER_FRAME, Update);

            }



            //OnEnd

            {

                addEventListener(Event.REMOVED_FROM_STAGE, Finish);

            }



        }





        //Finish

        public function Finish(e:Event):void{

            removeEventListener(Event.ADDED_TO_STAGE, Init);

            removeEventListener(Event.ENTER_FRAME, Update);

            removeEventListener(Event.REMOVED_FROM_STAGE, Finish);

        }



        //Touch

        private function OnMouseDown(e:MouseEvent):void{

            m_Player.OnJumpStart();

        }

        private function OnMouseUp(e:MouseEvent):void{

            m_Player.OnJumpEnd();

        }

        private function OnKeyDown(event:KeyboardEvent):void{

            m_Player.OnJumpStart();

        }

        private function OnKeyUp(e:KeyboardEvent):void{

            m_Player.OnJumpEnd();

        }



        //Update

        public function Update(e:Event=null):void{

            var DeltaTime:Number = 1.0 / stage.frameRate;



            if(m_IsGameOver){

                return;

            }



            Update_Player(DeltaTime);



            Update_BG(DeltaTime);



            Update_Gimmick(DeltaTime);



            Check_End();

        }



        //Update : Player

        public function Update_Player(in_DeltaTime:Number):void{

            //

            m_Player.Update(in_DeltaTime);



            //Score

            ++m_Score;

            m_NumberView_Score.SetVal(m_Score);

        }



        //Update : BG

        public function Update_BG(in_DeltaTime:Number):void{

            {//Near

                m_BG_Near.x -= SCROLL_VEL_NEAR * in_DeltaTime;

                while(m_BG_Near.x <= -2*ImageManager.BG_PANEL_W){

                    m_BG_Near.x += 2*ImageManager.BG_PANEL_W;

                }

            }

            {//Far

                m_BG_Far.x -= SCROLL_VEL_FAR * in_DeltaTime;

                while(m_BG_Far.x <= -ImageManager.BG_PANEL_W){

                    m_BG_Far.x += ImageManager.BG_PANEL_W;

                }

            }

        }



        //Update : Gimmick

        public function Update_Gimmick(in_DeltaTime:Number):void{

            var i:int;

            var gimmick:Gimmick;



            var num:int = m_Gimmick.length;

            var player:Player = m_Player;

            var playerX:int = player.x;

            var playerY:int = player.y;



            //Create



            //Move

            for(i = 0; i < num; ++i){

                gimmick = m_Gimmick[i];



                gimmick.x -= SCROLL_VEL_NEAR * in_DeltaTime;

            }



            //Update

            for(i = 0; i < num; ++i){

                gimmick = m_Gimmick[i];



                gimmick.Update(in_DeltaTime);

            }



            //HitCheck

            for(i = 0; i < num; ++i){

                gimmick = m_Gimmick[i];



                if(gimmick.IsHit(playerX, playerY)){

                    gimmick.OnHit(player);

                }

            }



            //RemoveCheck

            for(i = 0; i < num; ++i){

                gimmick = m_Gimmick[i];



                var vanish_flag:Boolean = false;



                if(gimmick.m_DeadFlag){//接触などで消失

                    vanish_flag = true;

                }

                if(gimmick.x < -32){//画面外

                    vanish_flag = true;

                }



                if(vanish_flag){

                    //描画登録の解除

                    gimmick.parent.removeChild(gimmick);



                    //リストから削除

                    m_Gimmick.splice(i, 1);

                    --i;

                    --num;

                }

            }



            //Create

            {

                m_CreateScrollX -= SCROLL_VEL_NEAR * in_DeltaTime;



                if(m_CreateScrollX <= 0){

                    var GimmickInitX:int = VIEW_W + m_CreateScrollX;

                    var GimmickInitY:int = VIEW_H - 32*1.5;

                    var GimmickOffsetX:int = 32;

                    var GimmickOffsetY:int = 16;



                    var selected_pattern_index:int = GIMMICK_PATTERN.length * Math.random();

                    var pattern:Vector.<Vector.<int> > = GIMMICK_PATTERN[selected_pattern_index];



                    var NumY:int = pattern.length;

                    var NumX:int = pattern[0].length;



                    var chain_obj:Vector.<ChainObj> = new Vector.<ChainObj>(10);

                    for(i = 0; i < 10; ++i){

                        chain_obj[i] = new ChainObj();

                    }



                    for(var yy:int = 0; yy < NumY; ++yy){

                        for(var xx:int = 0; xx < NumX; ++xx){

                            var gimmick_index:int = pattern[yy][xx];



                            gimmick = null;



                            //Bomb

                            if(0 < gimmick_index){

                                gimmick = new Gimmick_Damage(chain_obj[gimmick_index-1]);

                            }



                            //Item

                            if(gimmick_index == I){

                                if(Math.random() < 0.7){//HP回復を多めにして、MPの節約とわざと当たるのを重要にする

                                    gimmick = new Gimmick_CureHP();

                                }else{

                                    gimmick = new Gimmick_CureMP();

                                }

                            }



                            if(gimmick != null){

                                gimmick.x = GimmickInitX + xx * GimmickOffsetX;

                                gimmick.y = GimmickInitY - (NumY-1 - yy) * GimmickOffsetY;

                                m_Gimmick.push(gimmick);

                                m_Layer_Game.addChild(gimmick);

                            }

                        }

                    }



                    m_CreateScrollX += NumX * GimmickOffsetX;

                }

            }

        }



        //Check : End

        public function Check_End():void{

            if(m_GaugeHP.m_Val <= 0){

                m_Text_GameOver.visible = true;



//*

                ScoreWindowLoader.show(m_Score);

/*/

                //ランキング表示

                const PreText:Array = [

                    "1st : ",

                    "2nd : ",

                    "3rd : ",

                    "4th : ",

                    "5th : ",

                    "6th : ",

                    "7th : ",

                    "8th : ",

                    "9th : ",

                    "10th: ",

                ];

                var ranking:Array = Refresh_Ranking(m_Score);

                var len:int = ranking.length;

                for(var i:int = 0; i < len; ++i){

                    m_Text_Ranking.appendText(PreText[i] + ranking[i] + "\n");

                }

                m_Text_GameOver.x = VIEW_W/4 - m_Text_GameOver.textWidth/2;

//*/



                m_IsGameOver = true;

            }

        }



        //Refresh : Ranking

        public function Refresh_Ranking(in_NewScore:int):Array{

            var so:SharedObject = SharedObject.getLocal("ResourceRunner");



            //Get Old Ranking

            var ranking_old:Array = so.data.ranking;

            if(ranking_old == null){

                ranking_old = new Array();

            }



            //Calc Param

            var len_old:int = ranking_old.length;

            var len_new:int = (len_old < 10)? len_old+1: 10;

            var ranking_new:Array = new Array(len_new);



            var i:int = 0;

            for(; i < len_old; ++i){

                if(ranking_old[i] <= in_NewScore){

                    break;

                }

                ranking_new[i] = ranking_old[i];

            }

            if(i < len_new){

                ranking_new[i++] = in_NewScore;

                for(; i < len_new; ++i){

                    ranking_new[i] = ranking_old[i-1];

                }

            }



            //Save

            so.data.ranking = ranking_new;



            return ranking_new;

        }



        //Add : Gimmick

        public function AddGimmick(in_Gimmick:Gimmick):void{

            if(in_Gimmick != null){

                m_Gimmick.push(in_Gimmick);

                m_Layer_Game.addChild(in_Gimmick);

            }

        }

    }

}





import flash.display.*;

import flash.events.*;

import flash.filters.*;

import flash.geom.*;

import flash.net.*;

import flash.system.*;

import flash.ui.*;

import net.wonderfl.utils.WonderflAPI;





class NumberView extends Sprite

{

    //==Const==



    //桁数

    static public const KETA:int = 12;



    //数字を並べる際のオフセット

    static public const OFFSET_X:int = 16;

    

    //色の種類

    static public var s_ColorIter:int = 0;

    static public const COLOR_RED    :int = s_ColorIter++;

    static public const COLOR_BLUE    :int = s_ColorIter++;

    static public const COLOR_WHITE    :int = s_ColorIter++;

    static public const COLOR_NUM    :int = s_ColorIter;





    //==Var==



    //表示画像(桁ごとに用意)

    public var m_Bitmap:Vector.<Bitmap> = new Vector.<Bitmap>(KETA);



    //画像のデータ

    public var m_BitmapData:Vector.<BitmapData>;//[10]





    //==Function==



    //Init

    public function NumberView(in_ColorIndex:int){

        var i:int;



        //m_Bitmap

        for(i = 0; i < KETA; ++i){

            var bmp:Bitmap = new Bitmap();

            bmp.x = (-i-1) * OFFSET_X;

            bmp.y = 0;

            addChild(bmp);

            m_Bitmap[i] = bmp;

        }



        m_BitmapData = ImageManager.CreateNumberGraphic(in_ColorIndex);

    }



    //Set

    public function SetVal(in_Val:int):void{

        var V:int = in_Val;



        //数字表示

        var index:int = 0;

        for(;;)

        {

            m_Bitmap[index++].bitmapData = m_BitmapData[V % 10];



            V /= 10;

            if(V <= 0){

                break;

            }

            if(KETA <= index){

                break;

            }

        }



        //残りは空白

        while(index < KETA){

            m_Bitmap[index++].bitmapData = null;

        }

    }

}





class Gauge_HP extends Sprite

{

    //==Const==



    //Max

    static public const VAL_MAX:int = 5;





    //==Var==



    //Val

    public var m_Val:int = VAL_MAX;



    //Gauge

    public var m_Gauge:Vector.<Bitmap> = new Vector.<Bitmap>(VAL_MAX);



    //Number

    public var m_NumberView:NumberView;







    //==Function==



    //Init

    public function Gauge_HP(){

        var i:int;

        var bmp:Bitmap;



        var OffsetX:int = 4;



        //Label

        {

            bmp = ImageManager.GetBitmap_LabelHP();

            bmp.x = OffsetX;

            OffsetX += 32;

            addChild(bmp);

        }



        //Gauge

        for(i = 0; i < VAL_MAX; ++i){

            bmp = ImageManager.GetBitmap_GaugeHP();

            bmp.x = OffsetX;

            OffsetX += 16;

            addChild(bmp);

            m_Gauge[i] = bmp;

        }



        //Number

        {

            m_NumberView = new NumberView(NumberView.COLOR_RED);

            m_NumberView.x = 176;

            m_NumberView.y = 0;

            m_NumberView.SetVal(m_Val);

            addChild(m_NumberView);

        }

    }



    //

    public function AddVal(in_Val:int):void{

        m_Val += in_Val;

        if(m_Val < 0){m_Val = 0;}

        if(VAL_MAX < m_Val){m_Val = VAL_MAX;}



        //表示の更新

        for(var i:int = 0; i < VAL_MAX; ++i){

            m_Gauge[i].visible = (i < m_Val);

        }

        m_NumberView.SetVal(m_Val);

    }

}



class Gauge_MP extends Sprite

{

    //==Const==



    //Max

    static public const VAL_MAX:int = 50;





    //==Var==



    //Val

    public var m_Val:int = VAL_MAX;



    //Gauge

    public var m_Gauge:Bitmap;



    //Number

    public var m_NumberView:NumberView;





    //==Function==



    //Init

    public function Gauge_MP(){

        var i:int;

        var bmp:Bitmap;



        var OffsetX:int = 4;



        //Label

        {

            bmp = ImageManager.GetBitmap_LabelMP();

            bmp.x = OffsetX;

            OffsetX += 32;

            addChild(bmp);

        }



        //Gauge BG

        {

            bmp = ImageManager.GetBitmap_GaugeMP_BG();

            bmp.x = OffsetX;

            addChild(bmp);

        }



        //Gauge

        {

            bmp = ImageManager.GetBitmap_GaugeMP();

            bmp.x = OffsetX;

            addChild(bmp);

            m_Gauge = bmp;



            OffsetX += 80;

        }



        //Number

        {

            m_NumberView = new NumberView(NumberView.COLOR_BLUE);

            m_NumberView.x = 176;

            m_NumberView.y = 0;

            m_NumberView.SetVal(m_Val);

            addChild(m_NumberView);

        }

    }



    //

    public function AddVal(in_Val:int):void{

        m_Val += in_Val;

        if(m_Val < 0){m_Val = 0;}

        if(VAL_MAX < m_Val){m_Val = VAL_MAX;}



        //表示の更新

        m_Gauge.scaleX = 1.0 * m_Val / VAL_MAX;

        m_NumberView.SetVal(m_Val);

    }

}





class Player extends Sprite

{

    //==Const==



    static public const JUMP_VY:Number = -100;

    static public const GRAVITY:Number = 200;



    //アニメーション用パラメータ

    static public const ANIM_CYCLE:Number = 0.1;

    static public const ANIM_ITER:Array = [0,1,2,1];

    static public const ANIM_NUM:int = ANIM_ITER.length;





    //==Var==



    public var m_VY:Number = 0;

    public var m_JumpFlag:Boolean = false;



    public var m_GaugeHP:Gauge_HP;

    public var m_GaugeMP:Gauge_MP;



    //飛行エフェクト

    public var m_FlyEffect:Bitmap;



    //表示画像

    public var m_Bitmap:Bitmap = new Bitmap();//これの中身を差し替えることでアニメーションさせる



    //アニメーション用タイマー

    public var m_AnimTimer:Number = 0.0;



    //アニメーション用画像リスト

    public var m_BitmapDataList:Vector.<BitmapData> = new Vector.<BitmapData>(ImageManager.PLAYER_ANIM_NUM);



    //Flag

    public var m_ThisFrameDoneFlag:Boolean = false;





    //==Function==



    //Init

    public function Player(in_GaugeHP:Gauge_HP, in_GaugeMP:Gauge_MP){

        //Param

        {

            m_GaugeHP = in_GaugeHP;

            m_GaugeMP = in_GaugeMP;

        }



        //Graphic

        {//FlyEffect

            m_FlyEffect = ImageManager.CreateFlyEffect();

            m_FlyEffect.alpha = 0;

            addChild(m_FlyEffect);

        }

        {//Player

            //ロード

            {

                m_BitmapDataList = ImageManager.CreatePlayerGraphic();

            }



            //表示画像の登録

            {

                m_Bitmap.x = -24/2;

                m_Bitmap.y = -32/2;

                addChild(m_Bitmap);

            }

        }

    }



    //Jump

    public function OnJumpStart():void{

        m_JumpFlag = true;

    }

    public function OnJumpEnd():void{

        m_JumpFlag = false;

    }



    //Gauge

    public function AddHP(in_Val:int):void{

        if(m_ThisFrameDoneFlag){return;}//2つの爆弾に同時に当たることがあったので応急処置的な対応

        m_GaugeHP.AddVal(in_Val);

        m_ThisFrameDoneFlag = true;

    }

    public function AddMP(in_Val:int):void{

        m_GaugeMP.AddVal(in_Val);

    }



    //Update

    public function Update(in_DeltaTime:Number):void{

        Update_Coord(in_DeltaTime);



        Update_Anim(in_DeltaTime);



        m_ThisFrameDoneFlag = false;

    }



    //Update : Coord

    public function Update_Coord(in_DeltaTime:Number):void{

        //VY

        if(m_JumpFlag && 0 < m_GaugeMP.m_Val){

            //Jump

            m_VY = JUMP_VY;

            //MP

            m_GaugeMP.AddVal(-1);

        }else{

            //Fall

            m_VY += GRAVITY * in_DeltaTime;

        }



        //Y

        this.y += m_VY * in_DeltaTime;

        if(this.y < ResourceRunner.PLAYER_MIN_Y){

            this.y = ResourceRunner.PLAYER_MIN_Y;

            m_VY = 0;

        }

        if(ResourceRunner.PLAYER_MAX_Y < this.y){

            this.y = ResourceRunner.PLAYER_MAX_Y;

            m_VY = 0;

        }

    }



    //Update : Anim

    public function Update_Anim(in_DeltaTime:Number):void{

        //m_AnimTimer

        {

            m_AnimTimer += in_DeltaTime;

            if(m_AnimTimer > ANIM_CYCLE){m_AnimTimer -= ANIM_CYCLE;}

        }



        //m_AnimTimer => iter

        var iter:int;

        {

            iter = ANIM_ITER[int(ANIM_NUM * m_AnimTimer/ANIM_CYCLE)];

        }



        m_Bitmap.bitmapData = m_BitmapDataList[iter];



        //FlyEffect

        const ALPHA_TIME:Number = 0.2;

        if(m_JumpFlag && 0 < m_GaugeMP.m_Val){

            m_FlyEffect.alpha += in_DeltaTime / ALPHA_TIME;

            if(1 < m_FlyEffect.alpha){m_FlyEffect.alpha = 1;}

        }else{

            m_FlyEffect.alpha -= in_DeltaTime / ALPHA_TIME;

            if(m_FlyEffect.alpha < 0){m_FlyEffect.alpha = 0;}

        }

    }

}







class Gimmick extends Sprite

{

    //==Var==



    public var m_Rad:int = 16;



    public var m_DeadFlag:Boolean = false;





    //==Function==



    //Update

    public function Update(in_DeltaTime:Number):void{

        //Override

    }



    //Check : Hit

    public function IsHit(in_X:int, in_Y:int):Boolean{

        var PlayerRad:int = 12;

        var GapX:Number = in_X - this.x;

        var GapY:Number = in_Y - this.y;

        var Len:Number = Math.sqrt(GapX*GapX + GapY*GapY);

        return (Len < m_Rad + PlayerRad);

    }



    //OnHit

    public function OnHit(in_Player:Player):void{

        //Override

    }

}



//隣接するボムに共通のコレを持たせておき、どれかが爆発したらTrueにして他のボムに爆発を伝達

class ChainObj

{

    public var m_Flag :Boolean = false;

}



class Gimmick_Damage extends Gimmick

{

    //==Var==



    public var m_ChainObj:ChainObj = null;





    //==Function==



    //Init

    public function Gimmick_Damage(in_ChainObj:ChainObj){

        //Param

        {

            //当たり判定を小さめにして、プレイヤーと接触しにくいようにする

            m_Rad = 14;



            m_ChainObj = in_ChainObj;

        }



        //Graphic

        {

            addChild(ImageManager.CreateBitmap_GimmickDamage());

        }

    }



    //Update

    override public function Update(in_DeltaTime:Number):void{

        //誘爆

        if(m_ChainObj != null && m_ChainObj.m_Flag){

            //Effect

            {

                var effect:Gimmick = new Gimmick_Effect(Gimmick_Effect.TYPE_BOMB);

                effect.x = this.x;

                effect.y = this.y;

                ResourceRunner.Instance.AddGimmick(effect);

            }



            //Flag

            m_DeadFlag = true;



            m_ChainObj = null;

        }

    }



    //OnHit

    override public function OnHit(in_Player:Player):void{

        //プレイヤーにダメージ

        in_Player.AddHP(-2);



        //Effect

        {

            var effect:Gimmick = new Gimmick_Effect(Gimmick_Effect.TYPE_BOMB);

            effect.x = this.x;

            effect.y = this.y;

            ResourceRunner.Instance.AddGimmick(effect);

        }



        //誘爆伝達

        if(m_ChainObj != null){

            m_ChainObj.m_Flag = true;

            m_ChainObj = null;

        }



        m_DeadFlag = true;

    }

}



class Gimmick_CureHP extends Gimmick

{

    //==Function==



    //Init

    public function Gimmick_CureHP(){

        //Param

        {

            //当たり判定を大きめにして、プレイヤーと接触しやすいようにする

            m_Rad = 18;

        }



        //Graphic

        {

            addChild(ImageManager.CreateBitmap_GimmickCureHP());

        }

    }



    //OnHit

    override public function OnHit(in_Player:Player):void{

        //プレイヤーのHP回復

        in_Player.AddHP(+1);



        //Effect

        {

            var effect:Gimmick = new Gimmick_Effect(Gimmick_Effect.TYPE_ITEM);

            effect.x = this.x;

            effect.y = this.y;

            ResourceRunner.Instance.AddGimmick(effect);

        }



        m_DeadFlag = true;

    }

}



class Gimmick_CureMP extends Gimmick

{

    //==Function==



    //Init

    public function Gimmick_CureMP(){

        //Param

        {

            //当たり判定を大きめにして、プレイヤーと接触しやすいようにする

            m_Rad = 18;

        }



        //Graphic

        {

            addChild(ImageManager.CreateBitmap_GimmickCureMP());

        }

    }



    //OnHit

    override public function OnHit(in_Player:Player):void{

        //プレイヤーのMP回復

        in_Player.AddMP(+25);



        //Effect

        {

            var effect:Gimmick = new Gimmick_Effect(Gimmick_Effect.TYPE_ITEM);

            effect.x = this.x;

            effect.y = this.y;

            ResourceRunner.Instance.AddGimmick(effect);

        }



        m_DeadFlag = true;

    }

}





class Gimmick_Effect extends Gimmick

{

    //==Const==



    static public const VANISH_TIME:Number = 0.2;



    static public var s_TypeIter:int = 0;

    static public const TYPE_BOMB    :int = s_TypeIter++;

    static public const TYPE_ITEM    :int = s_TypeIter++;

    static public const TYPE_NUM    :int = s_TypeIter;





    //==Function==



    //Init

    public function Gimmick_Effect(in_Type:int){

        //Graphic

        {

            addChild(ImageManager.CreateBitmap_GimmickEffect(in_Type));

            this.blendMode = BlendMode.ADD;

        }

    }

    

    //Update

    override public function Update(in_DeltaTime:Number):void{

        this.alpha -= in_DeltaTime / VANISH_TIME;

        this.scaleX = this.scaleY = 1 + 5 * (1 - this.alpha);



        if(this.alpha <= 0){

            this.alpha = 0;

            m_DeadFlag = true;

        }

    }

}





class ImageManager

{

    //==Const==



    static public const PLAYER_ANIM_NUM:int = 3;



    static public const BG_PANEL_W:int = 32;





    //==Var==



    //Gauge : HP

    static public var m_BitmapData_LabelHP        :BitmapData = new BitmapData(32, 16, true, 0x00000000);

    static public var m_BitmapData_GaugeHP        :BitmapData = new BitmapData(16, 16, true, 0x00000000);



    //Gauge : MP

    static public var m_BitmapData_LabelMP        :BitmapData = new BitmapData(32, 16, true, 0x00000000);

    static public var m_BitmapData_GaugeMP        :BitmapData = new BitmapData(80, 16, true, 0x00000000);

    static public var m_BitmapData_GaugeMP_BG    :BitmapData = new BitmapData(80, 16, true, 0x00000000);



    //Score

    static public var m_BitmapData_LabelScore    :BitmapData = new BitmapData(80, 16, true, 0x00000000);



    //Number

    static public var m_BitmapData_Number        :Vector.<Vector.<BitmapData> > = new Vector.<Vector.<BitmapData> >(NumberView.COLOR_NUM);



    //Player

    static public var m_BitmapDataVec_Player    :Vector.<BitmapData> = new Vector.<BitmapData>(PLAYER_ANIM_NUM);

    static public var m_BitmapData_FlyEffect        :BitmapData = new BitmapData(32, 16, true, 0x00000000);



    //BG

    static public var m_BitmapData_BG_Far            :BitmapData = new BitmapData(32, 32, false, 0x000000);

    static public var m_BitmapData_BG_Near            :BitmapData = new BitmapData(64, 32, true,  0x00000000);



    //Gimmick

    static public var m_BitmapData_GimmickDamage    :BitmapData = new BitmapData(16, 16, true, 0x00000000);

    static public var m_BitmapData_GimmickCureHP    :BitmapData = new BitmapData(16, 16, true, 0x00000000);

    static public var m_BitmapData_GimmickCureMP    :BitmapData = new BitmapData(16, 16, true, 0x00000000);



    //Effect

    static public var m_BitmapData_Effect    :Vector.<BitmapData> = new Vector.<BitmapData>(Gimmick_Effect.TYPE_NUM);





    //==Function==



    //Init

    static public function Init(in_Graphic:DisplayObject):void{

        var i:int, j:int;

        var mtx:Matrix = new Matrix();

        var tmp:BitmapData = new BitmapData(16, 16, true, 0x00000000);

        var rect:Rectangle = new Rectangle(0, 0, 16, 16);

        var pos:Point = new Point(0,0);

        var shape:Shape = new Shape();

        var g:Graphics = shape.graphics;



        //Gauge : HP : Label

        {

            mtx.tx = 0;

            mtx.ty = 0;

            m_BitmapData_LabelHP.draw(in_Graphic, mtx);

        }

        //Gauge : HP : Bar

        {

            mtx.tx = -32;

            mtx.ty = 0;

            m_BitmapData_GaugeHP.draw(in_Graphic, mtx);

        }



        //Gauge : MP : Label

        {

            mtx.tx = 0;

            mtx.ty = -16;

            m_BitmapData_LabelMP.draw(in_Graphic, mtx);

        }

        //Gauge : MP : Bar

        {

            mtx.tx = -32;

            mtx.ty = -16;

            tmp.fillRect(tmp.rect, 0x00000000);

            tmp.draw(in_Graphic, mtx);

            //L

            rect.x = 0; rect.y = 0; rect.width = 8; rect.height = 16;

            pos.x = 0; pos.y = 0;

            m_BitmapData_GaugeMP.copyPixels(tmp, rect, pos);

            //R

            rect.x = 8; rect.y = 0; rect.width = 8; rect.height = 16;

            pos.x = 80-8; pos.y = 0;

            m_BitmapData_GaugeMP.copyPixels(tmp, rect, pos);

            //C

            rect.x = 7; rect.y = 0; rect.width = 1; rect.height = 16;

            pos.y = 0;

            for(i = 8; i < 80-8; ++i){

                pos.x = i;

                m_BitmapData_GaugeMP.copyPixels(tmp, rect, pos);

            }

        }

        //Gauge : MP : BG

        {

            mtx.tx = -48;

            mtx.ty = -16;

            tmp.fillRect(tmp.rect, 0x00000000);

            tmp.draw(in_Graphic, mtx);

            //L

            rect.x = 0; rect.y = 0; rect.width = 8; rect.height = 16;

            pos.x = 0; pos.y = 0;

            m_BitmapData_GaugeMP_BG.copyPixels(tmp, rect, pos);

            //R

            rect.x = 8; rect.y = 0; rect.width = 8; rect.height = 16;

            pos.x = 80-8; pos.y = 0;

            m_BitmapData_GaugeMP_BG.copyPixels(tmp, rect, pos);

            //C

            rect.x = 7; rect.y = 0; rect.width = 1; rect.height = 16;

            pos.y = 0;

            for(i = 8; i < 80-8; ++i){

                pos.x = i;

                m_BitmapData_GaugeMP_BG.copyPixels(tmp, rect, pos);

            }

        }



        //Label

        {

            mtx.tx = -3*16;

            mtx.ty = -6*16;

            m_BitmapData_LabelScore.draw(in_Graphic, mtx);

        }



        //m_BitmapData_Number

        {

            for(i = 0; i < NumberView.COLOR_NUM; ++i){

                m_BitmapData_Number[i] = new Vector.<BitmapData>(10);

                for(j = 0; j < 10; ++j){

                    var bmd:BitmapData = new BitmapData(16, 16, true, 0x00000000);

                    mtx.tx = -int(j % 5) * 16 - 0;

                    mtx.ty = -int(j / 5) * 16 - 128 - 32*i;

                    bmd.draw(in_Graphic, mtx);

                    m_BitmapData_Number[i][j] = bmd;

                }

            }

        }



        //Player

        {

            mtx.ty = -32;

            for(i = 0; i < PLAYER_ANIM_NUM; ++i){

                mtx.tx = i * -24;

                m_BitmapDataVec_Player[i] = new BitmapData(24, 32, true, 0x00000000);

                m_BitmapDataVec_Player[i].draw(in_Graphic, mtx);

            }

        }



        //m_BitmapData_FlyEffect

        {

            var Offset:int = 2;

            g.clear();

            g.lineStyle(2, 0x88AAFF, 1.0);

            g.drawEllipse(Offset, Offset, 32-2*Offset, 16-2*Offset);

            g.moveTo(32/2, Offset+2);

            g.lineTo(16-6, 8+2);

            g.lineTo(16+6, 8+2);

            g.lineTo(32/2, Offset+2);

            m_BitmapData_FlyEffect.draw(shape);

        }



        //BG

        {

            mtx.tx = 0;

            mtx.ty = -64;

            m_BitmapData_BG_Near.draw(in_Graphic, mtx);



            mtx.tx = 0;

            mtx.ty = -96;

            m_BitmapData_BG_Far.draw(in_Graphic, mtx);

        }



        //Gimmick : Damage

        {

            mtx.tx = -64;

            mtx.ty = 0;

            m_BitmapData_GimmickDamage.draw(in_Graphic, mtx);

        }

        //Gimmick : CureHP

        {

            mtx.tx = -80;

            mtx.ty = 0;

            m_BitmapData_GimmickCureHP.draw(in_Graphic, mtx);

        }

        //Gimmick : CureMP

        {

            mtx.tx = -96;

            mtx.ty = 0;

            m_BitmapData_GimmickCureMP.draw(in_Graphic, mtx);

        }



        //Effect

        {

            for(i = 0; i < Gimmick_Effect.TYPE_NUM; ++i){

                m_BitmapData_Effect[i] = new BitmapData(16, 16, true, 0x00000000);



                g.clear();

                switch(i){

                case Gimmick_Effect.TYPE_BOMB:

                    g.lineStyle(4, 0xFF8800, 1.0);

                    g.beginFill(0xFFFF00, 1.0);

                    g.drawCircle(16/2, 16/2, 16/2 - 4);

                    g.endFill();

                    break;

                case Gimmick_Effect.TYPE_ITEM:

                    g.lineStyle(4, 0x00FFFF, 1.0);

                    g.beginFill(0xFFFFFF, 1.0);

                    g.drawCircle(16/2, 16/2, 16/2 - 4);

                    g.endFill();

                    break;

                }



                m_BitmapData_Effect[i].draw(shape);

            }

        }

    }



    //Get

    static public function GetBitmap_LabelHP():Bitmap{

        return new Bitmap(m_BitmapData_LabelHP);

    }

    static public function GetBitmap_GaugeHP():Bitmap{

        return new Bitmap(m_BitmapData_GaugeHP);

    }

    static public function GetBitmap_LabelMP():Bitmap{

        return new Bitmap(m_BitmapData_LabelMP);

    }

    static public function GetBitmap_GaugeMP():Bitmap{

        return new Bitmap(m_BitmapData_GaugeMP);

    }

    static public function GetBitmap_GaugeMP_BG():Bitmap{

        return new Bitmap(m_BitmapData_GaugeMP_BG);

    }

    static public function GetBitmap_LabelScore():Bitmap{

        return new Bitmap(m_BitmapData_LabelScore);

    }

    static public function CreatePlayerGraphic():Vector.<BitmapData>{

        return m_BitmapDataVec_Player;

    }

    static public function CreateNumberGraphic(in_ColorIndex:int):Vector.<BitmapData>{

        return m_BitmapData_Number[in_ColorIndex];

    }



    static public function CreateFlyEffect():Bitmap{

        var bmp:Bitmap = new Bitmap(m_BitmapData_FlyEffect);

        bmp.x = -16;

        bmp.y += 8;

        bmp.blendMode = BlendMode.ADD;

        return bmp;

    }



    static public function CreateBitmap_GimmickDamage():Bitmap{

        var bmp:Bitmap = new Bitmap(m_BitmapData_GimmickDamage);

        bmp.x = -bmp.width/2;

        bmp.y = -bmp.height/2;

        return bmp;

    }

    static public function CreateBitmap_GimmickCureHP():Bitmap{

        var bmp:Bitmap = new Bitmap(m_BitmapData_GimmickCureHP);

        bmp.x = -bmp.width/2;

        bmp.y = -bmp.height/2;

        return bmp;

    }

    static public function CreateBitmap_GimmickCureMP():Bitmap{

        var bmp:Bitmap = new Bitmap(m_BitmapData_GimmickCureMP);

        bmp.x = -bmp.width/2;

        bmp.y = -bmp.height/2;

        return bmp;

    }



    static public function CreateBitmap_GimmickEffect(in_Type:int):Bitmap{

        var bmp:Bitmap = new Bitmap(m_BitmapData_Effect[in_Type]);

        bmp.x = -bmp.width/2;

        bmp.y = -bmp.height/2;

        return bmp;

    }



    static public function CreateBitmap_BG_Near(in_MinW:int, in_MinH:int):Bitmap{

        //Size

        var NumX:int = int(in_MinW / (2*BG_PANEL_W)) + 2;

        var NumY:int = 1;

        var BmdW:int = NumX * (2*BG_PANEL_W);

        var BmdH:int = NumY * BG_PANEL_W;

        var bmd:BitmapData = new BitmapData(BmdW, BmdH, true, 0x00000000);



        //Draw

        var pos:Point = new Point(0,0);

        var rect:Rectangle = m_BitmapData_BG_Near.rect;

        for(var y:int = 0; y < NumY; ++y){

            pos.y = y * BG_PANEL_W;

            for(var x:int = 0; x < NumX; ++x){

                pos.x = x * (2*BG_PANEL_W);

                bmd.copyPixels(m_BitmapData_BG_Near, rect, pos);

            }

        }



        var bmp:Bitmap = new Bitmap(bmd);

        bmp.y = in_MinH - BG_PANEL_W;



        return bmp;

    }



    static public function CreateBitmap_BG_Far(in_MinW:int, in_MinH:int):Bitmap{

        //Size

        var NumX:int = int(in_MinW / BG_PANEL_W) + 2;

        var NumY:int = int(in_MinH / BG_PANEL_W) + 2;

        var BmdW:int = NumX * BG_PANEL_W;

        var BmdH:int = NumY * BG_PANEL_W;

        var bmd:BitmapData = new BitmapData(BmdW, BmdH, false, 0x000000);



        //Draw

        var pos:Point = new Point(0,0);

        var rect:Rectangle = m_BitmapData_BG_Far.rect;

        for(var y:int = 0; y < NumY; ++y){

            pos.y = y * BG_PANEL_W;

            for(var x:int = 0; x < NumX; ++x){

                pos.x = x * BG_PANEL_W;

                bmd.copyPixels(m_BitmapData_BG_Far, rect, pos);

            }

        }



        return new Bitmap(bmd);

    }

}







//*

//bkzenさんのコードを利用

//@see http://wonderfl.net/c/cuY4

//@see http://wonderfl.net/c/kYyY

class ScoreWindowLoader

{

    private static var _top: DisplayObjectContainer;

    private static var _api: WonderflAPI;

    private static var _content: Object;

    //private static const URL: String = "wonderflScore.swf";

    private static const URL: String = "http://swf.wonderfl.net/swf/usercode/5/57/579a/579a46e1306b5770d429a3738349291f05fec4f3.swf";

    private static const TWEET: String = "Playing Run & Hover [score: %SCORE%] #wonderfl";

    

    public static function init(top: DisplayObjectContainer, api: WonderflAPI): void 

    {

        _top = top, _api = api;

        var loader: Loader = new Loader();

        var comp: Function = function(e: Event): void

        {

            loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, comp);

            _content = loader.content;

//            handler();

        }

        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, comp);

        loader.load(new URLRequest(URL), new LoaderContext(true));

    }

    

    public static function show( score: int): void

    {

        var window: DisplayObject = _content.makeScoreWindow(_api, score, "Run & Hover", 1, TWEET);

//        var close: Function = function(e: Event): void

//        {

//            window.removeEventListener(Event.CLOSE, close);

//            closeHandler();

//        }

//        window.addEventListener(Event.CLOSE, close);

        _top.addChild(window);

    }

    

}

//*/