Forum Topic: As: Duplicated Mc Hit Detction

(5,391 views • 43 replies)

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
None

SpamBurger

Reply To Post Reply & Quote

Posted at: 11/13/05 12:57 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

AS: Main
AS: Duplicated Movie Clips
AS: For() loops.
AS: Hit Detection
-----------
Ok, in this tutorial, youll learn how to use hitTest() against duplicated movie clips. When you duplicate a movie clip, the dupes have a different instance name then the original. So, when using hitTest(), you have to check the collisions between 2 movie clips by using the instance names of the two. So, this will be a short tutorial on how to check collision with dupe movie clips.
-----------
I assume you know how to duplicate movie clips, but if not, check out the link above ^^. To check collision, you must use for() loops. If you dont know what those are, check out the link above^^. In its basic form, it would look like this:

for(i=1;i<9999;i++){
if(this.hitTest(_root["thing"+i])){
_root["thing"+i].doStuff();
}
}

Now, dont use that code becuase its just a model. Let me explain what it does:

The for() loops determines how many dupes of the movie clip there are. I just set it to a high number becuase if you have a number lower than the amount of movie clips on screen, not all the movie clips would be effected.
-----------
Also note that the code above would only detect collision between the dupe movie clips. So, that means that you also need to check hit detection between the original movie clip (I assume you know that).
-----------
Also, you see that instead of seeing _root.thing.blah, you see _root["thing"+i].blah. Thats becuase we are attaching "thing" with the value of i (which in this case is 9999).
-----------
I think Ive got everything, If I missed something or did something wrong, please post here :)

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

Claxor

Reply To Post Reply & Quote

Posted at: 11/13/05 01:02 PM

Claxor DARK LEVEL 10

Sign-Up: 10/21/05

Posts: 2,465

Nice tutorial. Will hopefully teach AS noobs something

BBS Signature

None

Blaze

Reply To Post Reply & Quote

Posted at: 11/13/05 01:03 PM

Blaze LIGHT LEVEL 22

Sign-Up: 08/04/05

Posts: 6,989

Neat. Nice tutorial . =] Easy to understand.

Yet.

there is something i never get. The i++ things. I never seem to get these things

if you could please point it out for me. =]


None

Toast

Reply To Post Reply & Quote

Posted at: 11/13/05 01:32 PM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,918

Spend more time on your ASes, there are about 2 more ways to do it...


None

Nemo

Reply To Post Reply & Quote

Posted at: 11/13/05 01:39 PM

Nemo LIGHT LEVEL 34

Sign-Up: 06/13/03

Posts: 1,895

At 11/13/05 01:03 PM, Darkfire_Blaze wrote: Neat. Nice tutorial . =] Easy to understand.

Yet.

there is something i never get. The i++ things. I never seem to get these things

if you could please point it out for me. =]

i++ is the same as saying i = i+1


None

Blaze

Reply To Post Reply & Quote

Posted at: 11/13/05 01:45 PM

Blaze LIGHT LEVEL 22

Sign-Up: 08/04/05

Posts: 6,989

At 11/13/05 01:39 PM, Atomic_Sponge wrote: i++ is the same as saying i = i+1

Thanks but that doesnt help me much. I get it. So, i = 1. which means i++ is the same as i = i+1. But i still dont get why i could use that for.

Im also having trouble... finding what math.stuff are good for. Cept for floor, round, and pow.

None

Toast

Reply To Post Reply & Quote

Posted at: 11/13/05 01:51 PM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,918

for(i=1;i<999;i++); Means that i is one. If i is below 999, it is inscresed by one, meaning that i is finally 999.


None

liaaaam

Reply To Post Reply & Quote

Posted at: 11/13/05 01:57 PM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

At 11/13/05 01:45 PM, Darkfire_Blaze wrote: Thanks but that doesnt help me much. I get it. So, i = 1. which means i++ is the same as i = i+1. But i still dont get why i could use that for.

Read Toasts post.

Im also having trouble... finding what math.stuff are good for. Cept for floor, round, and pow.

Math.ciel = Opposite of floor, rounds down.
Math.sqrt = Gets the square root of the number.
Math.abs = Gets the absolute value of a number, so it makes negatives positive.
Math.sin = Sine
Math.cos = Cosine
Math.tan = Tangent
Math.random = gets a random number between 0 and 1
Math.max = Gets the maximum value of the two specified
Math.min = Gets the minimum value of the two specified

