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

[ステレオグラム] 立体視避けゲー

矢印キーで移動 
 [ctrl]で交差法、平行法切り替え
[shift]+[←][→]で立体の強さを変える
画面クリックでスタート
マウスボタンで加速
マウスで移動
マウスホイールで距離感の変更
/**
 * Copyright tepe ( http://wonderfl.net/user/tepe )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/gWQp
 */

// forked from tomrx's 立体視避けゲー
package 
{
    /*  矢印キーで移動 
     *  [ctrl]で交差法、平行法切り替え
     *   [shift]+[←][→]で立体の強さを変える
     */
    import flash.display.*;
    import flash.events.*;
    import flash.text.TextField;
    import flash.ui.*;
    import flash.net.*;
                        
    
    import org.papervision3d.core.io.BasicExporter;
    import org.papervision3d.core.proto.MaterialObject3D;
    import org.papervision3d.lights.PointLight3D;
    import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
    import org.papervision3d.materials.utils.MaterialsList;
    import org.papervision3d.objects.primitives.Cube;
    import org.papervision3d.objects.primitives.Sphere;
    import org.papervision3d.view.BasicView;
    import org.papervision3d.objects.DisplayObject3D;
    [SWF(width="465", height="465", backgroundColor="0xffffff", frameRate="60")]
    public class Main extends Sprite 
    {
        private var minicube:Vector.<Cube>;
        private var minicube2:Vector.<Cube>;
        private var basex:Vector.<Number>;
        private var basey:Vector.<Number>;
        private var basez:Vector.<Number>;
        private var baser:Vector.<Number>;
        private var basecount:Vector.<Number>;
        private var pattern:Vector.<uint>;
        private var cubevx:Vector.<Number>;
        private var cubevy:Vector.<Number>;
        private var world1:BasicView;
        private var world2:BasicView;
        private var _light:PointLight3D;
        private var _myship:Sphere;
        private var _myship2:Sphere;
        private var keyState:int;
        private var parallel:int = -1;
        private var depth:int = 50;
        private var gameoverwait:uint;
        private var gameover:Boolean = true;
        private var gameovertext:TextField;
        private var gameovertext2:TextField;
        private var speed:Number = 1.0;
        private var hp:int = 5;
        private var hpFull:int = 80;
        private var yure:Boolean = false;;
        private var yuretime:uint = 0;
        private var cax:Number = 0;
        private var cay:Number = 0;
        private var level:uint = 0;
        private var cc:Number = 0;
        private var vx:Number = 0.0;
        private var vy:Number = 0.0;
        private var hptext:TextField;
        private var hptext2:TextField;
        private var speedtext:TextField;
        private var speedtext2:TextField;
        private var txt3A:TextField;
        private var txt3B:TextField;
        private var levelcount:uint = 0;
        private var mode:String = new String();
        private var ksk:Boolean = false;
        private var so:SharedObject;
//エントリ
        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);//ステージが用意されるまで待つ
        }
