views:

411

answers:

2

What's a good algorithm for "bouncing cards" like the ones you see in solitaire games?

What's the coolest card animation you've seen?

Edit - Any besides the Windows game?

+4  A: 

The x-axis velocity is constant. The y-velocity is incremented by some value every frame. Each frame, the current x and y positions are incremented by the respective velocities. If the card would end up below the window, y-velocity is multiplied by something like -0.9. (negative number > -1) This produces the series of descending bounces.

recursive
but theres some "gravity" or else it would not slow down
DFectuoso
IIRC, the Solitaire animation displays the card in all the positions along it's path, so you'd have to modify this algorithm to remember all the places it has been and draw them appropriately. Or just don't clear the framebuffer between frames (which I suspect is what the original solitaire did)
rmeador
Gravity: The y-velocity is incremented by some value every frame.
recursive
gravity is the y-velocity being incremented each frame. the part that makes it slow down is the -0.9 multiplier, which introduces a 10% loss in vertical velocity each time the card bounces.
Sparr
+2  A: 
Charlie Martin