Lerp Derp.
Here’s a quick video showing Sweepy Cleaner gameplay. We’ve only got one more week until the deadline and I need to finish the final level and add a ‘how to play’ section. Should manage it.
The final boss fight involves shooting dust you have collected back at the enemy. It took me a while to find out how to do this, but thanks to my friend Lewis I’ve learned how to use Lerp :)
I tried using the seek methods I had used for the main menu cleaner that rolls around the screen. However I could not find a way to extend the vector the dust travels along out the screen when you tap to shoot.
Lerp in XNA performs a linear interpolation between two vectors. Basically, given two points it can create a line between them where you can retrieve any coordinate on that line, and beyond!
x and y could be any position on the line.
So in XNA, you can use it like this:
position = Vector2.Lerp(start point, end point, amount);
amount += 0.05f;
The amount is like a percentage complete value, a float between 0 and 1 of how far between the two points you want to know. If we make this a variable and increase it on each step it makes your object move in a line to the end position. The end point could be a touch screen location if your on a WP7. The ‘amount’ value can also go above 1 so you can keep going for as long as you want past the end position in a linear direction.