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

角丸シューティング

シンプルなシューティングゲーム
クリック:弾の切り替え
ESCキー:STAGE1からやり直し
/**
 * Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/kQBf
 */

// forked from shohei909's LIVE CODING  一日でシューティングゲーム作る on 2010-3-30
package {
    import flash.display.BitmapData;
    import flash.display.Bitmap;
/*
  シンプルなシューティングゲーム
    クリック:弾の切り替え
    ESCキー:STAGE1からやり直し
*/
    import flash.display.Sprite;
    import flash.events.*;
    import flash.text.*;
    import flash.utils.*; 
    import net.wonderfl.score.basic.BasicScoreForm;
    import net.wonderfl.score.basic.BasicScoreRecordViewer;
     public class Game extends Sprite {
                private static const HEIGHT:Number = 465;
                private static const WIDTH:Number = 465;
                private var point:int=0; 
                private var time:int=0; 
                private var lastTime:int=0;
                private var startTime:int=0;
                private var shadow:MyShipShape = new MyShipShape();
                
                private var myShip:MyShip;
                private var field:Sprite = new Sprite();
                
                
                private var textfield:TextField;
                private var title:TitleField;
                
                private var myShot:Vector.<Shot>;
                private var enemyShot:Vector.<Shot>;
                private var bomb:Vector.<Shot>;
                
                private var enemy:Vector.<Enemy>;
                private var dead:Vector.<Enemy>;

                private var shotType:int = 0;
                private var wave:int = 0;
                private var save:int = 0;
                
                private var waveCount:int = 0;
                
                private var frameCount:uint=0;
                
                private var lifeBar:LifeBar = new LifeBar();
                
                private var play:Boolean = false;
                private var setting:Boolean = true;
                    
                private var r:Number = 0;
                
                public function Game():void{
                    field= new Sprite();
                    textfield= new TextField();
                    title= new TitleField();
                    with(textfield){
                        width=400;
                        selectable=false;
                        defaultTextFormat = new TextFormat("", 12, 0x0, true);
                    }
                    textfield.y=447;
                    with(title){
                        antiAliasType = AntiAliasType.ADVANCED;
                        y=415;
                        x=0;
                        width=455; 
                        selectable=false;
                    }
                    
                    stage.addChild(field);
                    stage.addChild(title);
                    stage.addChild(textfield);
                    
                    lifeBar = new LifeBar();
                    with(field.graphics){
                        lineStyle (4, 0x000000, 1.0);    // 線のスタイル指定
                        beginFill (0xFEFEEE, 1.0);    // 面のスタイル設定
                        drawRoundRect ( 0,0, 465 , 465 , 15 , 16);
                    }
                    stage.addEventListener(MouseEvent.MOUSE_DOWN,onClick);
                    stage.addEventListener(KeyboardEvent.KEY_DOWN,onKey);
                    restart();
                    
                    
                    var b:Bitmap = new Bitmap( new BitmapData(1,1,false,0) );
                    b.scaleX = b.scaleY = 465;
                    field.addChild(b);
                    field.mask = b;
                    
                }
                public function onKey(e:KeyboardEvent):void{
                    if(e.keyCode==27){
                        wave=0;
                        restart();
                    }
                }
                public function reset():void{
                    title.setText("CONTINUE?",-1);
                    setting = true;
                }
                public function restart():void{
                    title.setText("",-1);
                    while(field.numChildren>0){
                        field.removeChildAt(0);
                    }
                    stage.addChild(lifeBar);
                    
                    point = 0; 
                    time = 0;
                    lastTime = getTimer();
                    startTime = getTimer();
                        
                    shadow = new MyShipShape();
                    
                    
                    
                    
                    
                    
                    
                    
                    myShot = new Vector.<Shot>();
                    enemyShot = new Vector.<Shot>();
                    bomb = new Vector.<Shot>();
                    
                    enemy = new Vector.<Enemy>();
                    dead = new Vector.<Enemy>();
    
                    shotType = 0;
                    
                    wave = save;
                    waveCount = 0;
                    
                    frameCount = 0;
                    
                    
                    
                    play = true;
                    setting = false;
                    myShip = new MyShip();
                    
                    
                    myShip.skeleton=true;
                    
                    lifeBar.x=10;
                    lifeBar.y=430;
                    lifeBar.life = 5;
                    
                    
                    field.addChild(myShip);
                    
                    
                    
                    
                    //リスナーの追加
                    this.addEventListener(Event.ENTER_FRAME,onEnterFrame);
                }

                public function addMyShot(dx:Number, dy:Number, power:int):void{
                    var shot:Shot = new Shot(true);
                
                    shot.setData(dx, dy, 10, power);
                    shot.x = myShip.x;
                    shot.y = myShip.y;
                    myShot.push(shot);
                    field.addChildAt(shot,0);
                }
                
                public function addEnemyShot(x:Number, y:Number,dx:Number, dy:Number, power:int):void{
                    var shot:Shot = new Shot(false);
                
                    shot.setData(dx, dy, 7, power);
                    shot.x = x;
                    shot.y = y;
                    enemyShot.push(shot);
                    field.addChildAt(shot,0);
                }


                public function addEnemy(x:int, y:int,t:int=1):Enemy{
                    var ship:Enemy = new Enemy(t);
                    ship.x = x;
                    ship.y = y;
                    enemy.push(ship);
                    if(t==5){field.addChildAt(ship,0);}
                    else{field.addChild(ship);}
                    return ship;
                }
                
                public function damage():void{
                    myShip.skeleton = true;
                    if(lifeBar.life==0){
                        gameOver();
                    }else{
                        lifeBar.life--;
                    }
                    
                    shadow.x=myShip.x;
                    shadow.y=myShip.y;
                    shadow.count=0;
                    shadow.alpha=1;
                    field.addChildAt(shadow,0);
                }
                
                
                private function onEnterFrame(e:Event):void{
                    textfield.text="";
                    //自機の移動
                    myShip.x=(field.mouseX+myShip.x*3)/4;
                    myShip.y=(field.mouseY+myShip.y*3)/4;
                    if(myShip.x<0){myShip.x=0;}
                    if(myShip.y<0){myShip.y=0;}
                    if(myShip.x>465){myShip.x=465;}
                    if(myShip.x>465){myShip.y=465;}
                    
                    
                    if(play){
                        frameCount++;
                        if(frameCount==5){
                            var speed:Number = 18;
                            switch(shotType){
                                case 0:
                                    addMyShot(0,-speed,10);
                                    break;
                                case 1:
                                    addMyShot(speed*Math.sin(3/4*Math.PI),speed*Math.cos(3/4*Math.PI),10);
                                    addMyShot(speed*Math.sin(-3/4*Math.PI),speed*Math.cos(-3/4*Math.PI),10);
                                    break;
                                case 2:
                                    addMyShot(0,speed,10);
                                    addMyShot(speed*Math.sin(1/4*Math.PI),speed*Math.cos(1/4*Math.PI),10);
                                    addMyShot(speed*Math.sin(-1/4*Math.PI),speed*Math.cos(-1/4*Math.PI),10);
                                    addMyShot(speed*Math.sin(1/2*Math.PI),speed*Math.cos(1/2*Math.PI),10);
                                    addMyShot(speed*Math.sin(-1/2*Math.PI),speed*Math.cos(-1/2*Math.PI),10);
                                    break;
                            }
                            frameCount=0;
                        }
                        
                        
                        //自機の弾と敵のあたり判定
                        for(var j:int=0; j<enemy.length; j++){    
                            for(i=0; i<myShot.length; i++){
                                if(enemy[j].hitTestPoint ( myShot[i].x , myShot[i].y , true )){
                                    enemy[j].life -= myShot[i].power;
                                    myShot[i].life=0;
                                    enemy[j].x+=myShot[i].dx/2;
                                    enemy[j].y+=myShot[i].dy/2;
                                    
                                    point+=10;
                                }
                            }
                            for(i=0; i<enemyShot.length; i++){
                                if(enemy[j].hitTestPoint ( enemyShot[i].x , enemyShot[i].y , true )){
                                    enemy[j].life -= enemyShot[i].power;
                                    enemyShot[i].life=0;
                                    enemy[j].x+= enemyShot[i].dx/2;
                                    enemy[j].y+= enemyShot[i].dy/2;
                                }
                            }
                        }
                        
                    
                        
                        //自機と敵のあたり判定
                        if(myShip.skeleton == false){
                            for(i=0; i<enemyShot.length; i++){
                                if(myShip.hitTestPoint ( enemyShot[i].x , enemyShot[i].y , true )){
                                    damage();
                                    enemyShot[i].life=0;
                                }
                            }
                            for(j = 0; j<enemy.length; j++){
                                if(enemy[j].hitTestPoint(myShip.x,myShip.y,true)){
                                    damage();
                                }
                            }
                        }
                        //自機の弾と敵の弾のあたり判定
                        for(i=0; i<myShot.length; i++){
                            for(j=0; j<enemyShot.length; j++){
                                if(myShot[i].hitTestObject( enemyShot[j] )){
                                    enemyShot[j].life=0;
                                    myShot[i].life=0;
                                    point += 50;
                                }
                            }
                        }
                    }
                    
                    lastTime = time;
                    time=getTimer()-startTime;
                    textfield.appendText(" point:" + point + "  time:"+time);
                    
                    
                    
                    //自機の弾の移動
                    for(var i:int=0; i<myShot.length; i++){
                        myShot[i].x += myShot[i].dx;
                        myShot[i].y += myShot[i].dy;
                        
                        if(myShot[i].y < 0 || myShot[i].y > 465 || myShot[i].x < 0 ||myShot[i].x > 465){
                            if(field.contains(myShot[i])){field.removeChild(myShot[i]);}
                            myShot.splice(i,1);
                            i--;
                        }else if(myShot[i].life == 0){
                            myShot[i].count=0;
                            if(field.contains(myShot[i])){field.removeChild(myShot[i]);}
                            bomb.push(myShot[i]);
                            field.addChildAt(bomb[bomb.length-1],0);
                            myShot.splice(i,1);
                            i--;
                        }
                    }
                    
                    //敵の弾の移動
                    for(i=0; i<enemyShot.length; i++){
                        enemyShot[i].x += enemyShot[i].dx;
                        enemyShot[i].y += enemyShot[i].dy;
                        
                        if(enemyShot[i].y < 0 || enemyShot[i].y > 465){
                            enemyShot[i].dy*=-1;
                            enemyShot[i].life--;
                        }
                        if(enemyShot[i].x < 0 || enemyShot[i].x > 465){
                            enemyShot[i].dx*=-1;
                            enemyShot[i].life--;
                        }
                        if(enemyShot[i].life <= 0){
                            enemyShot[i].count=0;
                            if(field.contains(enemyShot[i])){field.removeChild(enemyShot[i]);}
                            bomb.push(enemyShot[i]);
                            field.addChildAt(bomb[bomb.length-1],0);
                            enemyShot.splice(i,1);
                            i--;
                        }
                    }
                    
                    
                    
                    //敵の移動
                    for( i=0; i<enemy.length; i++){
                        switch(enemy[i].type){
                            case 1:
                                if(enemy[i].count == 60){
                                    enemy[i].count = 0;
                                }
                                if(enemy[i].count == 0){
                                    enemy[i].dx = 7;
                                    enemy[i].dy = 7;
                                }

                                if(enemy[i].count == 30){
                                    enemy[i].dx = -7;
                                    enemy[i].dy = 7;
                                }
                                
                                enemy[i].x += enemy[i].dx;
                                enemy[i].y += enemy[i].dy;
                                enemy[i].dx = enemy[i].dx*15/16;
                                enemy[i].dy = enemy[i].dy*15/16;
                                break;
                            case 2:
                                enemy[i].rotation+=enemy[i].speed;
                                if(enemy[i].count == 100){
                                    enemy[i].count = 0;
                                }
                                if(enemy[i].count == 0){
                                    enemy[i].speed = 20;
                                    enemy[i].dx = (myShip.x - enemy[i].x) ;
                                    enemy[i].dy = (myShip.y - enemy[i].y) ;
                                    var s:Number = Math.sqrt(enemy[i].dx*enemy[i].dx + enemy[i].dy*enemy[i].dy);

                                    enemy[i].dx /= s;
                                    enemy[i].dy /= s;
                                }
                                enemy[i].speed *= 20/21;
                                

                                enemy[i].x += enemy[i].dx * enemy[i].speed;
                                enemy[i].y += enemy[i].dy * enemy[i].speed;
                                if(enemy[i].life<(enemy[i].rank * 180 - 200)){
                                    enemy[i].rank--;
                                    var en:Enemy = enemy[i].drowEnemy2(3);
                                    en.x=enemy[i].x;en.y=enemy[i].y;en.rotation=enemy[i].rotation;
                                    dead.push(en);
                                    field.addChild(en);
                                }
                                break;
                            case 3:
                                enemy[i].rotation+=enemy[i].speed*2;
                                enemy[i].speed = 2;
                                enemy[i].dx = (myShip.x - enemy[i].x) ;
                                enemy[i].dy = (myShip.y - enemy[i].y) ;
                                s = Math.sqrt(enemy[i].dx*enemy[i].dx + enemy[i].dy*enemy[i].dy);
                                enemy[i].dx /= s;
                                enemy[i].dy /= s;
                                

                                enemy[i].x += enemy[i].dx * enemy[i].speed;
                                enemy[i].y += enemy[i].dy * enemy[i].speed;
                                if(enemy[i].life<=(enemy[i].rank * 400 - 400)){
                                    enemy[i].rank--;
                                    en = enemy[i].drowEnemy3(10);
                                    en.x=enemy[i].x;en.y=enemy[i].y;en.rotation=enemy[i].rotation;
                                    en.count=50;
                                    enemy.push(en);
                                    field.addChild(en);
                                }
                                break;
                                
                            case 4:
                                
                                if(enemy[i].life==0){
                                    var d:Number = Math.random()*2;
                                    s = 9;
                                    
                                    
                                    addEnemyShot(enemy[i].x,enemy[i].y,s*Math.cos(d*Math.PI),s*Math.sin(d*Math.PI),10);
                                    addEnemyShot(enemy[i].x,enemy[i].y,s*Math.cos((d+0.5)*Math.PI),s*Math.sin((d+0.5)*Math.PI),10);
                                }
                                if(enemy[i].count == 100){
                                    enemy[i].count = 0;
                                }
                                if(enemy[i].count == 0){
                                    enemy[i].dx = Math.random()-0.5;
                                    enemy[i].dy = Math.random()-0.5;
                                    enemy[i].speed = 13;
                                    
                                    s = Math.sqrt(enemy[i].dx*enemy[i].dx + enemy[i].dy*enemy[i].dy);

                                    enemy[i].dx /= s;
                                    enemy[i].dy /= s;
                                }
                                enemy[i].speed *= 127/128;
                                
                                enemy[i].x += enemy[i].dx * enemy[i].speed;
                                enemy[i].y += enemy[i].dy * enemy[i].speed;
                                
                                break;
                                
                            case 5:
                                enemy[i].x = (enemy[i].dx + enemy[i].x*15)/16;
                                enemy[i].y = (enemy[i].dy + enemy[i].y*15)/16;
                                if(enemy[i].count < 90){
                                    enemy[i].life += 30;
                                    enemy[i].bf_life += 30; 
                                    enemy[i].drowEnemy5();
                                }else if(enemy[i].life != enemy[i].bf_life){
                                    enemy[i].bf_life = enemy[i].life;
                                   var k:int = 1;
                                   if(enemy[i].life<=0){k=30;}
                                   
                                   for(var m:int =0;m<k;m++){
                                        var en = addEnemy(enemy[i].x,enemy[i].y,4);
                                        en.dx = Math.sin(Math.PI*2*Math.random());
                                        en.dy = -Math.cos(Math.PI*Math.random());
                                   }
                                    enemy[i].drowEnemy5();
                                }
                                
                                break;
                        }
                        enemy[i].count++;
                        
                        
                        
                        if(enemy[i].x < -40){
                            enemy[i].x=505;
                        }
                        if(enemy[i].x > 505){
                            enemy[i].x=-40;
                        }
                        if(enemy[i].y > 515){
                            enemy[i].y= -100;
                        }
                        if(enemy[i].y <-100){
                            enemy[i].y= 515;
                        }
                        if(enemy[i].life <= 0){
                            point+=500
                            
                            enemy[i].count=0;
                            field.removeChild(enemy[i]);
                            dead.push(enemy[i]);
                            field.addChild(dead[dead.length-1]);
                            enemy.splice(i,1);
                            
                            i--;
                            
                        }
                    }
                    
                    //敵の破壊エフェクト
                    for(i=0; i<dead.length; i++){
                        dead[i].count++;
                        dead[i].alpha= 1 - dead[i].count/5;
                        dead[i].scaleX= dead[i].count/2;
                        dead[i].scaleY= dead[i].count/2;
                        if(dead[i].count == 20){
                            field.removeChild(dead[i]);
                            dead.splice(i,1);
                        }
                    }
                    
                    
                    
                    //弾の爆発エフェクト
                    for(i=0; i<bomb.length; i++){
                        bomb[i].count++;
                        bomb[i].scaleX = bomb[i].count;
                        bomb[i].scaleY = bomb[i].count;
                        if(bomb[i].count == 5){
                            field.removeChild(bomb[i]);
                            bomb.splice(i,1);
                        }
                    }
                    
                    
                    
                    



                    
                    //自機の破壊エフェクト
                    if(field.contains(shadow)){
                        shadow.count++;
                        shadow.alpha= 1 - shadow.count/5;
                        shadow.scaleX= shadow.count;
                        shadow.scaleY= shadow.count;
                        if(shadow.count == 5){
                            field.removeChild(shadow);
                        }
                    }
                    
                    
                    
                    
                    
                    
                    switch(wave){
                        case 0:
                            save = wave;
                            title.setText("STAGE 1",100);
                            waveCount++;if(waveCount>30){wave++;}
                            break;
                        case 1:
                            addEnemy(200,-40);addEnemy(150,-35);addEnemy(100,-25);
                            waveCount=0;wave++;
                            break;
                        case 2:
                            waveCount++;if(waveCount>40){wave++;}
                            break;
                        case 3:
                            addEnemy(365,-40);addEnemy(315,-35);addEnemy(265,-25);
                            waveCount=0;wave++;
                            break;
                        case 4:
                            if(enemy.length==0){
                                waveCount++;if(waveCount>40){wave++;}
                            }
                            break;
                            
                            
                            
                            
                            
                            
                        case 5:
                            addEnemy(0,-25);addEnemy(50,-25);addEnemy(100,-25);addEnemy(150,-25);
                            addEnemy(200,-25);addEnemy(250,-25);addEnemy(300,-25);addEnemy(350,-25);
                            addEnemy(400,-25);
                            waveCount=0;wave++;
                            break;
                        case 6:
                            waveCount++;if(waveCount>60){wave++;}
                            break;
                        case 7:
                            addEnemy(0,-25);addEnemy(200,-25);addEnemy(400,-25);
                            waveCount=0;wave++;
                            break;
                        case 8:
                            if(enemy.length==0){
                                waveCount++;if(waveCount>80){waveCount=0;wave++;}
                            }
                            break;
                            
                            
                            
                            
                            
                        case 9:
                            addEnemy(0,-25);addEnemy(50,-25);addEnemy(100,-25);addEnemy(150,-25);
                            addEnemy(200,-25);addEnemy(250,-25);addEnemy(300,-25);addEnemy(350,-25);
                            addEnemy(400,-25);
                            waveCount=0;wave++;
                            break;
                        case 10:
                            waveCount++;if(waveCount>30){waveCount=0;wave++;}
                            break;
                        case 11:
                            waveCount++;
                            if(waveCount%5==0){
                                r = Math.random()/2 + r;
                                if(r>1){r--;}
                                addEnemy(r*485-20,-25);
                            }
                            if(waveCount>100){waveCount=0;wave++;}
                            break;
                        case 12:
                            if(enemy.length==0){
                                waveCount++;if(waveCount>80){waveCount=0;wave++;}
                            }
                            break;
                            
                            
                            
                            
                            
                            
                            
                        case 13:
                            waveCount++;
                            if(waveCount%4==0){
                                r = Math.random()/2 + r;
                                if(r>1){r--;}
                                addEnemy(r*485-20,-25);
                            }
                            if(waveCount>80){waveCount=0;wave++;}
                            break;
                        case 14:
                            addEnemy(0,-25);addEnemy(50,-25);addEnemy(100,-25);addEnemy(150,-25);
                            addEnemy(200,-25);addEnemy(250,-25);addEnemy(300,-25);addEnemy(350,-25);
                            addEnemy(400,-25);addEnemy(450,-25);
                            waveCount=0;wave++;
                            break;
                        case 15:
                            waveCount++;if(waveCount>10){waveCount=0;wave++;}
                            break;
                        case 16:
                            addEnemy(0,-25);addEnemy(50,-25);addEnemy(100,-25);addEnemy(150,-25);
                            addEnemy(200,-25);addEnemy(250,-25);addEnemy(300,-25);addEnemy(350,-25);
                            addEnemy(400,-25);addEnemy(450,-25);
                            waveCount=0;wave++;
                            break;
                        case 17:
                            if(enemy.length==0){
                                title.setText("STAGE1 CLEAR",140);
                                wave++;
                            }
                            break;
                        case 18:
                            waveCount++;if(waveCount>200){waveCount=0;wave+=10;}
                            break;
                        
                        
                        
                        
                        
                        
                        
                        //Stage2=========================
                        case 28:
                            save = wave;
                            title.setText("STAGE 2",100);
                            addEnemy(0,-25,2);
                            waveCount=0;wave++;
                            break;
                        case 29:
                            if(enemy.length==0){
                                waveCount++;if(waveCount>40){waveCount=0;wave++;}
                            }
                            break;
                            
                            
                            
                        case 30:
                            addEnemy(465,-25,2);
                            waveCount=0;wave++;
                            break;
                        case 31:
                            waveCount++;if(waveCount>30){waveCount=0;wave++;}
                            break;
                        case 32:
                            addEnemy(0,-25,2);
                            waveCount=0;wave++;
                            break;
                        case 33:
                            if(enemy.length==0){
                                waveCount++;if(waveCount>40){waveCount=0;wave++;}
                            }
                            break;
                            
                            
                        case 34:
                            addEnemy(465,-25,2);
                            waveCount=0;wave++;
                            break;
                        case 35:
                            waveCount++;if(waveCount>33){waveCount=0;wave++;}
                            break;
                        case 36:
                            addEnemy(232,-25,2);
                            waveCount=0;wave++;
                            break;
                        case 37:
                            waveCount++;if(waveCount>33){waveCount=0;wave++;}
                            break;
                        case 38:
                            addEnemy(0,-25,2);
                            waveCount=0;wave++;
                            break;
                        case 39:
                            waveCount++;if(waveCount>30){waveCount=0;wave++;}
                            break;
                        case 40:
                            waveCount++;
                            if(waveCount%10==0){
                                r = Math.random()/2 + r;
                                if(r>1){r--;}
                                addEnemy(r*485-20,-25);
                            }
                            if(waveCount>150){waveCount=0;wave++;}
                            break;
                        case 41:
                            if(enemy.length==0){
                                save = wave;
                                waveCount++;if(waveCount>40){waveCount=0;wave++;}
                            }
                            break;
                            
                            
                            
                        case 42:
                            addEnemy(465,-25,2);
                            waveCount=0;wave++;
                            break;
                        case 43:
                            waveCount++;if(waveCount>33){waveCount=0;wave++;}
                            break;
                        case 44:
                            addEnemy(232,-100,3);
                            waveCount=0;wave++;
                            break;
                        case 45:
                            waveCount++;if(waveCount>33){waveCount=0;wave++;}
                            break;
                        case 46:
                            addEnemy(0,-25,2);
                            waveCount=0;wave++;
                            break;
                        case 47:
                            waveCount++;if(waveCount>33){waveCount=0;wave++;}
                            break;
                        case 48:
                            if(enemy.length==0){
                                title.setText("STAGE 2 CLEAR",140);
                                wave++;
                            }
                            break;
                        case 49:
                            waveCount++;if(waveCount>200){waveCount=0;wave+=10;}
                            break;
                        
                        
                        
                        
                        
                        
                        
                        //Stage3=========================
                        case 59:
                            save = wave;
                            title.setText("STAGE 3",100);
                            addEnemy(232,-25,4);
                            waveCount=0;wave++;
                            break;
                        case 60:
                            if(enemy.length==0 && enemyShot.length==0){
                                waveCount++;if(waveCount>30){waveCount=0;wave++;}
                            }
                            break;
                        case 61:
                            addEnemy(80,-25,4);addEnemy(130,-25,4);addEnemy(180,-25,4);addEnemy(230,-25,4);addEnemy(280,-25,4);addEnemy(330,-25,4);addEnemy(380,-25,4);
                            waveCount=0;wave++;
                            break;
                        case 62:
                            if(enemy.length==0 && enemyShot.length==0){
                                save = wave;
                                title.setText("WARNING",200);
                                waveCount++;wave++;
                            }
                            break;
                        case 63:
                            waveCount++;
                            if(waveCount>300){waveCount=0;wave++;}
                            break;
                        case 64:
                            waveCount++;
                            if(waveCount%1==0){
                                r = Math.random()/2 + r;
                                if(r>1){r--;}
                                addEnemy(r*485-20,-25,4);
                            }
                            if(waveCount>50){waveCount=0;wave++;}
                            break;
                        case 65:
                            waveCount++;
                            if(waveCount%3==0){
                                r = Math.random()/2 + r;
                                if(r>1){r--;}
                                addEnemy(r*485-20,-25,4);
                            }
                            if(waveCount>400){waveCount=0;wave++;}
                            break;
                        case 66:
                            if(enemy.length==0){
                                waveCount++;if(waveCount>50){waveCount=0;wave++;}
                            }
                            break;
                        case 67:
                            if(enemy.length==0 && enemyShot.length==0){
                                title.setText("LAST BATTLE",200);
                                waveCount++;wave++;
                            }
                            break;
                        case 68:
                            waveCount++;if(waveCount>50){waveCount=0;wave++;}
                            break;
                        case 69:
                            addEnemy(235,-25,5);
                            waveCount=0;wave++;
                            break;
                        case 70:
                            waveCount++;if(waveCount>50){waveCount=0;wave++;}
                            break;
                        case 71:
                            if(enemy.length==0 && enemyShot.length==0){
                                title.setText("ALL CLEAR",400);
                                wave++;
                            }
                            break;
                        case 72:
                            waveCount++;if(waveCount>500){waveCount=0;wave+=10;}
                            break;
                        default:
                            wave=0;
                    }
                }
                
                
                private function onClick(e:MouseEvent):void{
                    if(play){
                        shotType++;
                        if(shotType>2){
                            shotType=0;
                        }
                    }else if(setting){
                        restart();
                    }

                }
                
                private function gameOver():void{
                    play = false;
                    field.removeChild(myShip);
                    title.setText("GAME OVER",-1);
                    new BasicScoreForm(stage, (WIDTH - 280) / 2, (HEIGHT - 160) / 2, point, 'SAVE RECORD', _onClosed);
                }
                private function _onClosed($didSendComplete:Boolean):void {
                    stage.removeChildAt(5);
                    new BasicScoreRecordViewer(stage, (WIDTH - 220) / 2, (HEIGHT - 240) / 2, 'RECORD RANKING', 20, true, _rankClosed);
                }
                private function _rankClosed():void {
                    stage.removeChildAt(5);
                    reset();
                }
    }
}


