Thanks, I actually just needed to be able to make things go in a straight line from each other. This program was just an experiment so I could work on that. I went ahead and spruced up the sprites to make it more fun though.
I made the sprites smaller and added a grid so you can calculate the slope more easily.
I tried using the idea of the equation of a line as you drag the second sprite (the one with the smiley face when pressed). I was constantly adjusting the y position of the smiley face sprite to stick to the line that the two sprites are on. The problem was that when the slope was very large, I got a lot of eratic behavior. So instead I calculated the standard angle that the line segment makes with the horizontal and used sine and cosine of that angle to calculate the coordinates of the smiley point sprite as you move it.
Comments
You need to be logged in to post comments
Add a Comment
my brain hurts... nice project though =]
I agree. But neat project, I've been looking for a way to do this. I might and up using it (I give you credit).
(view all replies)Thanks, I actually just needed to be able to make things go in a straight line from each other. This program was just an experiment so I could work on that. I went ahead and spruced up the sprites to make it more fun though.