Location based on rotation

BlitzMax Forums/BlitzMax Programming/Location based on rotation

Yahfree(Posted 2008) [#1]
Hey guys, math question here...


I'm trying to make it so when the player has his accelerate button down, the spaceship will emit fire particles.

The below code is what I use to generate the particles, x is the spaceships center x point, and the y is the spaceships center y point. (The image was mid handled)

		If burning
			EmitParticle(x,y,firepart,10)
		End If


As expected, it generates a stream of fire particles from the center point of the ship. And the ship rotates (it's an astroid clone)

So the problem is:

I want the particles to be on the back of the image( where the engine is ) and to do this would mean some trig math that I'm trying to figure out.

Any help appriciated!

PS. here is the player's ship image(20x20):



The vertice of the concave section of that polygon is where I need the particles to come from


GfK(Posted 2008) [#2]
particleX = Cos(rotationAngle-90) * -5 + shipX
particleY = Sin(rotationAngle-90) * -5 + shipY


You need the -90 because 0 degrees would usually be to the right, rather than straight up.

The -5 is my estimate of the distance from the centre to the 'particle emitter' of the ship. So you might need to tweak that value slightly.


Yahfree(Posted 2008) [#3]
Thanks GFK, just what I was looking for.