import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;

class Shot extends Shape{
    public var type:int;
    public var life:int;
    public var power:int;
    public var dx:int;
    public var dy:int;
    public var count:int;
    public function Shot(m:Boolean):void{
        if(m){
            graphics.beginFill (0xFFCCDD, 1.0);    // 面のスタイル設定
        }else{
            graphics.beginFill (0xCCCCCC, 1.0);    // 面のスタイル設定
        }
        with(graphics){
            lineStyle (4, 0x000000, 1.0);    // 線のスタイル指定
            drawCircle(0, 0 , 5);
        }
    }
    public function setData(ndx:Number, ndy:Number, nlife:int,npower:int):void{
        dx=ndx;dy=ndy;life=nlife;power=npower;
    }
}

class LifeBar extends Shape{
    private var _life:int;
    public function set life(l:int):void{
        _life=l;
        graphics.clear();
        for(var i:int=0;i<l;i++){
            with(graphics){
                lineStyle (4, 0x000000, 1.0);    // 線のスタイル指定
                beginFill (0xFFCCDD, 1.0);    // 面のスタイル設定
                drawRoundRect  (i*20 ,0, 15 , 15 , 7 , 7);
            }
        }
    }
    public function get life():int{
        return _life;
    }
}


class Enemy extends Shape{
    public var type:int;
    public var bf_life:int;
    
    public var life:int;
    public var maxLife:int;
    public var dx:Number ;
    public var dy:Number ;
    
    public var count:int;
    public var rank:int;
    public var speed:Number;
    public function Enemy(t:Number):void{
        with(graphics){
            lineStyle (4, 0x000000, 1.0);    // 線のスタイル指定
            beginFill (0xDDCCFF, 1.0);    // 面のスタイル設定
        }    
        switch(t){
            case 0: 
                count=0;
                break;
            case 1:
                type = 1
                maxLife = 50;
                life = 50;
                dx = 5;
                dy = 5;
                with(graphics){
                    drawRoundRect  (-20 ,-20, 40 , 40 , 7 , 7);
                }
                break;
            case 2:
                type = 2;
                rank = 3;
                maxLife = 600;
                life = 600;
                dx = x;
                dy = y;
                speed = 10;
                drowEnemy2(3);
                break;
            case 2.5:
                type = 2;
                rank = 2;
                maxLife = 600;
                life = 600;
                dx = 0;
                dy = -1;
                speed = 15;
                drowEnemy2(3);
                break;
            case 3:
                type = 3;
                rank = 5;
                maxLife = 2000;
                life = 2000;
                dx = 0;
                dy = 20;
                speed = 20;
                drowEnemy3(10);
                break;
            case 4:
                type = 4;
                maxLife = 10;
                life = 10;
                count = 80;
                speed = 10;
                dx = 0;
                dy = 1;
                
                with(graphics){
                    drawRoundRect  ( -10,-10, 20 , 20 , 7 , 7);
                }
                break;
                
            case 5:
                type = 5;
                maxLife = 2000;
                life = 200;
                bf_life = 200;
                count = 0;
                speed = 10;
                dx = 232;
                dy = 150;
                
                
                drowEnemy5();
                break;
        }
    }
    public function drowEnemy2(n:int):Enemy{
            with(graphics){
                clear();
                lineStyle (4, 0x000000, 1.0);    // 線のスタイル指定
                beginFill (0xDDCCFF, 1.0);    // 面のスタイル設定
            }    
            for(var i:int=0;i<rank;i++){
                graphics.drawCircle  (6*(n+1) * Math.cos((2/n*i-2/n)*Math.PI) , 6*(n+1) * Math.sin((2/n*i-2/n)*Math.PI), 22);
            }
            var s:Enemy = new Enemy(0);
            s.graphics.drawCircle(6*(n+1) * Math.cos((2/n*i-2/n)*Math.PI) , 6*(n+1) * Math.sin((2/n*i-2/n)*Math.PI), 22);
            return s;
    }
    
    
    public function drowEnemy3(n:int):Enemy{
            with(graphics){
                clear();
                lineStyle (4, 0x000000, 1.0);    // 線のスタイル指定
                beginFill (0xDDCCFF, 1.0);    // 面のスタイル設定
            }    
            for(var i:int=0;i<rank*2;i++){
                graphics.drawCircle  (6*(n+1) * Math.cos((2/n*i-2/n)*Math.PI) , 6*(n+1) * Math.sin((2/n*i-2/n)*Math.PI), 22);
            }
            var s:Enemy = new Enemy(2.5);
            return s;
            
    }
    public function drowEnemy5():void{
        with(graphics){
            clear();
            lineStyle (4, 0x000000, 1.0);    // 線のスタイル指定
            beginFill (0xDDCCFF, 1.0);    // 面のスタイル設定
        }    
        graphics.drawCircle  (0,0, life/8+5);
        
        
    }
}