There are others, but they're the ones I can remember.


None

authorblues

Reply To Post Reply & Quote

Posted at: 11/13/05 02:00 PM

authorblues FAB LEVEL 12

Sign-Up: 06/21/05

Posts: 6,360

At 11/13/05 01:45 PM, Darkfire_Blaze wrote: Im also having trouble... finding what math.stuff are good for. Cept for floor, round, and pow.

constants, properties, trig identities, and somehow, a Math object always finds its way into games. you cannot make games without them really (obviously, you could, but they are so very common).

GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

BBS Signature

None

liaaaam

Reply To Post Reply & Quote

Posted at: 11/13/05 03:30 PM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

Heres a simple Maths class, with a lot of the Math functions :D Basically I wanted to see if I could recreate the Maths class, and I did. I just left out all the trig (sin, cos, tan, etc) stuff. If theres anything else missing, tell me.

class Maths {
static var PI:Number = 3.14159265358979;
static var E:Number = 2.71828182845905;
static var LN2:Number = 0.693147180559945;
static var LN10:Number = 2.30258509299405;
static var LOG2E:Number = 1.44269504088896;
static var LOG10E:Number = 0.434294481903252;
static var SQRT1_2:Number = 0.707106781186548;
static var SQRT2:Number = 1.4142135623731;
static function max(a:Number, b:Number):Number {
return a>b ? a : b;
}
static function min(a:Number, b:Number):Number {
return a>b ? b : a;
}
static function rand(a:Number):Number {
return random(a);
}
static function sqrt(a:Number):Number {
for (var b = 0; b<a; b++) {
if (b*b == a) {
return b;
}
}
return NaN;
}
static function ceil(a:Number):Number {
return (1-a%1)+a;
}
static function floor(a:Number):Number {
return a-a%1;
}
static function round(a:Number):Number {
return a>(a-a%1)+0.5 ? ceil(a) : floor(a);
}
static function abs(a:Number):Number {
return a>0 ? a : -a;
}
static function pow(a:Number, b:Number):Number {
var temp:Number = a;
for (var c = 1; c<b; c++) {
temp *= a;
}
return temp;
}
static function exp(a:Number):Number {
return pow(E, a);
}
}

How 1337.


None

Rustygames

Reply To Post Reply & Quote

Posted at: 11/13/05 04:12 PM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,662

Oh noes
You can almost hear Delta getting ready to come in and pwn you

- Matt, Rustyarcade.com


None

liaaaam

Reply To Post Reply & Quote

Posted at: 11/13/05 04:28 PM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

At 11/13/05 04:12 PM, Ninja-Chicken wrote: You can almost hear Delta getting ready to come in and pwn you

Why would he try to do that? I'm perfectly aware that he has wrote his own math classes and mine and his are totally different, I just re-wrote the Math class (and left some stuff out ;D) to test my skills (sorta). dELtas Math classes add stuff, and are much more complex.

Now, go learn OOP you nub.


None

authorblues

Reply To Post Reply & Quote

Posted at: 11/13/05 04:53 PM

authorblues FAB LEVEL 12

Sign-Up: 06/21/05

Posts: 6,360

At 11/13/05 03:30 PM, -liam- wrote: static function rand(a:Number):Number {
return random(a);
}

cheater. you cant recreate the Math class by using the Math class...

static function sqrt(a:Number):Number {
for (var b = 0; b<a; b++) {
if (b*b == a) {
return b;
}
}
return NaN;
}

what if a isnt a perfect square?
Maths.sqrt(7) = NaN?

static function pow(a:Number, b:Number):Number {
var temp:Number = a;
for (var c = 1; c<b; c++) {
temp *= a;
}
return temp;
}

and if b just so happens to be a decimal? isnt there a formula to approximate power functions? ive been toying with something like this for a while, but i know its possible.

GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

BBS Signature

None

T-H

Reply To Post Reply & Quote

Posted at: 11/13/05 04:55 PM

T-H LIGHT LEVEL 39

Sign-Up: 01/07/04

Posts: 4,893