//準備関数        
        private function init(e:Event = null):void 
        {
            //Mouse.hide();
            removeEventListener(Event.ADDED_TO_STAGE, init);
            
            try {// try : エラー発生予測箇所。この区間でエラーが出ても停止には至らない。エラーが出たらcatchを実行。
                so = SharedObject.getLocal("87253930314");
                var flushStatus:String = so.flush();
                if (flushStatus == SharedObjectFlushStatus.FLUSHED) {
                    if (so.data.count > 0) {

                        so.data.count++;
                        parallel = so.data.parallel;
                        depth = so.data.depth;  
                        if(parallel == 1)mode = "[ 平行法 ]";
                        else mode = "[ 交差法 ]";          
        
                        //textField.appendText("\n"+mySharedObject.data.date.toLocaleString());
                    } else {
                        var val:int = 1;
                        var now:Date = new Date();
                        so.data.createtime = now;
                        so.data.count = val;
                        so.data.parallel = parallel;
                        val = 50;
                        so.data.depth = val;
                        if(parallel == 1)mode = "[ 平行法 ]";
                        else mode = "[ 交差法 ]";

                    }
                } else {//容量不足
                    
                }
            } catch (e:Error) {//tryスコープ内でエラーが発生したとき
                
            }       
            
            // entry point
            minicube = new Vector.<Cube>;
            minicube2 = new Vector.<Cube>;
            pattern = new Vector.<uint>();
            cubevx = new Vector.<Number>();
            cubevy = new Vector.<Number>();
            basex = new Vector.<Number>();
            basey = new Vector.<Number>();
            basez = new Vector.<Number>();
            baser = new Vector.<Number>();
            basecount = new Vector.<Number>();
            gameovertext = new TextField();
            gameovertext2 = new TextField();
            speedtext = new TextField();
            speedtext2 = new TextField();
            hptext = new TextField();
            hptext2 = new TextField();
            txt3A = new TextField();
            txt3B = new TextField();
            gameovertext = new TextField();
            gameovertext2 = new TextField();
            world1 = new BasicView(230, 230, false, true, "Free");
            world2 = new BasicView(230, 230, false, true, "Free");
            world1.camera.x = 0;
            world2.camera.x = 0;
            
            _light = new PointLight3D(true);
            _light.x = 0;
            _light.y = 0;
            _light.z = -500;
            
            
            
            
            var container:DisplayObject3D = new DisplayObject3D();
            world1.scene.addChild(container);
            var i:int;
            for (i = 0; i < 100; i++) {//ブロックのリスト
                var _cube:Cube = new Cube(new MaterialsList( { all:new FlatShadeMaterial(_light, 0x666666, 0x333333) } ), 50, 50, 50);
                cubevx.push(0.0);
                cubevy.push(0.0);
                basex.push(0.0);
                basey.push(0.0);
                basez.push(0.0);
                baser.push(0.0);
                basecount.push(0.0);
                minicube.push(_cube);//ブロックの配列
                minicube[i].x = 0;
                minicube[i].y = 0;
                minicube[i].z = -1500;
                pattern[i] = 0;
                
                container.addChild(minicube[i]);
            }
            var container2:DisplayObject3D = new DisplayObject3D();
            world2.scene.addChild(container2);
            for (i = 0; i < 100; i++) {
                var _cube2:Cube = new Cube(new MaterialsList( { all:new FlatShadeMaterial(_light, 0x666666, 0x333333) } ), 50, 50, 50);
                minicube2.push(_cube2);
                minicube2[i].x = 0;
                minicube2[i].y = 0;
                minicube2[i].z = -1500;
                container2.addChild(minicube2[i]);
            }
            _myship = new Sphere(new FlatShadeMaterial(_light, 0x00ffff, 0x005555), 30, 12, 12);
            _myship2 = new Sphere(new FlatShadeMaterial(_light, 0x00ffff, 0x005555), 30, 12, 12);
            //自機の表示
            container.addChild(_myship);
            container2.addChild(_myship2);
            _myship.z = -300;
            _myship2.z = -300;
            world1.startRendering();
            world2.startRendering();
            hptext.text = hptext2.text = "LIFE";
            hptext.width = hptext2.width = 200;
            //mode = "[ 交差法 ]"
            txt3A.text = txt3B.text = "クリック スタート";
            
            txt3A.x = 315;
            txt3B.x = 75;
            txt3A.y = txt3B.y = 360;
            txt3A.textColor = txt3B.textColor = 0x000000;

            
            hptext.textColor = hptext2.textColor = 0xffffff;
            hptext2.x = 310-70-10;
            hptext.x = 80-70+10;
            hptext.y = hptext2.y = 80;
            speedtext.scaleX = speedtext.scaleY = speedtext2.scaleX = speedtext2.scaleY = 0.8;
            speedtext.width = speedtext2.width = 200;
            speedtext.x = 0;
            speedtext2.x = 330-100;
            speedtext.y = speedtext2.y = 80;
            speedtext.textColor = speedtext2.textColor = 0xaaaaaa;
            speedtext.text = speedtext2.text = " "
            
            gameovertext.scaleX = gameovertext2.scaleX = gameovertext.scaleY = gameovertext2.scaleY = 2.5;
            gameovertext.textColor = 0xff0000;
            gameovertext.x = 95-90;
            gameovertext.y = gameovertext2.y = 200;
            gameovertext2.textColor = 0xff0000;
            gameovertext2.x = 325-90;
            
            addChild(speedtext);//スピード表示
            addChild(speedtext2);
            addChild(hptext);//ライフ表示
            addChild(hptext2);
            
            addChild(world1);//ステージ表示
            addChild(world2);
            addChild(txt3A);
            addChild(txt3B);
            addChild(gameovertext);//ゲームオーバー
            addChild(gameovertext2);
            world1.x = -depth / 2+10;
            world2.x = depth / 2+230+10;
            world1.y = 116;
            world2.y = 116;
            world1.camera.x = cax - depth ;
            world2.camera.x = cax + depth ;
            world1.camera.y = cay; 
            world2.camera.y = cay; 
            //イベント追加
            addEventListener(Event.ENTER_FRAME, enterFrameHandler);
            stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeydown);
            stage.addEventListener(KeyboardEvent.KEY_UP, onKeyup);
            stage.addEventListener(MouseEvent.CLICK,onClick);
            stage.addEventListener(MouseEvent.MOUSE_WHEEL,onWheel);
            stage.addEventListener(MouseEvent.MOUSE_DOWN,function():void{
                ksk = true;
            });
            stage.addEventListener(MouseEvent.MOUSE_UP,function():void{
                ksk = false;
            });


            
            var s:Sprite = new Sprite();
            addChild(s);
            s.graphics.beginFill(0x000000,0);
            s.graphics.drawRect(0,0,stage.width,stage.height+200);
            s.graphics.endFill();
            
            
        }
        private function onWheel(e:MouseEvent):void{
            depth += e.delta;
            if(depth<0)depth=0;
            else if(depth>100)depth=100;
        }

        private function onClick(e:MouseEvent):void{
            if(gameover == true && gameoverwait <= 0) { 
                gameover = false;
                gameovertext.text = "";
                gameovertext2.text = "";
                speed = 40;
                hp = hpFull;
                _myship.x = 0;
                _myship2.x = 0;
                _myship.y = 0;
                _myship2.y = 0;
                var l:int = minicube.length;
                while (l--) {
                    minicube[l].z = -1000;
                    minicube2[l].z = -1000;
                    basez[l] = -1000;
                }
                yure = false;
                yuretime = 0;
                cax = 0;
                cay = 0;
                level = 16;
            }
            /*
            else{
                 parallel = -parallel; 
                 if(parallel < 0){
                     mode = "[ 交差法 ]"
                 }
                 else{
                     mode = "[ 平行法 ]"
                 }
                 txt3A.text = txt3B.text = mode;
                 // 交差法 ←→ 平行法
            }*/

        }



        
