Rotating Particle (Flamethrower) Tower Spawn Acceleration

Right, in my Java2d TD Game I have set on making a tower that has 3 barrels which spin around and, using my particle engine, spew out fire particles at the direction the barrels are pointing. I have no trouble with the rotation, and I can set the acceleration vector by saying particle.setAcc(X, Y). If the Y value is positive, the particle will go down by that many pixels per tick. Negative, opposite. Same thing for X, just on the X axis. My only problem is if I have the rotation method going like this:


				if (rotateT >= rotateS) {
					rotation++;
					rotateT = 0;
				} else {
					rotateT++;
				}

and my method for spawning in particles is this:


				Screen.addOverParticle(X, Y, velocityx, velocityy, size, amount, life, image);

how would I get it so it the spawning of the particles spins around in a circle as if a flamethrower is turning around in a continuous circle, firing. I have a few ideas, but I think it will be very CPU intensive the ways I am thinking. Thanks -cMp


float ang = (float)Math.toRadians(rotation);
velocityx = (float)Math.cos(ang) * speed; 
velocityy = (float)Math.sin(ang) * speed;

I get an interesting effect with this. The particles spawn like a box and the width gets bigger than smaller while the height gets smaller than bigger in an indirect variation, if you will. Not the effect I was looking for and still am :wink: but a nice oneā€¦

If you get a box it is because you are using different speeds for x and y.

If you want it so it looks like someone with a water hose spinning in a circle with flames instead of water, then what relminator said is right. You might be doing something different in your particle system.

Here is how my emitters do this


float temp = angle2 - angle1; 
			
			float newAngle = (float) (((Rnd.randomPlus(temp))+angle1) * Math.PI/180);
			newAngle *= -1;
			if(randomV)
			{
				float v = Rnd.randomPlus(vel);
				x.setVel((float)(v*FastMath.cos(newAngle)),(float) (v*FastMath.sin(newAngle)));
			}
			else
			{
				x.setVel((float)(vel*FastMath.cos(newAngle)),(float) (vel*FastMath.sin(newAngle)));
			}

Note in this I have extra options like random vel and emitting particles between 2 angles but the key is the x.setVel

Ok I see now! Works like a charm, thank you very much :slight_smile: