[AS3]as3乱序排列法洗牌初始化1-52扑克牌
[AS3]as3乱序排列法洗牌初始化1-52扑克牌,这是一个初始化1-52扑克牌,然后进行乱序排列进行洗牌
这是一个初始化1-52扑克牌,然后进行乱序排列进行洗牌
- package
- {
- /*
- *@ClassName:package::PokerMain
- *@Intro:这是一个初始化1-52扑克牌,然后进行乱序排列进行洗牌;
- *@Author:非若
- *@Date:2015.07.22
- *@LanguageVersion:ActionScript 3.0
- *
- */
- import flash.display.Sprite;
- public class PokerMain extends Sprite
- {
- //CuPlayer.com提示:设置扑克牌总数
- private var NUM:Number = 52;
- public function PokerMain()
- {
- //CuPlayer.com提示:扑克洗牌:
- init_Shuffle();
- }
- private function init_Shuffle():void
- {
- var temp:Object = null;
- var _pokers:Vector.<Object > = get_Poker();
- for (var m:uint=0; m<NUM; m++)
- {
- var n:uint = Math.random() * NUM;
- temp = _pokers[m];
- _pokers[m] = _pokers[n];
- _pokers[n] = temp;
- trace(m+"--:--"+_pokers[m].name+"<|>"+_pokers[m].style);
- }
- }
- private function get_Poker():Vector.<Object >
- {
- //CuPlayer.com提示:创建扑克牌对象池
- var POKER:Vector.<Object>=new Vector.<Object>();
- var _name:String = "";
- var _style:String = "";
- for (var r:uint=0; r<NUM; r++)
- {
- var Poker:Object = {name:null,style:null};
- var n:uint=uint((r-0.3)/4);
- var m:uint=uint((r-1)%4);
- switch (m)
- {
- case 0 :
- {
- _style = "红桃";
- };
- break;
- case 1 :
- {
- _style = "黑桃";
- };
- break;
- case 2 :
- {
- _style = "方块";
- };
- break;
- case 3 :
- {
- _style = "梅花";
- };
- break;
- default :
- {
- _style = "未知";
- };
- break;
- }
- switch (n)
- {
- case 0 :
- _name = "K";
- break;
- case 1 :
- _name = "A";
- break;
- case 11 :
- _name = "J";
- break;
- case 12 :
- _name = "Q";
- break;
- default :
- _name = String(n);
- break;
- }
- Poker.name = _name;
- Poker.style = _style;
- POKER.push(Poker);
- }
- return POKER;
- }
- }
- }
来源:http://www.cnblogs.com/feiruo/p/4669071.html
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...