Once again youve made a tutorial thats WAY too topical.

you should have at least called it "Referencing Dynamically Created MovieClips" because thats all you are teaching.


None

liaaaam

Reply To Post Reply & Quote

Posted at: 11/13/05 04:59 PM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

At 11/13/05 04:53 PM, authorblues wrote: cheater. you cant recreate the Math class by using the Math class...

Random isn't part of the maths class.

what if a isnt a perfect square?
Maths.sqrt(7) = NaN?

Good point, probably better off with:

static function sqrt(a:Number):Number {
for (var b = 0; b<a; b++) {
if (b*b == a) {
return b;
}
}
return a;
}

and if b just so happens to be a decimal? isnt there a formula to approximate power functions? ive been toying with something like this for a while, but i know its possible.

I'll have to ask dELta about that XP but for now:

static function pow(a:Number, b:Number):Number {
var temp:Number = a;
for (var c = 1; c<round(b); c++) {
temp *= a;
}
return temp;
}

Thanks for the comments =P


None

T-H

Reply To Post Reply & Quote

Posted at: 11/13/05 05:17 PM

T-H LIGHT LEVEL 39

Sign-Up: 01/07/04

Posts: 4,893

At 11/13/05 04:59 PM, -liam- wrote:
At 11/13/05 04:53 PM, authorblues wrote: cheater. you cant recreate the Math class by using the Math class...
Random isn't part of the maths class.

lol touché, but technically its been replaced with Math.random(), which is.

I still use plain random() most of the time though


None

Reed

Reply To Post Reply & Quote

Posted at: 11/13/05 05:25 PM

Reed FAB LEVEL 18

Sign-Up: 03/25/04

Posts: 3,866

Great tut Spam!

I put it in favorites.

None

authorblues

Reply To Post Reply & Quote

Posted at: 11/13/05 05:32 PM

authorblues FAB LEVEL 12

Sign-Up: 06/21/05

Posts: 6,360

At 11/13/05 04:59 PM, -liam- wrote: Random isn't part of the maths class.

random(num) is a property that strictly uses Math.random()

function random(num:Number):Number{
return Math.floor(Math.random()*num);
}

ha, so you used two properties of the math class. ha.

GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

BBS Signature

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 11/13/05 05:46 PM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

powers and roots are not limited to positive integers.
powers can be defined for any arbitary number/complex number/quaternion

although taking roots for example, the most common method of obtaining the root of a number is using Newtons iteration (which i dont know, i just know its the most common method used)

anyways here are my math classes for the sake of it :p

class emath extends Math
{
static var Rad:Number = 0.0174532925199433;
static var Deg:Number = 57.2957795130823;
static var PI2:Number = 6.28318530717959;
static var Phi:Number = 1.61803398874989;
static var phi:Number = 0.61803398874989;
static var SQRT2:Number = 1.4142135623731;
static var SQRT3:Number = 1.73205080756888;
static var SQRT4:Number = 2;
static var SQRT5:Number = 2.23606797749979;
static var SQRT6:Number = 2.44948974278318;
static var SQRT7:Number = 2.64575131106459;
static var SQRT8:Number = 2.82842712474619;
static var SQRT9:Number = 3;
static var SQRT10:Number = 3.16227766016838;
static var SQRT11:Number = 3.3166247903554;
static var SQRT12:Number = 3.46410161513775;
static var SQRT13:Number = 3.60555127546399;
static var SQRT14:Number = 3.74165738677394;
static var SQRT15:Number = 3.87298334620742;
static var SQRT16:Number = 4;
static var SQRT17:Number = 4.12310562561766;
static var SQRT18:Number = 4.24264068711928;
static var SQRT19:Number = 4.35889894354067;
static var SQRT20:Number = 4.47213595499958;
static var SQRT21:Number = 4.58257569495584;
static var SQRT22:Number = 4.69041575982343;
static var SQRT23:Number = 4.79583152331272;
static var SQRT24:Number = 4.89897948556636;
static var SQRT25:Number = 5;
static var G:Number = 6.673e-11;
static var g:Number = 6.673e-12;
static var inf:Number = Number.POSITIVE_INFINITY;
static var ninf:Number = Number.NEGATIVE_INFINITY;
//
static function Min():Number
{
var low:Number = (typeof (arguments[0]) == "number" ? arguments[0] : arguments[0][0]);
var i:Number;
for (i = 0; i < arguments.length; i++)
{
if (typeof (arguments[i]) == "number")
{
if (arguments[i] < low)
{
low = arguments[i];
}
} else
{
var j:Number;
for (j = 0; j < arguments[i].length; j++)
{
if (arguments[i][j] < low)
{
low = arguments[i][j];
}
}
}
}
return low;
}
static function Max():Number
{
var high:Number = (typeof (arguments[0]) == "number" ? arguments[0] : arguments[0][0]);
var i:Number;
for (i = 0; i < arguments.length; i++)
{
if (typeof (arguments[i]) == "number")
{
if (arguments[i] > high)
{
high = arguments[i];
}
} else
{
var j:Number;
for (j = 0; j < arguments[i].length; j++)
{
if (arguments[i][j] > high)
{
high = arguments[i][j];
}
}
}
}
return high;
}
//
static function Fib(n:Number):Number
{
return round((Math.pow(Phi, n) - Math.pow(-Phi, -n)) / SQRT5);
}
static function isPrime(n:Number):Boolean
{
if (n != round(n) || n < 2)
{
return false;
}
if (n == 2)
{
return true;
}
var i:Number;
for (i = 2; i <= sqrt(n) + 1; i++)
{
if (n / i == round(n / i))
{
return false;
}
}
return true;
}
private static var gamms:Array = new Array(inf, 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001599, 6227020793, 87178291129, 1307674367233, 20922789878933, 355687427980145);
static function Gamma(x:Number, a:Boolean):Number
{
if (gamms[x] != undefined)
{
return gamms[x];
}
var b:Number = sqrt((PI2) / x) * pow((x / E) * sqrt(x * sinh(1 / x) + (a ? 1 / (810 * Math.pow(x, 6)) : 0)), x);
if (x == round(x))
{
return round(b);
}
return b;
}
static function Fact(x:Number, a:Boolean):Number
{
return Gamma(x + 1, a);
}
//
static function C(r:Number,k:Number):Number
{
return Fact(r)/(Fact(k)*(Fact(r-k)));
}
//
static function sinh(x:Number):Number
{
return (exp(x) - exp(-x)) / 2;
}
static function cosh(x:Number):Number
{
return (exp(x) + exp(-x)) / 2;
}
static function tanh(x:Number):Number
{
return sinh(x) / cosh(x);
}
//
static function asinh(x:Number):Number
{
return log(x + sqrt(x * x + 1));
}
static function acosh(x:Number):Number
{
return log(x + sqrt(x * x - 1));
}
static function atanh(x:Number):Number
{
return 0.5 * log((1 + x) / (1 - x));
}
//
static function sec(x:Number):Number
{
return 1 / cos(x);
}
static function csc(x:Number):Number
{
return 1 / sin(x);
}
static function cot(x:Number):Number
{
return 1 / tan(x);
}
//
static function asec(x:Number):Number
{
return acos(1 / x);
}
static function acsc(x:Number):Number
{
return asin(1 / x);
}
static function acot(x:Number):Number
{
return atan(1 / x);
}
//
static function sech(x:Number):Number
{
return 1 / cosh(x);
}
static function csch(x:Number):Number
{
return 1 / sinh(x);
}
static function coth(x:Number):Number
{
return 1 / tanh(x);
}
//
static function asech(x:Number):Number
{
return acosh(1 / x);
}
static function acsch(x:Number):Number
{
return asinh(1 / x);
}
static function acoth(x:Number):Number
{
return atanh(1 / x);
}
//
static function isInt(x:Number):Boolean
{
return x == round(x);
}
static function isEven(x:Number):Boolean
{
return isInt(x) && x / 2 == round(x / 2);
}
static function isOdd(x:Number):Boolean
{
return isInt(x) && x / 2 != round(x / 2);
}
//
static function xlog(n:Number, x:Number):Number
{
return log(n) / log(x);
}
//
static function roundTo(x:Number, dp:Number):Number
{
var b:Number = pow(10, dp);
return round(x * b) / b;
}
static function floorTo(x:Number, dp:Number):Number
{
var b:Number = pow(10, dp);
return floor(x * b) / b;
}
static function ceilTo(x:Number, dp:Number):Number
{
var b:Number = pow(10, dp);
return ceil(x * b) / b;
}
}
and ill post my complex one in next reply since im running out of chars

My social worker says im special!

BBS Signature

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 11/13/05 05:50 PM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

class cmath extends emath
{
static function Complex(x:Number, y:Number):Array
{
return new Array(x, y);
}
static function add(a:Array, b:Array):Array
{
return new Array(a[0] + b[0], a[1] + b[1]);
}
static function min(a:Array, b:Array):Array
{
return new Array(a[0] - b[0], a[1] - b[1]);
}
static function mul(a:Array, b:Array):Array
{
return new Array(a[0] * b[0] - a[1] * b[1], a[0] * b[1] + a[1] * b[0]);
}
static function conj(a:Array):Array
{
return new Array(a[0], -a[1]);
}
static function abs(a:Array):Array
{
return new Array(Math.abs(a[0]), Math.abs(a[1]));
}
static function neg(a:Array):Array
{
return new Array(-a[0], -a[1]);
}
static function arg(a:Array):Number
{
return atan2(a[1], a[0]);
}
static function mod(a:Array, b:Boolean):Number
{
var d:Number = a[0] * a[0] + a[1] * a[1];
if (b)
{
return d;
}
return Math.sqrt(d);
}
static function div(a:Array, b:Array):Array
{
var d:Number = mod(b, true);
return new Array((a[0] * b[0] + a[1] * b[1]) / d, (a[0] * b[1] - a[1] * b[0]) / d);
}
static function sqrt(a:Array):Array
{
var r:Number = Math.sqrt(mod(a));
var t:Number = arg(a) / 2;
return new Array(r * Math.cos(t), r * Math.sin(t));
}
static function exp(a:Array):Array
{
var b:Number = Math.exp(a[0]);
return new Array(b * Math.cos(a[1]), b * Math.sin(a[1]));
}
static function log(a:Array):Array
{
return new Array(Math.log(mod(a)), arg(a));
}
static function xlog(a:Array, x:Array):Array
{
return div(log(a), log(x));
}
static function pow(a:Array, b:Array):Array
{
var r:Number = mod(a);
var t:Number = arg(a);
var x:Number = Math.pow(r, b[0]) * Math.exp(-b[1] * t);
var y:Number = b[0] * t + b[1] * Math.log(r);
return new Array(x * Math.cos(y), x * Math.sin(y));
}
//
static function sin(a:Array):Array
{
return new Array(emath.cosh(a[1]) * Math.sin(a[0]), emath.sinh(a[1]) * Math.cos(a[0]));
}
static function cos(a:Array):Array
{
return new Array(emath.cosh(a[1]) * Math.cos(a[0]), -emath.sinh(a[1]) * Math.sin(a[0]));
}
static function tan(a:Array):Array
{
return div(sin(a), cos(a));
}
//
static function sec(a:Array):Array
{
return div(new Array(1, 0), cos(a));
}
static function csc(a:Array):Array
{
return div(new Array(1, 0), sin(a));
}
static function cot(a:Array):Array
{
return div(cos(a), sin(a));
}
//
static function asin(a:Array):Array
{
return mul(new Array(0, -1), log(add(mul(new Array(0, 1), a), sqrt(min(new Array(1, 0), mul(a, a))))));
}
static function acos(a:Array):Array
{
return add(new Array(0.5 * PI, 0), mul(new Array(0, 1), log(add(mul(new Array(0, 1), a), sqrt(min(new Array(1, 0), mul(a, a)))))));
}
static function atan(a:Array):Array
{
return mul(new Array(0, 0.5), log(div(min(new Array(0, 1), a), add(new Array(0, 1), a))));
}
//
static function asec(a:Array):Array
{
return acos(div(new Array(1, 0), a));
}
static function acsc(a:Array):Array
{
return asin(div(new Array(1, 0), a));
}
static function acot(a:Array):Array
{
if (a[0] == 0 && a[1] == 0)
{
return new Array(emath.acot(0), 0);
}
return atan(div(new Array(1, 0), a));
}
//
static function sinh(a:Array):Array
{
var b:Array = min(exp(a), exp(new Array(-a[0], -a[1])));
return new Array(b[0] / 2, b[1] / 2);
}
static function cosh(a:Array):Array
{
var b:Array = add(exp(a), exp(new Array(-a[0], -a[1])));
return new Array(b[0] / 2, b[1] / 2);
}
static function tanh(a:Array):Array
{
return div(sinh(a), cosh(a));
}
//
static function sech(a:Array):Array
{
return div(new Array(1, 0), cosh(a));
}
static function csch(a:Array):Array
{
return div(new Array(1, 0), sinh(a));
}
static function coth(a:Array):Array
{
var b:Array = exp(a);
var c:Array = exp(new Array(-a[0], -a[1]));
return div(add(b, c), min(b, c));
}
//
static function asinh(a:Array):Array
{
return log(add(a, sqrt(add(new Array(1, 0), mul(a, a)))));
}
static function acosh(a:Array):Array
{
return log(add(a, sqrt(min(mul(a, a), new Array(1, 0)))));
}
static function atanh(a:Array):Array
{
var b:Array = log(div(new Array(1 + a[0], a[1]), new Array(1 - a[0], a[1])));
return new Array(b[0] / 2, b[1] / 2);
}
//
static function asech(a:Array):Array
{
return acosh(div(new Array(1, 0), a));
}
static function acsch(a:Array):Array
{
return asinh(div(new Array(1, 0), a));
}
static function acoth(a:Array):Array
{
return atanh(div(new Array(1, 0), a));
}
//
static function round(a:Array):Array
{
return new Array(Math.round(a[0]), Math.round(a[1]));
}
static function floor(a:Array):Array
{
return new Array(Math.floor(a[0]), Math.floor(a[1]));
}
static function ceil(a:Array):Array
{
return new Array(Math.ceil(a[0]), Math.ceil(a[1]));
}
//
private static var gamms:Array = new Array(inf, 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001599, 6227020793, 87178291129, 1307674367233, 20922789878933, 355687427980145);
static function Gamma(a:Array, b:Boolean):Array
{
if (a[1] == 0 && gamms[a[0]] != undefined)
{
return new Array(gamms[a[0]], 0);
}
if (a[1] == 0 && isInt(a[0]) && a[0] <= 0)
{
return new Array(inf, 0);
}
var c:Array = div(new Array(PI2, 0), a);
var d:Array = div(a, new Array(E, 0));
var e:Array = mul(a, sinh(div(new Array(1, 0), a)));
//
if (a[1] == 0 && isInt(a[0]))
{
e = pow(mul(d, e), a);
e = mul(sqrt(c), e);
return new Array(Math.round(e[0]), 0);
}
if (b)
{
e = add(e, div(new Array(1, 0), mul(new Array(810, 0), pow(a, new Array(6, 0)))));
}
e = pow(mul(d, e), a);
return mul(sqrt(c), e);
}
static function Fact(a:Array, b:Boolean):Array
{
return Gamma(new Array(1 + a[0], a[1]), b);
}
//
static function C(r:Array, k:Array):Array
{
var b:Array = div(Fact(r), mul(Fact(k), Fact(min(r, k))));
if (b[0] == inf || b[0] == ninf || isNaN(b[0]) || b[1] == inf || b[1] == ninf || isNaN(b[1]))
{
return new Array(0, 0);
}
return b;
}
static function Fib(n:Array):Array
{
return div(min(pow(new Array(emath.Phi, 0), n), pow(new Array(-emath.Phi, 0), new Array(-n[0], -n[1]))), new Array(emath.SQRT5, 0));
}
}

emath:

Min and Max take 'n' number of arguments, either numbers, or arrays of numbers, or both:
emath.Min(4,1,[2,4]); is acceptable
im running out of chars again:

cmath:

a complex number in my class is defined as [x,y] in an array

for both, Gamma and Factorial are approximations , 0 chars remaining lmao :D

My social worker says im special!

BBS Signature

None

authorblues

Reply To Post Reply & Quote

Posted at: 11/13/05 06:10 PM

authorblues FAB LEVEL 12

Sign-Up: 06/21/05

Posts: 6,360

since, as many know, random() isnt truly random, and is based off of time, i decided to use what i could think of to make a pseudo-random script. heres what i came up with, and it works perfectly:

function prandom():Number{
var whn:Date = new Date();
return (getTimer()%whn.getMilliseconds())/whn.get
Milliseconds();
}

function prandom2(num:Number):Number{
return Math.floor(prandom()*Math.floor(num));
}

feel free to have that, dELta...
prandom() represents the Math.random(); function
prandom2() represents the random(num); function

GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

BBS Signature

None

rmthegreat88

Reply To Post Reply & Quote

Posted at: 11/13/05 06:11 PM

rmthegreat88 LIGHT LEVEL 10

Sign-Up: 04/17/04

Posts: 1,314

good god


None

SpamBurger

Reply To Post Reply & Quote

Posted at: 11/13/05 06:13 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

At 11/13/05 04:55 PM, T-H wrote: Once again youve made a tutorial thats WAY too topical.

Bleh...

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

JD77

Reply To Post Reply & Quote

Posted at: 11/13/05 06:16 PM

JD77 NEUTRAL LEVEL 17

Sign-Up: 03/30/05

Posts: 1,059

nice tut spam! =P

*User Page under construction*

BBS Signature

None

Toast

Reply To Post Reply & Quote

Posted at: 11/14/05 02:30 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,918

=O
*Opens mouth in amazement.*
Stop doing those things, you'll make Liam feel sad =)


None

liaaaam

Reply To Post Reply & Quote

Posted at: 11/14/05 08:18 AM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

At 11/13/05 06:10 PM, authorblues wrote: heres what i came up with, and it works perfectly.

Nice, I'll change mine for yours if you don't mind :)

Though random doesn't use Math functions because random was around before Math, wasn't it?


None

authorblues

Reply To Post Reply & Quote

Posted at: 11/14/05 08:31 AM

authorblues FAB LEVEL 12

Sign-Up: 06/21/05

Posts: 6,360

At 11/14/05 08:18 AM, -liam- wrote: Though random doesn't use Math functions because random was around before Math, wasn't it?

my actuall prandom() class doesnt use any Math classes, but random was always based on time, even further back into programming. i know that random used to be based a bit more strictly on the number of milliseconds, but programming languages began using a command called "randomize timer", which used a more complicated algorithm to generate random numbers.

you should replace all my Math classes in my prandom2() with your math class's equivalent. oh, and here is a version that works better (that one returns NaN on a rare occasion):

function prandom():Number{
var whn:Date = new Date();
return (getTimer()%(whn.getMilliseconds()+1))/(wh
n.getMilliseconds()+1);
}

function prandom2(num:Number):Number{
return Math.floor(prandom()*Math.floor(num));
}

GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

BBS Signature

None

Blaze

Reply To Post Reply & Quote

Posted at: 11/14/05 08:50 AM

Blaze LIGHT LEVEL 22

Sign-Up: 08/04/05

Posts: 6,989

At 11/13/05 01:51 PM, -Toast- wrote: for(i=1;i<999;i++); Means that i is one. If i is below 999, it is inscresed by one, meaning that i is finally 999.

oooh!!! I finally get it. :) Thanks man!

To liam

Thanks, there were a few functions i didnt know about. And i was messing around in flash yesterday, and found out those are really useful... =] Thanks.


None

T-H

Reply To Post Reply & Quote

Posted at: 11/14/05 11:34 AM

T-H LIGHT LEVEL 39

Sign-Up: 01/07/04

Posts: 4,893

At 11/13/05 06:13 PM, SpamBurger wrote:
At 11/13/05 04:55 PM, T-H wrote: Once again youve made a tutorial thats WAY too topical.
Bleh...

No offence, better there actually be one of these because there hasn't been yet. But I'd argue that it should be renamed for helpfulness.

:D


None

Hoeloe

Reply To Post Reply & Quote

Posted at: 4/8/06 09:33 AM

Hoeloe LIGHT LEVEL 28

Sign-Up: 04/29/04

Posts: 5,014

i got a problem... it works fine, but when i export it the amount of lag is incredible
at 99 FPS it acts as though it is at 12 FPS on High quality

Sex!
------------------------------
Super Nuke Bros. Melee, the web's no. 1 awaited Super Smash Tribute Game!

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 11:17 PM

<< Back

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!