So I made sun rays.

16 posts

Flag Post

yeah- they look pretty good. You can pass in a start angle and an end angle and they create a little “sun ray” dynamically.

Here is the class (not really primed for public release but whatever): http://pastebin.com/pxVBKSf5

I’d also appreciate if you could check out the demo and tell me how well it runs. Use WASD/Arrow keys to move. http://www.fastswf.com/Dx8M9Do

 
Flag Post

FastMath class is referenced. What is this class?

 
Flag Post

If the rays were red and the background was white, it would remind me a lot of chinese symbolism. It looks really weird in the centre where all the rays meet. Not in a bad way, just…. weird.
It runs fairly well on my 6 year old custom.

Would test the code myself, but I don’t know anything about this fastmath class thats referenced.

 
Flag Post

Using a Math class like that really doesn’t help with fastness unless you can inline it :P

 
Flag Post

I was really upset when I wasn’t allowed to get the star. :(

 
Flag Post

Yea- i forgot to include a few classes- very sorry about that. Later today I’ll set up a GitHub repo.

@alecz, yeah, it does look pretty weird. In game I’ll probably have a sun there

@qwerber my FastMath.ceil and floor functions are 7x faster than Adobe’s.

@Yoshi, that’s the point of the game :P

 
Flag Post

RTL, I’m curious as qwerber is. A lot of performance increase in math stuff does come from avoiding a function call (luckily we’ll have inlining in ASC 2.0) Post your FastMath class and performance test maybe?


Also, this:

Originally posted by DrYoshiyahu:

I was really upset when I wasn’t allowed to get the star. :(

 
Flag Post
Originally posted by BobTheCoolGuy:

RTL, I’m curious as qwerber is. A lot of performance increase in math stuff does come from avoiding a function call (luckily we’ll have inlining in ASC 2.0) Post your FastMath class and performance test maybe?


Also, this:

Originally posted by DrYoshiyahu:

I was really upset when I wasn’t allowed to get the star. :(


I could very well be wrong, but when I did the whole getTimer trick it all added up.

FastMath Class: http://pastebin.com/LrnCBk3H
Vector2D Class: http://pastebin.com/ExE4XPWY
VectorUtils Class: http://pastebin.com/6W9qntDn

 
Flag Post
Originally posted by RTL_Shadow:
Originally posted by BobTheCoolGuy:

RTL, I’m curious as qwerber is. A lot of performance increase in math stuff does come from avoiding a function call (luckily we’ll have inlining in ASC 2.0) Post your FastMath class and performance test maybe?


Also, this:

Originally posted by DrYoshiyahu:

I was really upset when I wasn’t allowed to get the star. :(


I could very well be wrong, but when I did the whole getTimer trick it all added up.

FastMath Class: http://pastebin.com/LrnCBk3H
Vector2D Class: http://pastebin.com/ExE4XPWY
VectorUtils Class: http://pastebin.com/6W9qntDn

Ah, well, I didn’t test it, but you do have one small bug. Say you do Math.floor(-9.7). Your code would return -9 instead of -10. Same thing could happen for ceil I think. You also don’t have to explicitly cast your results to Number. I’m not sure what the performance impact of that is though.

 
Flag Post
Originally posted by BobTheCoolGuy:
Originally posted by RTL_Shadow:
Originally posted by BobTheCoolGuy:

RTL, I’m curious as qwerber is. A lot of performance increase in math stuff does come from avoiding a function call (luckily we’ll have inlining in ASC 2.0) Post your FastMath class and performance test maybe?


Also, this:

Originally posted by DrYoshiyahu:

I was really upset when I wasn’t allowed to get the star. :(


I could very well be wrong, but when I did the whole getTimer trick it all added up.

FastMath Class: http://pastebin.com/LrnCBk3H
Vector2D Class: http://pastebin.com/ExE4XPWY
VectorUtils Class: http://pastebin.com/6W9qntDn


Ah, well, I didn’t test it, but you do have one small bug. Say you do Math.floor(-9.7). Your code would return -9 instead of -10. Same thing could happen for ceil I think. You also don’t have to explicitly cast your results to Number. I’m not sure what the performance impact of that is though.

Yes; your floor and ciel functions are bugged. If you already know you’re dealing wiht positive numbers however, I would simply inline int() instead of writing out FastMath.floor()

 
Flag Post
Originally posted by qwerber:
Originally posted by BobTheCoolGuy:
Originally posted by RTL_Shadow:
Originally posted by BobTheCoolGuy:

RTL, I’m curious as qwerber is. A lot of performance increase in math stuff does come from avoiding a function call (luckily we’ll have inlining in ASC 2.0) Post your FastMath class and performance test maybe?


Also, this:

Originally posted by DrYoshiyahu:

I was really upset when I wasn’t allowed to get the star. :(


I could very well be wrong, but when I did the whole getTimer trick it all added up.

FastMath Class: http://pastebin.com/LrnCBk3H
Vector2D Class: http://pastebin.com/ExE4XPWY
VectorUtils Class: http://pastebin.com/6W9qntDn


Ah, well, I didn’t test it, but you do have one small bug. Say you do Math.floor(-9.7). Your code would return -9 instead of -10. Same thing could happen for ceil I think. You also don’t have to explicitly cast your results to Number. I’m not sure what the performance impact of that is though.


Yes; your floor and ciel functions are bugged. If you already know you’re dealing wiht positive numbers however, I would simply inline int() instead of writing out FastMath.floor()


Yeah- I’ve removed the two functions. Thanks guys. I’ll probably make the sun rays a bit more effecient and document them, then I’ll release them out on github.

As of now UG has helped me set up my GitHub with my FlashUtils here

Feel free to suggest things or point out bugs. Free use too!

 
Flag Post

For your radians and degree functions, you should calculate the conversion value and just manually enter the value by hand in the actual function, instead of using a constant.

 
Flag Post

I disagree; multiplying by a constant is much faster than calling a function (essentially it’s inlining the function). You should, however, actually label them with const so that the compiler folds the division. Or you can precalculate; I prefer seeing Math.PI/180 vs. 0.017453292519943295, though.

 
Flag Post
Originally posted by BigJM:

I disagree; multiplying by a constant is much faster than calling a function (essentially it’s inlining the function). You should, however, actually label them with const so that the compiler folds the division. Or you can precalculate; I prefer seeing Math.PI/180 vs. 0.017453292519943295, though.

I don’t think you actually disagree. :D My very confusingly worded statement just meant that this would be better than what he has now:

public static function toRadians( deg:Number ):Number
{
     return deg * 0.017453292519943295;
}
 
Flag Post

No, I do disagree :P I wouldn’t have a toRadians function at all.

 
Flag Post

i dont even use degeree; my engine entirely uses radians.