Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - peacemaker

Pages: [1]
1
Graphics / Animating a sprite between 2 points
« on: January 10, 2012, 05:33:02 pm »
Hey texus,

Thanks for that - it was along the lines I was thinking but I have had a look around online and read about various 2d vector translations, working out the angle between the two points and so on and assumed there was a "better" solution.

However, if simply updating the sprites x and y in the manner you suggested works then I don't see why I'd need to worry about the other stuff :)

2
Graphics / Animating a sprite between 2 points
« on: January 10, 2012, 05:03:18 pm »
Hey guys,

I understand the basics of it, you step the sprite by offset*elapsed frame time per frame in the update loop until it reaches the destination.

But I think I'm missing some (I admit elementary) math when it comes to something like moving the sprite diagonally for example, imagine a wizard casts a spell at a monster.  The wizard is at (X:100,Y:100) and the monster is at (X:500, Y:10).

My current code in this example would increase X and decrease Y for each step but what happens is Y gets to the destination before X so you have a very strange looking effect where the spell travels diagonally until it is at the correct height then it goes horizontally until it reaches the destination.

So what am I missing?  I feel like that is some simple math which can calculate the steps better :)

Pages: [1]