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

forked from: カード雨

カードの雨
ゲーム作りたい。。。
Get Adobe Flash player
by roll.sagawa 21 Mar 2011
/**
 * Copyright roll.sagawa ( http://wonderfl.net/user/roll.sagawa )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5W28
 */

// forked from Dorara's カード雨
// カードの雨
//   ゲーム作りたい。。。
package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;

    [SWF(width="465", height="465",backgroundColor=0x00000000,frameRate=60)]
    public class tranp extends Sprite
    {
        private var mycard:myCARD;
        private var cards:Array;
        private var N:int = 100;
        
        public function tranp()
        {
            this.stage.scaleMode = StageScaleMode.NO_SCALE;
            this.stage.align = StageAlign.TOP_LEFT;
            
            mycard = new myCARD();
            cards = new Array(N);
            
            for(var i:int = 0; i<N; i++){
                var sp:Sprite = new Sprite();
                var bmp:Bitmap = mycard.createCard((int)(Math.random()*12+1),(int)(Math.random()*4));
                var scale:Number = Math.random()*0.7+0.3;
                bmp.x -= 50*scale;
                bmp.y -= 75*scale;
                bmp.scaleX = scale;
                bmp.scaleY = scale;
                sp.addChild(bmp);
                sp.x = Math.random()*465;
                sp.y = Math.random()*465;
                sp.rotation = Math.random()*360;
                sp.alpha = 0.8;
                cards[i] = sp;
                this.addChild(sp);
            }
            
            this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        private function onEnterFrame(e:Event):void {
            for(var i:int = 0; i<N; i++){
                cards[i].y += cards[i].scaleX * 2;
                cards[i].rotation += cards[i].scaleX * 2;
                if(cards[i].rotation >= 360) cards[i].rotation = 0;
                
                
                if(cards[i].y > 500){
                    var scale:Number = Math.random()*0.7+0.3;
                    cards[i].scaleX = scale;
                    cards[i].scaleY = scale;
                    cards[i].x = Math.random() * 465;
                    cards[i].y = -50;
                }
            }
        }
    }
    
}


import flash.display.Sprite;
import flash.text.TextField;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.text.TextFormat;
    

class myCARD {
    private var cardtype:Array = ["♠", "♣", "♦", "♥"];
    private var cardnumb:Array = ["-","A","2","3","4","5","6","7","8","9","10","J","Q","K"];
    private var pn:Array = [0,0x4000,0x3000,0x4c00,0x2d0,0x42d0,0x3f0,0x23f0,0x2df,0x22df,0x32df];
    private var px:Array = [40,40,40,40,40,20,20,20,60,60,60,20,20,60,60];
    private var py:Array = [75,45,105,25,125,25,75,125,25,75,125,60,95,60,95];
    //カード生成
    public function createCard(number:int, type:int):Bitmap {
        var ret:Sprite = new Sprite();
        var retBitmap:Bitmap = new Bitmap();
        var retBitmapD:BitmapData = new BitmapData(100, 150, true, 0x000000);
        var tmpbmpD:BitmapData = new BitmapData(100, 150, true, 0x000000);
        var tmpbmp:Bitmap = new Bitmap();
        var tmpsp:Sprite = new Sprite();
        var textFormat:TextFormat = new TextFormat();
        textFormat.size = 23;
        if(type == 0 || type == 1){textFormat.color = 0x000000;}
        else {textFormat.color = 0xff0000;}
        
        //外枠
        tmpsp.graphics.beginFill(0xffffff);
        tmpsp.graphics.drawRoundRect(0, 0, 100, 150, 20, 20);
        tmpsp.graphics.endFill();
        tmpbmpD.draw(tmpsp);


        {//右下のナンバーと記号
            var ntext1:TextField = new TextField();
            ntext1.defaultTextFormat = textFormat;
            ntext1.text = cardnumb[number] + "\n" + cardtype[type];
            ntext1.x = 0;
            ntext1.y = 0;
            tmpbmpD.draw(ntext1);
            tmpbmp.bitmapData = tmpbmpD;
            tmpbmp.rotation = 180;
            tmpbmp.x = 100;
            tmpbmp.y = 150;
            ret.addChild(tmpbmp);
        }
        //カード内部
        if(1 <= number && number <= 10){
            var b:uint = pn[number];
            var comp:uint = 0x4000;
            var cmped:uint;
            for(var i:int = 0; i<15; i++){
                cmped = b & comp;
                if(cmped > 0){
                    var kigou:TextField = new TextField();
                    kigou.defaultTextFormat = textFormat;
                    kigou.text = cardtype[type];
                    kigou.x = px[i] - 3;
                    kigou.y = py[i] - 10;
                    ret.addChild(kigou);
                }
                comp = comp >> 1;
            }

        }
        else if(11 <= number && number <= 13){
            var gara:Sprite = new Sprite();
            gara.graphics.beginFill(0xcccccc);
            gara.graphics.drawRect(25,25,50,100);
            gara.graphics.endFill();
            ret.addChild(gara);
        }
        
        {//左上のナンバーと記号
            var ntext2:TextField = new TextField();
            ntext2.defaultTextFormat = textFormat;
            ntext2.text = cardnumb[number] + "\n" + cardtype[type];
            ntext2.x = 0;
            ntext2.y = 0;
            ret.addChild(ntext2);
        }

        retBitmapD.draw(ret);
        retBitmap.bitmapData = retBitmapD;
        return retBitmap;
    }
}