ID:171378
Oct 3 2004, 11:45 am
|
|
Okay people i need to know can someone give me the EASIEST code for round explosions?(like the ones in MJ when a pet dies or in SG2)Ive been stuck on this for a while. Someone plz help?
|
Copyright © 2025 BYOND Software.
All rights reserved.
Easiest code:
If you want to do more with those turfs than just a visual effect, consult AbyssDragon.BasicMath.
[edit]
To explain better what's going on here, I'll add some details. A circle would be defined by (x-h)2 + (y-k)2 <= r2, where (h,k) are the coordinates of the center and r is the radius. That's where the var rsq comes in: r squared. However, if you stick with strictly r2, you'll find that only the very tips reach exactly that far, but just a little to the right or left you'll be outside that range, like this:
That doesn't look very round. The solution is to use a fudge factor, and treat r as if it's larger than it is. So instead of, in this example, r=3, we'll pretend it's 3.5. (r+0.5)2 = r2 + r + 0.25. We don't have to worry about the 0.25, since dx and dy are always whole numbers. So, for our purposes a fudged rsq of (r+0.5)2 is equivalent to r2 + r, or r(r+1). Using this in place of r2 gives the circle a more rounded appearance.
Lummox JR