//ループ関数
        private function enterFrameHandler(event:Event):void {
            if (gameoverwait > 0 && yuretime == 0) { gameoverwait--; }
            if(gameover == true && gameoverwait <= 0){
                txt3A.text = txt3B.text = "クリック スタート";
                Mouse.show();
                
            }
            
            if(ksk == true){
                speed+=(0.5*(hp/hpFull));
            }
            else{
                if(speed > 15)speed -= 0.5;
            }



            if (keyState != 0 && gameover == true && gameoverwait <= 0) { 
                //stage.displayState=StageDisplayState.FULL_SCREEN;
                gameover = false;
                gameovertext.text = "";
                gameovertext2.text = "";
                speed = 40;
                hp = hpFull;
                _myship.x = 0;
                _myship2.x = 0;
                _myship.y = 0;
                _myship2.y = 0;
                var l:int = minicube.length;
                while (l--) {
                    minicube[l].z = -1000;
                    minicube2[l].z = -1000;
                    basez[l] = -1000;
                }
                yure = false;
                yuretime = 0;
                cax = 0;
                cay = 0;
                level = 1;
            }
            if (gameover == true && yuretime == 0) { return;}
            cc -= speed;
            
            if ((keyState&3) == 0 && vx > 0) { vx = vx - 0.5; }
            if ((keyState&3) == 0 && vx < 0) { vx = vx + 0.5; }
            if ((keyState&0xc) == 0 && vy > 0) { vy = vy - 0.5; }
            if ((keyState&0xc) == 0 && vy < 0) { vy = vy + 0.5;}
            if (keyState & 1) {
                if((keyState&0x100)==0){
                vx = vx + 0.5;
                if (vx > 4.0) { vx = 4.0; }
                }else {
                    if(depth>0){depth--;}
                }
            }
            if (keyState & 2) {
                if((keyState&0x100)==0){
                vx = vx - 0.5;
                if (vx < -4.0) { vx = -4.0; }
                }else {
                    depth++;
                }
            }
            if (keyState & 4) {
                vy = vy - 0.5;
                if (vy < -4.0) { vy = -4.0;}
            }
            if (keyState & 8) {
                vy = vy + 0.5;
                if (vy > 4.0) { vy = 4.0;}
            }    
            
            cax = (mouseX-stage.width/2)*2;
            //vx =  (mouseX-stage.width/2)/60;
            //if(vx > 4.0)vx =4.0;
            cay = (stage.height/2-mouseY)*2;
            //if(vy < -4.0)vy = -4.0;
            
            /*
            if (cax + vx*speed + 25 > 230) { vx = 0; }
            if (cax + vx*speed - 25 < -230) { vx = 0; }
            if (cay + vy*speed > 230) { vy = 0; }
            if (cay + vy*speed < -230) { vy = 0;}
            //cax += vx * speed;
            //cay += vy * speed;
            */
//ダメージ
            if (yuretime > 0) { 
                hptext.textColor = hptext2.textColor = 0xff0000;
                var yurex:Number = Math.random() * 20.0;
                var yurey:Number = Math.random() * 20.0;
                yuretime--;
            }else {
                yurex = 0; yurey = 0; 
                //ライフカラー
                if(hp > hpFull/3)hptext.textColor = hptext2.textColor = 0x00dd00;
                else if(hp > hpFull/10)hptext.textColor = hptext2.textColor = 0xffbb00; 
                else hptext.textColor = hptext2.textColor = 0xbb0000;
            }
            
            hptext2.x = 310-70-10+yurex*1.3;
            hptext.x = 0+10+yurex*1.3;
            hptext.y = hptext2.y = 80 + yurey*1.3;
            
            speedtext.x = 10+yurex*0.8;
            speedtext2.x = 235+yurex*0.8;
            speedtext.y = speedtext2.y = 95+yurey*0.8;
            
            txt3A.x = 315+yurex;
            txt3B.x = 75+yurex;
            txt3A.y = txt3B.y = 360+yurey;
 //カメラ位置移動             
            world1.camera.x = cax - depth + yurex;;
            world2.camera.x = cax + depth + yurex;
            world1.camera.y = cay + yurey;
            world2.camera.y = cay + yurey;
            world1.camera.z = -1000;
            world2.camera.z = -1000;
//自機移動
            //_myship.x = _myship2.x += vx * speed;
            _myship.x = _myship2.x = (mouseX-stage.width/2)*3;
            //_myship.y = _myship2.y += vy * speed;
            _myship.y = _myship2.y = -(mouseY-stage.height/2)*3; 
            if(ksk == true){
                _myship.x = _myship2.x += ((Math.random()*1-0.5)/((hp/hpFull)/2));
                _myship.y = _myship2.y += ((Math.random()*1-0.5)/((hp/hpFull)/2));
                if(_myship.z < -100)_myship.z = _myship2.z +=20*(hp/hpFull);
            }

            else if(ksk == false && -500 < _myship.z)_myship.z= _myship2.z -=10;
            

            //距離感調整
            if(parallel==true){
                world1.x = -125+125;
                world2.x = 125 + 125;                
                world1.x = -depth / 2+10;
                world2.x = depth / 2+230+10;
            }else {
                world1.x = 125+125;
                world2.x = -125 + 125;    
                world1.x = -depth / 2+230+10;
                world2.x = depth / 2+10;
            }

            txt3A.text = txt3B.text = mode;

            var s:String="";
            for (var i:int = 0; i < hp; i++) {
                s += "|";
            }

            hptext.text = "LIFE "+s;
            hptext2.text = "LIFE " + s;        
            speedtext.text = speedtext2.text = "LEVEL " + level.toString();
            s = "";
            for(i=0;i<speed/5;i++){
                s += "]";
            }

            speedtext.text = speedtext2.text = "SPEED " + s;
            //speedtext.text = speedtext2.text = so.data.count.toString();
            if (cc <= 0) {
                var r:int = Math.floor(Math.random() * level) + 1;
                var rx:Number;
                var ry:Number;
                var rr:Number;
                var rd:Number;
                switch(r) {
                    case 1:    
                        rx = Math.random() * 460 - 230;
                        ry = Math.random() * 460 - 230;
                        r = Math.round(Math.random()* 5000);
                            for (i = 0; i < r; i++) {
                                makecube(rx+=Math.random()*50-25, ry+=Math.random()*50-25, 15000+i*70, 0, 0, 0, 1);
                            }
                        cc = 150;
                    break;
                    case 2: 
                        rx = Math.random() * 1460 - 1230;
                        ry = Math.random() * 460 - 230;
                        r = Math.round(Math.random()* 10)+5;
                            for (i = 0; i < r; i++) {
                                makecube(rx, ry+(i-2)*60, 15000, 0, 0, 0, 1);
                            }
                        cc = 100;
                    break;
                    case 3:        
                        makecube(Math.random() * 4600 - 2300, Math.random() * 4600 - 2300, 15000,Math.random()*90,Math.random()*90,Math.random()*90, 1); 
                        cc = 100;
                    break;
                    case 4:    
                        rx = Math.random() * 1460 - 1230;
                        ry = Math.random() * 460 - 230;
                        r = Math.round(Math.random()* 50);
                            for (i = 0; i < r; i++) {
                                makecube(rx+(i-2)*60, ry, 15000, 0, 0, 0, 1);
                            }
                        cc = 100;
                    break;
                    case 5:        
                        rx = Math.random() * 1460 - 1230;
                        ry = Math.random() * 1460 - 1230;
                        rr = Math.random() * 200 + 150;
                        for (i = 0; i < 10; i++) {
                            makecube(Math.cos(i*36*Math.PI/ 180)*rr+rx, Math.sin(i*36*Math.PI/ 180)*rr+ry, 15000, 0,0, i*36, 1);                        
                        }
                        cc = 100;
                    break;
                    case 6:        
                        rx = Math.random() * 460 - 230;
                        ry = Math.random() * 460 - 230;
                        rr = Math.random() * 200 + 150;
                        rd = Math.random() * 10;
                        for (i = 0; i < 10; i++) {
                            makecube(Math.cos((i+rd)*36*Math.PI/ 180)*rr+rx, Math.sin((i+rd)*36*Math.PI/ 180)*rr+ry, 15000+i*40, 0,0, (i+rd)*36, 1);                        
                        }
                        cc = 150;
                    break;
                    case 7:
                        makecube(Math.random()*460-230, Math.random()*460-230, 15000, Math.random()*300+50, 0, 0, 8);
                        cc = 100;
                    break;
                    case 8:    
                        makecube(Math.random()*460-230, Math.random()*460-230, 15000, Math.random()*300+50, 0, 0, 5);
                        cc = 100;
                    break;
                    case 9:
                        makecube(Math.random()*460-230, Math.random()*460-230, 15000, Math.random()*300+50, 0, 0, 9);
                        cc = 100;
                    break;
                    case 10:
                        makecube(Math.random()*460-230, Math.random()*460-230, 15000, Math.random()*300+50, 0, 0, 6);
                        cc = 100;
                    break;
                    case 11:        
                        makecube(Math.random() * 460 - 230, Math.random() * 460 - 230, 15000,Math.random()*90,Math.random()*90,Math.random()*90, 2);
                        cc = 100;
                    break;
                    case 12:    
                        makecube(Math.random()*460-230, Math.random()*460-230, 15000, Math.random()*300+50, 0, 0, 4);
                        cc = 100;
                    break;
                    case 13:
                        makecube(Math.random()*460-230, Math.random()*460-230, 15000, Math.random()*300+50,Math.random()*360, 0, 7);
                        cc = 100;
                    break;
               
                        cc = 100;
                    break;
                    case 14:
                        rx = Math.random() * 4600 - 2300;
                        ry = Math.random() * 4600 - 2300;
                        rr = Math.random() * 300;
                        for (i = 0; i < 10; i++) {
                            makecube(rx, ry, 15000+i*70, 50+rr, i*10, 0, 7);
                        }
                        cc = 250;
                    break;
                    case 15:
                        rx = Math.random() * 4600 - 2300;
                        ry = Math.random() * 4600 - 2300;
                        rr = Math.random() * 300;
                        for (i = 0; i < 10; i++) {
                            makecube(rx, ry, 15000+i*70, 50+rr, i*-10, 0, 4);
                        }
                        cc = 250;
                    break;
                    default:
                    break;
                }
                speed += 0.01;//加速
                levelcount++;
                if (levelcount > 100) {
                    levelcount = 0;
                    if (level < 18) {
                        level++;
                    }
                }
            }
            movecube();
        }
