|
  
- 精华
- 4
- 积分
- 3887
- 威望
- 108 点
- 银子
- 1651 两
- 金子
- 0 两
- 来自
- 杭州
  
|
9RIA天地会官方培训机构
Adobe官方认证培训中心
[AS3] AS3 Dice Class & Dice Tester :色子机系统
嘿嘿,有人对DND系列(龙与地下城)游戏感兴趣的话,一定会知道色子有很多类,
从4面色子到20面色子~~
嗯嗯
在AS3实现起来也很简单,呵呵这个类已经方便的提供了基础的几个,
有需要的朋友可以去下载咯~!!
演示:
http://files.hexagonstar.com/labs/diceclass/dicetester.swf
下载地址:
http://files.hexagonstar.com/classes/as3/diceclass.zip
原文:
AS3 Dice Class & Dice Tester
In game development randomness is often necessary for certain tasks, be it the random distribution of graphic tiles, a random factor in NPC AI or random stats in a roleplaying game. Especially for the latter purpose the static Dice class provides a set of methods to roll dice as it is common in a RPG, to be exact four-, six-, eight-, ten-, twelve-, twenty-sided and percentile dice.
The Dice class (and it’s supporting classes) are rather elaborated, using for example the Linear Congruential algorithm in the process of generating ‘true’ random numbers so it might not be the most speed-optimized method for calculating random numbers. For absolute performance the LCA and rounding routines can be removed to speed up calculations.
Using the Dice class is very simple! For example rolling two ten-sided dice can be done with the following call …
var result:int = Dice.tenSided(2);
… rolling the percentile die is even simpler as it does not need any arguments. It always returns a value between 1 and 100 …
var result:int = Dice.percentile();
… the class also provides the roll method with that any x-sided die could be rolled, 3 sixteen-sided dice for instance …
var result:int = Dice.roll(16, 3);
The following application uses the Dice class and can be used to test dice throw probability according to the bell curve (the more dice are used the lower the probability to roll boundary results).
[ 本帖最后由 KingFo_HZ 于 2007-12-25 14:13 编辑 ] |
|