Skip to content

Commit

Permalink
Addition to solitaire writeup.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfitzp committed Feb 19, 2018
1 parent 7ca39a4 commit a54970a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions solitaire/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@ a parent-child relationship, allowing multiple cards to be dragged at once.

### The end animation

The end-game was a bit weird to implement. Since it happens 'outside' of
game time the first thought was to have a self contained loop, using
`QApplication.processEvents` to tick over. But that's nasty.

Instead I used a timer, idle during play, which constantly pings an
animation step-forward endpoint. This moves cards (faking 'gravity', bouncing)
The end-game was a bit weird to implement. Since it is self-contained
and happens 'outside' of game time the first thought was to have a
separate fake event loop, hitting `QApplication.processEvents` to
tick over. But that's nasty.

Instead the animation is handled by a QTimer, normally idle during play,
which once triggered repeatedly pings an
animation step-forward slot. This moves cards (faking 'gravity', bouncing)
as well as re-stacking them once they're out of the play area.
Restacking uses the normal stacking code.

The final step was to block event handling, otherwise the cards could
still be grabbed while they bounced (and dropped). The easiest way to
achieve this was to simply place an event-capturing object over the entire
window.
Restacking uses the normal stacking code so they can pile up.
The final piece of the puzzle was to block user interaction, otherwise
the cards could still be grabbed and dropped they bounced.
The easiest way to achieve this is to place an object over the entire
window which is set to capture (and discard) all mouse clicks.

## Other licenses

Expand Down

0 comments on commit a54970a

Please sign in to comment.