//キューブ生成
        private function makecube(mx:Number,my:Number,mz:Number,rx:int,ry:int,rz:int,p:uint):void {
            var l:int = minicube.length;
            var m:int = 0;
            while (l--) {
                if (m == 0 && minicube[l].z < -700) {
                    m = 1;
                    minicube[l].x = mx;
                    minicube[l].y = my;
                    minicube[l].z = mz;
                    minicube[l].rotationX = rx;
                    minicube[l].rotationY = ry;
                    minicube[l].rotationZ = rz;
                    minicube[l].visible = true;
                    minicube2[l].x = mx;
                    minicube2[l].y = my;
                    minicube2[l].z = mz;
                    minicube2[l].rotationX = rx;
                    minicube2[l].rotationY = ry;
                    minicube2[l].rotationZ = rz;
                    basez[l] = 1500;
                    minicube2[l].visible = true;
                    switch(p) {
                        case 1:
                            pattern[l] = p;
                        break;
                        case 2:
                            pattern[l] = p;
                            cubevx[l] = Math.random() * 4.0 - 2.0;
                            cubevy[l] = Math.random() * 4.0 - 2.0;
                        break;
                        case 3:
                            pattern[l] = p;
                        break;
                        case 4:
                            basex[l] = minicube[l].x;
                            basey[l] = minicube[l].y;
                            basez[l] = minicube[l].z;
                            baser[l] = rx;
                            pattern[l] = p;
                            basecount[l] = ry;
                        break;
                        case 5:
                            basex[l] = minicube[l].x;
                            basey[l] = minicube[l].y;
                            basez[l] = minicube[l].z;
                            baser[l] = rx;
                            pattern[l] = p;
                            basecount[l] = Math.random()*360;
                        break;
                        case 6:
                            basex[l] = minicube[l].x;
                            basey[l] = minicube[l].y;
                            basez[l] = minicube[l].z;
                            baser[l] = rx;
                            pattern[l] = p;
                            basecount[l] = Math.random()*360;
                        break;
                        case 7:
                            basex[l] = minicube[l].x;
                            basey[l] = minicube[l].y;
                            basez[l] = minicube[l].z;
                            baser[l] = rx;
                            pattern[l] = p;
                            basecount[l] = ry;
                        break;
                        case 8:
                            basex[l] = minicube[l].x;
                            basey[l] = minicube[l].y;
                            basez[l] = minicube[l].z;
                            baser[l] = rx;
                            pattern[l] = p;
                            basecount[l] = Math.random()*360;
                        break;
                        case 9:
                            basex[l] = minicube[l].x;
                            basey[l] = minicube[l].y;
                            basez[l] = minicube[l].z;
                            baser[l] = rx;
                            pattern[l] = p;
                            basecount[l] = Math.random()*360;
                        break;
                    }
                }
            }
        }
