i have been working on a particle system for a while now, but its just not coming together the way i need it too. i am at my wits end with it. the main prblem i have is that my spread doesnt spread at all, it lingers trailing behind the object its attached to.
heres how i start it
p->SetDirection ( Vector2D_Rotate(direction,DegreesToRadians(float(rand() % int(Spreadrate)))));
pos.fX =(float) m_vStartPosX;
pos.fY =(float) m_vStartPosY;
and its update
m_vPosition.fX += Direction.fX * m_vVelocity.fX * dt;
m_vPosition.fY += Direction.fY * m_vVelocity.fY * dt;
any help would be much appreciated
creating Particle system. problem with the spread
2 replies to this topic
Crossbones+ - Reputation: 6812
Posted 17 June 2012 - 08:23 AM
- When using rand() like that, you should actually do it like: static_cast<float>(rand()) / static_cast<float>(RAND_MAX + 1.0f) * Spreadrate. See this on why.
- There isn't anything obvious from this... You're sure that DegreesToRadians() and Vector2D_Rotate() work properly and are returning the correct values? Step through it with a debugger and find out what these functions are receiving as parameters and what they're returning, and make sure they're correct. Make sure your randomness is working correctly.
- Are you initializing the random library properly? You have to call srand() once (and only once) in your program before you can start calling rand().
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]