Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to make a particle explosion, after something gets destroyed, but somehow only one line of mixed colors show up on the screen.

Here's the header:
http://pastebin.com/JW5bPLj2
Here's the source:
http://pastebin.com/KHmFqytD

I don't get what's wrong, as it's nearly the same as in "Programming Linux Games"

Can somebody help me fix that?

PS: "Uint32 delta" is needed to update the pixels based on time. PSS: Maybe I should add that it's programmed in C and includes SDL.

EDIT: Found the problem. It was the "drawParticles" function.
The problem was, that I passed a double to "offset" (as particles[i].x, etc are all doubles). So I ended up with values like ~MAX_INT because I didn't cast the doubles properly to ints.

share|improve this question
Is the particle.angle getting set correctly? – thedaian Sep 1 '11 at 18:44
@thedaian: yes it is – cr33p Sep 1 '11 at 19:03
Which direction is the line heading? – John McDonald Sep 1 '11 at 19:26
3  
Your paste links don't resolve any longer, could you edit the question to include the actual source? Also, you should post your solution as an answer and accept it. Both of these make this question far more useful for posterity. – Josh Petrie Oct 31 '11 at 22:25

closed as too localized by Tetrad Nov 30 '11 at 23:26

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

particle.angle = rand() % 360;

if think that you get a line because angle is always in [0..1] range

if rand() returns a value in [0..1] range, then should be

particle.angle = rand() * 360;
share|improve this answer
it's programmed in C and "rand()" returns an integer between 0 and RAND_MAX. I don't think that's the problem, as I even tested it in the "updateParticles" function. – cr33p Sep 1 '11 at 19:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.