class MyShip extends Shape{
    private var _skeleton:Boolean = false;
    private var myTimer:Timer = new Timer(2000);
    public function set skeleton(s:Boolean):void{
        _skeleton=s;
        if(s){
            myTimer.start();
        }
        alpha=0.2;
    }
    public function get skeleton():Boolean{
        return _skeleton;
    }
    public function MyShip(){
        with(graphics){
            lineStyle (4, 0x000000, 1.0);    // 線のスタイル指定
            beginFill (0xFFCCDD, 1.0);    // 面のスタイル設定
            drawRoundRect  ( -8,-8, 16 , 16 , 7 , 7);
        }
        myTimer.addEventListener("timer", visi);
    }
    public function visi(e:TimerEvent):void{
        myTimer.stop();
        _skeleton=false;
        alpha=1;
    }
}

class MyShipShape extends Shape{
    public var count:int = 0;
    public function MyShipShape(){
        with(graphics){
            lineStyle (4, 0x000000, 1.0);    // 線のスタイル指定
            beginFill (0xFFCCDD, 1.0);    // 面のスタイル設定
            drawRoundRect  ( -8,-8, 16 , 16 , 7 , 7);
        }
    }
}

class TitleField extends TextField{
    public var timer:int = 0;
    public var count:int = 0;
    public var b:Number = 50;
    public var db:Number = 2;
    public var vis:Boolean = true;
    public var textFormat:TextFormat = new TextFormat();
    public function TitleField(){
        alpha=1.0
        with(textFormat){
                align="right";
                font="メイリオ";
                bold=true;
                color=0xFF6666;
                size = 30;
        }
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
    }
    public function setText(s:String,t:int):void{
        text=s;
        vis=true;
        
        b= 0;
         db= 1;
        setTextFormat(textFormat);
        timer=t;
    }
    public function onEnterFrame(e:Event):void{
        if(vis){
            if(timer==0){
                alpha=0;
                b+=db;
                if(b>60){db=-1;}
                if(b<0){
                    b=0;
                    vis = false;
                }
                alpha = b/100;
            }else{
                timer--;
                b+=db;
                if(b>60){db=-1;}
                if(b<40){db=1;}
                alpha = b/100;
            }
        }
    }
}