//キューブ移動
        private function movecube():void {
            var l:int = minicube.length;
            var same:Number;
            while (l--) {
                switch(pattern[l]) {
                    case 1:
                        minicube[l].z -= speed*3;
                        minicube2[l].z -= speed * 3;
                        basez[l] -= speed * 3;
                    break;
                    case 2:                    
                        if (minicube[l].x + cubevx[l] * speed < -230) { cubevx[l] = -cubevx[l]; }
                        if (minicube[l].x + cubevx[l] * speed > 230) { cubevx[l] = -cubevx[l]; }
                        if (minicube[l].y + cubevy[l] * speed < -230) { cubevy[l] = -cubevy[l]; }
                        if (minicube[l].y + cubevy[l] * speed > 230) { cubevy[l] = -cubevy[l]; }
                        minicube[l].z -= speed * 3;
                        minicube[l].x += cubevx[l] * speed/3;
                        minicube[l].y += cubevy[l] * speed/3;
                        minicube2[l].z -= speed * 3;                        
                        minicube2[l].x += cubevx[l] * speed/3;
                        minicube2[l].y += cubevy[l] * speed/3;
                        basez[l] -= speed * 3;
                    break;
                    case 3:
                        minicube[l].z -= speed*3;
                        minicube2[l].z -= speed * 3;
                        basez[l] -= speed * 3;
                    break;
                    case 4://Z軸回転
                        //basecount[l] += speed / (baser[l]/100)*2;
                        basecount[l] += 10;
                        minicube[l].x =basex[l]+ Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube[l].y =basey[l]+ Math.sin(Math.PI / 180 * basecount[l])*baser[l];
                        minicube[l].z = basez[l];
                        minicube[l].rotationX = 0;
                        minicube[l].rotationY = 0;
                        minicube[l].rotationZ = basecount[l];
                        minicube2[l].x =basex[l]+ Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube2[l].y =basey[l]+ Math.sin(Math.PI / 180 * basecount[l])*baser[l];
                        minicube2[l].z = basez[l];
                        minicube2[l].rotationX = 0;
                        minicube2[l].rotationY = 0;
                        minicube2[l].rotationZ = basecount[l];
                        basez[l] -= speed * 3;
                    break;
                    case 5://縦回転
                        //basecount[l] += speed / (baser[l] / 100) * 2;
                        basecount[l] += 10;
                        minicube[l].x = basex[l];
                        minicube[l].y =basey[l]+ Math.sin(Math.PI / 180 * basecount[l])*baser[l];
                        minicube[l].z = basez[l]+Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube[l].rotationX = -basecount[l];
                        minicube[l].rotationY = 0;
                        minicube[l].rotationZ = 0;
                        minicube2[l].x = basex[l];
                        minicube2[l].y =basey[l]+ Math.sin(Math.PI / 180 * basecount[l])*baser[l];
                        minicube2[l].z = basez[l]+Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube2[l].rotationX = -basecount[l];
                        minicube2[l].rotationY = 0;
                        minicube2[l].rotationZ = 0;
                        basez[l] -= speed * 3;
                    break;
                    case 6:
                        //basecount[l] += speed / (baser[l] / 100) * 2*10;
                        basecount[l] += 10;
                        minicube[l].x = basex[l] + Math.sin(Math.PI / 180 * basecount[l]) * baser[l];
                        minicube[l].y = basey[l];
                        minicube[l].z = basez[l]+Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube[l].rotationX = 0;
                        minicube[l].rotationY = basecount[l];
                        minicube[l].rotationZ = 0;
                        minicube2[l].x = basex[l] + Math.sin(Math.PI / 180 * basecount[l]) * baser[l];
                        minicube2[l].y = basey[l];
                        minicube2[l].z = basez[l]+Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube2[l].rotationX = 0;
                        minicube2[l].rotationY = basecount[l];
                        minicube2[l].rotationZ = 0;
                        basez[l] -= speed * 3;
                    break;
                    case 27:
                        basecount[l] -= speed / (baser[l]/100)*2;
                        minicube[l].x =basex[l]+ Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube[l].y =basey[l]+ Math.sin(Math.PI / 180 * basecount[l])*baser[l];
                        minicube[l].z = basez[l];
                        minicube[l].rotationX = 0;
                        minicube[l].rotationY = 0;
                        minicube[l].rotationZ = basecount[l];;
                        minicube2[l].x =basex[l]+ Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube2[l].y =basey[l]+ Math.sin(Math.PI / 180 * basecount[l])*baser[l];
                        minicube2[l].z = basez[l];
                        minicube2[l].rotationX = 0;
                        minicube2[l].rotationY = 0;
                        minicube2[l].rotationZ = basecount[l];;
                        basez[l] -= speed * 3;
                    break;
                    case 28:
                        basecount[l] -= speed / (baser[l] / 100) * 2;
                        minicube[l].x = basex[l];
                        minicube[l].y =basey[l]+ Math.sin(Math.PI / 180 * basecount[l])*baser[l];
                        minicube[l].z = basez[l]+Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube[l].rotationX = -basecount[l];
                        minicube[l].rotationY = 0;
                        minicube[l].rotationZ = 0;
                        minicube2[l].x = basex[l];
                        minicube2[l].y =basey[l]+ Math.sin(Math.PI / 180 * basecount[l])*baser[l];
                        minicube2[l].z = basez[l]+Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube2[l].rotationX = -basecount[l];
                        minicube2[l].rotationY = 0;
                        minicube2[l].rotationZ = 0;
                        basez[l] -= speed * 3;
                    break;
                    case 29:
                        basecount[l] -= speed / (baser[l] / 100) * 2;
                        minicube[l].x = basex[l] + Math.sin(Math.PI / 180 * basecount[l]) * baser[l];;
                        minicube[l].y = basey[l];
                        minicube[l].z = basez[l]+Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube[l].rotationX = 0;
                        minicube[l].rotationY = basecount[l];
                        minicube[l].rotationZ = 0;
                        minicube2[l].x = basex[l] + Math.sin(Math.PI / 180 * basecount[l]) * baser[l];;
                        minicube2[l].y = basey[l];
                        minicube2[l].z = basez[l]+Math.cos(Math.PI / 180 * basecount[l])*baser[l];
                        minicube2[l].rotationX = 0;
                        minicube2[l].rotationY = basecount[l];
                        minicube2[l].rotationZ = 0;
                        basez[l] -= speed * 3;
                    break;
                    default:
                        minicube[l].z -= speed*3;
                        minicube2[l].z -= speed * 3;
                        basez[l] -= speed * 3;
                    break;
                }
                //ダメージ判定
                if (minicube[l].hitTestObject(_myship)) {
                    yure = true; yuretime = 10;                    
                    minicube[l].z = -1000;
                    minicube[l].visible = false;
                    minicube2[l].z = -1000;
                    minicube2[l].visible = false;
                    if(speed/3 > 1)speed /= Math.random()*3+1;
                    hp-=(speed/2)+Math.random()*5;
                    if (hp < 0) {
                        gameover = true;
                        yuretime = 25;
                        gameoverwait = 60;
                        gameovertext.text = gameovertext2.text = "GAME OVER";
                        //txt3A.text = txt3B.text = "クリック スタート";
                        try{
                            var flushStatus:String = so.flush();
                            if (flushStatus == SharedObjectFlushStatus.FLUSHED) {
                                so.data.parallel = parallel;
                                so.data.depth = depth;
                                
                            }
                        }
                        catch(e:Error){
                            //mode = "error";
                        }
                        
                   }
                }
                if (minicube[l].z < -700 && minicube[l].visible) { 
                    minicube[l].visible = false; minicube2[l].visible = false;
                    basez[l] = -1000;                    
                }
            
            }
        }
//キー入力ON
        private function onKeydown(event:KeyboardEvent):void {
            
            
            if (event.keyCode == 39 ) { keyState = keyState | 0x01;  }//39→ 37← 38↑ 40↓
            if (event.keyCode == 37 ) { keyState = keyState | 0x02;  }
            if (event.keyCode == 40 ) { keyState = keyState | 0x04;  }
            if (event.keyCode == 38 ) { keyState = keyState | 0x08;  }
            if (event.keyCode == 88 ) { keyState = keyState | 0x80;  }//x
            if (event.keyCode == 90 ) {
                 keyState = keyState | 0x40;
                 //if(stage.displayState==StageDisplayState.NORMAL)stage.displayState=StageDisplayState.FULL_SCREEN;
                 //else stage.displayState=StageDisplayState.NORMAL;
                   
            }//z        
            if (event.keyCode == 16) { keyState = keyState | 0x100; }//shift
            if (event.keyCode == 17) {//ctrl
                 parallel = -parallel; 
                 

                 if(parallel < 0){
                     mode = "【 交差法 】"
                 }
                 else{
                     mode = "【 平行法 】"
                 }
                 txt3A.text = txt3B.text = mode;
                 // 交差法 ←→ 平行法

            }
            
        }
        //キーOFF
        private function onKeyup(event:KeyboardEvent):void {
            if (event.keyCode == 39) { keyState &= ~0x01; }
            if (event.keyCode == 37) { keyState &= ~0x02; }
            if (event.keyCode == 40) { keyState &= ~0x04; }
            if (event.keyCode == 38) { keyState &= ~0x08; }
            if (event.keyCode == 88) { keyState &= ~0x80; }
            if (event.keyCode == 90) { keyState &= ~0x40; }
            if (event.keyCode == 16) { keyState &= ~0x100;}
        }
    }
    
}