Applications: Some more marble fun!
Posted
by TechTwaddle
on Geeks with Blogs
See other posts from Geeks with Blogs
or by TechTwaddle
Published on Thu, 06 May 2010 11:24:24 GMT
Indexed on
2010/05/11
2:55 UTC
Read the original article
Hit count: 296
Well, yesterday night I was watching a tutorial on XNA when I came across this neat little trick. It was a simple XNA application with a Windows Phone logo in it and whenever the user clicked on the device the logo would move towards the click point, and I couldn't resist experimenting with the marble (;
The code is written in C# using CF3.5. Here is a video of the demo,
You probably noticed that the motion of the marble towards the click point (destination) is not linear. The marble starts off with a high velocity and slows down as it reaches its destination. This is achieved by making the speed of the marble a function of the distance between marble's current position and the destination, so as the marble approaches the destination point, the distance between them reduces and so does the speed, until it becomes zero.
More on the code and the logic behind it in the next post. What I'd like to do next is, instead of making the marble stop at the click point, it should continue to move beyond it, bounce around the screen a few times and eventually come to a stop after a while. Let's see how that goes.
© Geeks with Blogs or respective owner