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

35 Panels

一応ゲーム自体は動くようにはできた。
あとはモーションだね

遊び方
よくあるスライドパズルの要領でパネルを動かします
123456という並びができたら1をクリックして、押したまま順番になぞっていって6までついたら離せば そいつらが消えて、新しいのが出てくる。
実は本当の判定条件は違かったりするんだけどまあソース見ればわかるさ

11/07/09 一応完成。スコアの計算方法は183行目にあります
Get Adobe Flash player
by phi16 09 Jul 2011
/**
 * Copyright phi16 ( http://wonderfl.net/user/phi16 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/tghK
 */

package {
    import flash.geom.Point;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    public class Pn extends Sprite {
        public var spr:Sprite=new Sprite();
        public var field:Array=new Array();
        public var blx:int,bly:int;
        public var i:int,j:int;
        public var clicking:Boolean=false;
        public var tracestack:Array=new Array();
        public var strpanels:Array=new Array();
        public var scorept:int=0,movedpt:int=0,befmoved:int=0;
        public var numspanels:Array=new Array();
        public function Pn(){
            var sel:Array=new Array();
            for(i=0;i<7;i++)sel[i]=new int(),sel[i]=i-6?6:0;
            var bl:Boolean=false;
            for(i=0;i<6;i++){
                field[i]=new Array();
                for(j=0;j<6;j++){
                    field[i][j]=new Panel;
                    field[i][j].x=(465-350)/2+i*60+25;
                    field[i][j].y=(465-350)/2+j*60+25;
                    field[i][j].s=50;
                    field[i][j].r=0;
                    var t:int=6;
                    while(!sel[t])t=Math.random()*6%6;
                    field[i][j].type=t+1;
                    if(!bl && t==5 && sel[t]!=0 && Math.random()<1/sel[t])field[i][j].type=0,bl=true,blx=i,bly=j;
                    sel[t]--;
                }
            }
            for(i=0;i<5;i++){
                strpanels[i]=new Panel;
                strpanels[i].x=30+i*35;
                strpanels[i].y=30;
                strpanels[i].s=30;
                strpanels[i].r=0;
                strpanels[i].type=23+i;
            }
            for(i=0;i<5;i++){
                strpanels[i+5]=new Panel;
                strpanels[i+5].x=30+i*35;
                strpanels[i+5].y=435;
                strpanels[i+5].s=30;
                strpanels[i+5].r=0;
                strpanels[i+5].type=28+i;
            }
            for(i=0;i<7;i++){
                numspanels[i]=new Panel;
                numspanels[i].x=225+i*35;
                numspanels[i].y=30;
                numspanels[i].s=30;
                numspanels[i].r=0;
                numspanels[i].type=13;
            }
            for(i=0;i<7;i++){
                numspanels[i+7]=new Panel;
                numspanels[i+7].x=225+i*35;
                numspanels[i+7].y=435;
                numspanels[i+7].s=30;
                numspanels[i+7].r=0;
                numspanels[i+7].type=13;
            }
            addChild(spr);
            addEventListener(Event.ENTER_FRAME,frame);
            addEventListener(MouseEvent.MOUSE_DOWN,onclkdn);
            addEventListener(MouseEvent.MOUSE_UP,onclkup);
        }
        public function frame(e:Event):void{
           for(i=0;i<6;i++)for(j=0;j<6;j++){
                field[i][j].x+=((465-350)/2+i*60+25-field[i][j].x)/1.3;
                field[i][j].y+=((465-350)/2+j*60+25-field[i][j].y)/1.3;
                if(field[i][j].type<7)field[i][j].s+=(50-field[i][j].s)/1.3,field[i][j].r/=1.3;
                if(field[i][j].type>6 && field[i][j].er<=0){
                    field[i][j].er=0;
                    field[i][j].s+=field[i][j].ss-=2;
                    field[i][j].r+=field[i][j].rs;
                    if(field[i][j].s<=0){
                        field[i][j].type=field[i][j].to;
                        field[i][j].to=0;
                        field[i][j].s=0;
                        field[i][j].r=2*Math.PI;
                    }
                }else if(field[i][j].type>6)field[i][j].er--;
            }
            if(clicking){
                var posx:int=(this.mouseX-(465-350)/2)/60+1,posy:int=(this.mouseY-(465-350)/2)/60+1;
                posx--,posy--;
                if(posx>=0 && posy>=0 && posx<6 && posy<6 && field[posx][posy].type!=0 && (tracestack.length==0 || !(tracestack[tracestack.length-1].x==posx && tracestack[tracestack.length-1].y==posy))){
                    if(tracestack.length>1 && tracestack[tracestack.length-2].x==posx && tracestack[tracestack.length-2].y==posy){
                        tracestack.pop();
                    }else if(tracestack.length==0 || (tracestack[tracestack.length-1].x==posx && Math.abs(tracestack[tracestack.length-1].y-posy)==1) || (tracestack[tracestack.length-1].y==posy && Math.abs(tracestack[tracestack.length-1].x-posx)==1)){
                        var ok:Boolean=true;
                        for(i=0;i<tracestack.length;i++)if(tracestack[i].x==posx && tracestack[i].y==posy)ok=false;
                        if(ok)tracestack.push(new Ps(posx,posy));
                    }
                }
            }else while(tracestack.length)tracestack.pop();
            spr.graphics.clear();
            spr.graphics.beginFill(0x000000);
            spr.graphics.drawRect(0,0,465,465);
            spr.graphics.endFill();
            for(i=0;i<6;i++)for(j=0;j<6;j++){
                field[i][j].Draw(spr);
                if(field[i][j].type>6)field[i][j].Draw(spr,true);
            }
            for(i=0;i<numspanels.length;i++){
                var ti:int=13+((i<7?scorept:movedpt)/Math.pow(10,(i<7?6:13)-i))%10;
                numspanels[i].type+=(int)(ti>numspanels[i].type)-(int)(ti<numspanels[i].type);
                numspanels[i].Draw(spr,false);
            }
            for(i=0;i<strpanels.length;i++)strpanels[i].Draw(spr,false);
            for(i=0;i<tracestack.length;i++)field[tracestack[i].x][tracestack[i].y].Draw(spr,true);
            for(j=0;j<2;j++){
                spr.graphics.lineStyle(j?10:5,0xffffff,j?0.5:1);
                for(i=0;i<tracestack.length-1;i++){
                    spr.graphics.moveTo(field[tracestack[i].x][tracestack[i].y].x,field[tracestack[i].x][tracestack[i].y].y);
                    spr.graphics.lineTo(field[tracestack[i+1].x][tracestack[i+1].y].x,field[tracestack[i+1].x][tracestack[i+1].y].y);
                }
                spr.graphics.moveTo(field[tracestack[i].x][tracestack[i].y].x,field[tracestack[i].x][tracestack[i].y].y);
                spr.graphics.lineTo(this.mouseX,this.mouseY);
            }
        }
        public function onclkdn(e:MouseEvent):void{
            clicking=true;
        }
        public function onclkup(e:MouseEvent):void{
            clicking=false;
            var posx:int=(this.mouseX-(465-350)/2)/60+1,posy:int=(this.mouseY-(465-350)/2)/60+1;
            posx--,posy--;
            if(posx>=0 && posy>=0 && posx<6 && posy<6){
                if(tracestack.length==1 && (posx==blx || posy==bly)){
                    var pr:Panel,p:int;
                    if(posx==blx){
                        if(posy<bly){
                            movedpt++;
                            for(p=bly;p>=posy;p--){
                                pr=field[posx][p];
                                field[posx][p]=field[blx][bly];
                                field[blx][bly]=pr;
                                bly=p;
                            }
                        }
                        if(posy>bly){
                            movedpt++;
                            for(p=bly;p<=posy;p++){
                                pr=field[posx][p];
                                field[posx][p]=field[blx][bly];
                                field[blx][bly]=pr;
                                bly=p;
                            }
                        }
                    }
                    if(posy==bly){
                        if(posx<blx){
                            movedpt++;
                            for(p=blx;p>=posx;p--){
                                pr=field[p][posy];
                                field[p][posy]=field[blx][bly];
                                field[blx][bly]=pr;
                                blx=p;
                            }
                        }
                        if(posx>blx){
                            movedpt++;
                            for(p=blx;p<=posx;p++){
                                pr=field[p][posy];
                                field[p][posy]=field[blx][bly];
                                field[blx][bly]=pr;
                                blx=p;
                            }
                        }
                    }
                }else if(tracestack.length){
                    var ok:Boolean=true,i:int;
                    for(i=0;i<tracestack.length;i++){
                        if(field[tracestack[i].x][tracestack[i].y].type!=i%6+1)ok=false;
                    }
                    if(ok && tracestack.length>=6){
                        scorept+=(100+(tracestack.length-6)*20)*((movedpt-befmoved)<20?(20-movedpt+befmoved)/20+1:1);
                        befmoved=movedpt;
                        var sel:Array=new Array();
                        for(i=0;i<7;i++)sel[i]=new int(),sel[i]=i-6?((tracestack.length-1)%6<i?0:1)+(int)((tracestack.length-1)/6):0;
                        for(i=0;i<tracestack.length;i++){
                            field[tracestack[i].x][tracestack[i].y].ss=10;
                            field[tracestack[i].x][tracestack[i].y].rs=5*Math.PI/180;
                            field[tracestack[i].x][tracestack[i].y].er=i*2;
                            field[tracestack[i].x][tracestack[i].y].type+=6;
                            var t:int=6;
                            while(!sel[t])t=Math.random()*6%6;
                            sel[t]--;
                            field[tracestack[i].x][tracestack[i].y].to=t+1;
                        }
                    }
                }
            }
        }
    }
}
import flash.display.Shape;
import flash.utils.Proxy;
import flash.geom.Point;

