So, this is one I've been wondering.
You have a block with an enemy that orbits it. I was hoping the radius it is from the block could be variable. The main thing is figuring out just how to re-calculate its positions to provide that circular motion.
It'd seem to me that it would have some set distance from the mid point and then just do a new angle as it goes along and then one would need to use sin/cos in some way to do the new X/Y positions.
Any thoughts? Thanks.
2-D enemy that orbits a block with variable radii
Hi, when you say "orbit", do you mean in a strict physical manner, as a satellite orbiting the earth? Will the enemy be orbiting the block due to gravitational interaction?
cheers,
Mike
cheers,
Mike
I'm not sure what behaviour you are looking for, but calculating the position of the enemy around the block for circular motion is fairly easy:
Starting with an angle of 0 radians your ship would appear on the right side of the block, increasing the angle over time will make your ship move counter clockwise in circular motion around the block.
shipPosition.x = blockPosition.x + cos(angle)*radiusshipPosition.y = blockPosition.y + sin(angle)*radius
Starting with an angle of 0 radians your ship would appear on the right side of the block, increasing the angle over time will make your ship move counter clockwise in circular motion around the block.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement