a Flash dice roller using custom-rendered virtual dice.
of course, this could be customized to match a particular sort of roll and style of game.
the next version contains the ability to set all of the attributes from the HTML page, and to send the results back to it’s containing HTML page.
for example, in firewater productions’s game “Chaos University”, the standard is 5 dice:
a simple image vewer, mostly put together to test transition effects and loading progress animation.
note: none of the viewers will ever load anything, the xml media list has only one dummy entry (to force it to continuously show the loading progress animation).
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque sollicitudin accumsan est. Sed volutpat elit ut diam. Mauris placerat placerat sem. Nullam non pede eget tellus adipiscing tempor. Duis ullamcorper. Cras sem justo, lacinia a, tempus vel, facilisis in, dui. Mauris eros erat, ultricies non, mattis nec, pulvinar at, libero. Proin purus. Donec interdum. Nam consequat dui. Ut nec leo. Nulla purus est, rutrum et, pretium ut, lacinia sollicitudin, felis. Nulla facilisi. Aliquam nibh eros, tempor vel, tincidunt eu, luctus id, metus. Praesent pellentesque.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque sollicitudin accumsan est. Sed volutpat elit ut diam. Mauris placerat placerat sem. Nullam non pede eget tellus adipiscing tempor. Duis ullamcorper. Cras sem justo, lacinia a, tempus vel, facilisis in, dui. Mauris eros erat, ultricies non, mattis nec, pulvinar at, libero. Proin purus. Donec interdum. Nam consequat dui. Ut nec leo. Nulla purus est, rutrum et, pretium ut, lacinia sollicitudin, felis. Nulla facilisi. Aliquam nibh eros, tempor vel, tincidunt eu, luctus id, metus. Praesent pellentesque.
Notes:
as this method uses a series of lines to construct the curve, a low angular change will result in a smoother curve. however, if a higher value is used, this will construct what appear to be “warped” polygons. for example, an angular change of 45 degrees (Pi/4 rad) will give an eight sided polygon. changing the dx and dy will still result in an elliptical shape.
ActionScript:
with( MovieClip_Object ) {
//center of ellipse
var x0 = Stage.width/2;
var y0 = Stage.height/2;
//ellipse bounds
var dx = 300;
var dy = 100;
//angular change
var dn = 1 * (Math.PI/180);
var r,x,y;
lineStyle(1, 0x000000);
for( var n=0; n<2*Math.PI; n+=dn ) {
x = dx*Math.cos(n);
y = dy*Math.sin(n);
moveTo(x0+x,y0+y);
x = dx*Math.cos(n+dn);
y = dy*Math.sin(n+dn);
lineTo(x0+x,y0+y);
}
}
in this version, the backend bases the force to apply on the number of clicks, it is also possible to base the force applied on the distance the head is dragged, or on length of time the head is clicked.
var angle_deg = angle_rad * 180/Math.PI;
var angle_rad = angle_deg * Math.PI/180;
find (x,y) from angle and radius:
var x = radius * cos( angle_rad );
var y = radius * sin( angle_rad );
a minor issue you will come across in ActionScript is that all of trigonometry functions in Math are based on the angle in radians, and a MovieClip’s _rotation property is based on the angle in degrees (this is not a bug or a flaw, but rather a design decision).