import flash.display.Sprite;

class Panel{
    public var x:Number,y:Number,s:Number,r:Number,ss:Number,rs:Number,er:Number;
    public var type:int,to:int;
    public function Panel(){
        x=y=s=r=ss=rs=er=type=to=0;
    }
    public function Set(X:Number,Y:Number,S:Number,R:Number):void{
        x=X;
        y=Y;
        s=S;
        r=R;
    }
    public function Draw(sp:Sprite,b:Boolean=false):void{
        var numbp:Array=new Array(
            0,1,0, 0,1,0, 0,1,0, 0,1,0, 0,1,0,//1
            1,1,1, 0,0,1, 1,1,1, 1,0,0, 1,1,1,//2
            1,1,1, 0,0,1, 1,1,1, 0,0,1, 1,1,1,//3
            1,0,1, 1,0,1, 1,1,1, 0,0,1, 0,0,1,//4
            1,1,1, 1,0,0, 1,1,1, 0,0,1, 1,1,1,//5
            1,1,1, 1,0,0, 1,1,1, 1,0,1, 1,1,1,//6
            0,1,0, 0,1,0, 0,1,0, 0,1,0, 0,1,0,//1
            1,1,1, 0,0,1, 1,1,1, 1,0,0, 1,1,1,//2
            1,1,1, 0,0,1, 1,1,1, 0,0,1, 1,1,1,//3
            1,0,1, 1,0,1, 1,1,1, 0,0,1, 0,0,1,//4
            1,1,1, 1,0,0, 1,1,1, 0,0,1, 1,1,1,//5
            1,1,1, 1,0,0, 1,1,1, 1,0,1, 1,1,1,//6
            1,1,1, 1,0,1, 1,0,1, 1,0,1, 1,1,1,//0
            0,1,0, 0,1,0, 0,1,0, 0,1,0, 0,1,0,//1
            1,1,1, 0,0,1, 1,1,1, 1,0,0, 1,1,1,//2
            1,1,1, 0,0,1, 1,1,1, 0,0,1, 1,1,1,//3
            1,0,1, 1,0,1, 1,1,1, 0,0,1, 0,0,1,//4
            1,1,1, 1,0,0, 1,1,1, 0,0,1, 1,1,1,//5
            1,1,1, 1,0,0, 1,1,1, 1,0,1, 1,1,1,//6
            1,1,1, 0,0,1, 0,0,1, 0,0,1, 0,0,1,//7
            1,1,1, 1,0,1, 1,1,1, 1,0,1, 1,1,1,//8
            1,1,1, 1,0,1, 1,1,1, 0,0,1, 1,1,1,//9
            1,1,1, 1,0,0, 1,1,1, 0,0,1, 1,1,1,//S
            0,0,0, 0,0,0, 1,1,1, 1,0,0, 1,1,1,//c
            0,0,0, 0,0,0, 1,1,1, 1,0,1, 1,1,1,//o
            0,0,0, 0,0,0, 1,0,1, 1,1,0, 1,0,0,//r
            0,0,0, 0,0,0, 1,2,1, 1,2,2, 1,1,1,//e
            1,1,1, 1,3,1, 1,3,1, 1,3,1, 1,3,1,//M
            0,0,0, 0,0,0, 1,1,1, 1,0,1, 1,1,1,//o
            0,0,0, 0,0,0, 1,0,1, 1,0,1, 0,1,0,//v
            0,0,0, 0,0,0, 1,2,1, 1,2,2, 1,1,1,//e
            0,0,1, 0,0,1, 1,1,1, 1,0,1, 1,1,1 //d
        );
        var colr:int,colg:int,colb:int;
        switch(type){
            case 0:return;
            case 1:case 7: sp.graphics.lineStyle((b?4:1)*s/50,0xff0000,b?0.5:1);break;
            case 2:case 8: sp.graphics.lineStyle((b?4:1)*s/50,0xffff00,b?0.5:1);break;
            case 3:case 9: sp.graphics.lineStyle((b?4:1)*s/50,0x00ff00,b?0.5:1);break;
            case 4:case 10:sp.graphics.lineStyle((b?4:1)*s/50,0x00ffff,b?0.5:1);break;
            case 5:case 11:sp.graphics.lineStyle((b?4:1)*s/50,0x0000ff,b?0.5:1);break;
            case 6:case 12:sp.graphics.lineStyle((b?4:1)*s/50,0xff00ff,b?0.5:1);break;
            case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:
                colr=(Math.sin((type-13)*36*Math.PI/180)+1)*255/2;
                colg=(Math.sin(((type-13)*36+120)*Math.PI/180)+1)*255/2;
                colb=(Math.sin(((type-13)*36-120)*Math.PI/180)+1)*255/2;
                sp.graphics.lineStyle((b?4:1)*s/50,colr*256*256+colg*256+colb,b?0.5:1);
                break;
            default:
                sp.graphics.lineStyle((b?4:1)*s/50,0xffffff,b?0.5:1);
        }
        var i:int,j:int;
        var dts:Array=new Array();
        var dtf:Array=new Array();
        dts[0]=new Point(-25,-25);
        dtf[0]=new Point(25,-25);
        dts[1]=new Point(25,-25);
        dtf[1]=new Point(25,25);
        dts[2]=new Point(25,25);
        dtf[2]=new Point(-25,25);
        dts[3]=new Point(-25,25);
        dtf[3]=new Point(-25,-25);
        for(i=0;i<3;i++)for(j=0;j<5;j++){
            if(numbp[(type-1)*15+j*3+i]){
                if(j==0 || !numbp[(type-1)*15+(j-1)*3+i]){
                    dts[dts.length]=new Point(-12+8*i,-20+8*j);
                    dtf[dtf.length]=new Point(-4+8*i,-20+8*j);
                }
                if(i==0 || numbp[(type-1)*15+j*3+i]==3 || !numbp[(type-1)*15+j*3+(i-1)]){
                    dts[dts.length]=new Point(-12+8*i,-20+8*j);
                    dtf[dtf.length]=new Point(-12+8*i,-12+8*j);
                }
                if(j==4 || numbp[(type-1)*15+j*3+i]==2 || !numbp[(type-1)*15+(j+1)*3+i]){
                    dts[dts.length]=new Point(-4+8*i,-12+8*j);
                    dtf[dtf.length]=new Point(-12+8*i,-12+8*j);
                }
                if(i==2 || numbp[(type-1)*15+j*3+i]==3 || !numbp[(type-1)*15+j*3+(i+1)]){
                    dts[dts.length]=new Point(-4+8*i,-12+8*j);
                    dtf[dtf.length]=new Point(-4+8*i,-20+8*j);
                }
            }
        }
        for(i=0;i<dts.length;i++){
            sp.graphics.moveTo(x+(Math.cos(r)*dts[i].x-Math.sin(r)*dts[i].y)*s/50,y+(Math.sin(r)*dts[i].x+Math.cos(r)*dts[i].y)*s/50);
            sp.graphics.lineTo(x+(Math.cos(r)*dtf[i].x-Math.sin(r)*dtf[i].y)*s/50,y+(Math.sin(r)*dtf[i].x+Math.cos(r)*dtf[i].y)*s/50);
        }
        sp.graphics.moveTo(0,0);
    }
}

class Ps{
    public var x:int,y:int;
    public function Ps(X:int,Y:int){
        x=X;
        y=Y;
    }
}

class Mo{
    public var x:Number,y:Number,sx:Number,sy:Number;
    public var c:uint,t:int;
    public function Mo(X:Number,Y:Number,C:uint){
        x=X;
        y=Y;
        switch(C){
            case 0:c=0xff0000;break;
            case 1:c=0xffff00;break;
            case 2:c=0x00ff00;break;
            case 3:c=0x00ffff;break;
            case 4:c=0x0000ff;break;
            case 5:c=0xff00ff;break;
        }
    }
    public function Draw(sp:Sprite):void{
        sp.graphics.lineStyle(3,c,0.5);
        for(var i:int=0;i<4;i++){
            sp.graphics.moveTo(x+Math.cos((t*3+i*90)*Math.PI/180)*10,y+Math.sin((t*3+i*90)*Math.PI/180)*10);
            sp.graphics.lineTo(x+Math.cos((t*3+(i+1)*90)*Math.PI/180)*10,y+Math.sin((t*3+(i+1)*90)*Math.PI/180)*10);
        }
        sp.graphics.moveTo(0,0);
    }
}