': Clock Patience (extra animations) by QWERKEY 2019-01-30 (updated 2019-03-16)
': Version with card pick-up and placement animation
': Images from pngimg.com, all-free-download.com, openclipart.org
': This program uses
': InForm - GUI library for QB64 - Beta version 8
': Fellippe Heitor, 2016-2018 - fellippe@qb64.org - @fellippeheitor
': https://github.com/FellippeHeitor/InForm
'-----------------------------------------------------------
': Controls' IDs: ------------------------------------------------------------------
CONST Offset%%
= 7, Pi!
= 3.141592, Hours!
= -Pi!
/ 6, ZOffset!
= -398, XImage%
= 182, YImage%
= 252 CONST Halfwidth%%
= 50, Halfheight%%
= Halfwidth%%
* YImage%
/ XImage%
, Radius%
= 320, Tucked%%
= 7 DIM SHARED CardsImg&
(51), Obverse&
, RedHighlight&
, GreenHighlight&
, GameOver&
, GameWon&
, XM%
, YM%
DIM SHARED PickedUp%%
, PickedHour%%
, PickedCard%%
, CanPutDown%%
, Orient!
, Orient0!
, OldHour%%
DIM SHARED Anime1%%
, Anime2%%
, DoPickUp%%
, TurnOver%%
, GreenValid%%
, RedValid%%
, Cards%%
(51) DIM SHARED DoPatience%%
, Stock%%
, IsComplete%%
, GotOut%%
, Positions!
(4, 12, 1, 4), Phi!
(12)
': External modules: ---------------------------------------------------------------
'$INCLUDE:'InForm.ui'
'$INCLUDE:'xp.uitheme'
'$INCLUDE:'Clock Patience.frm'
'$RESIZE:SMOOTH
': Event procedures: ---------------------------------------------------------------
DoPatience%% = False
Anime1%% = 31
Anime2%% = 43
'Set Data
Phi!(N%%) = N%% * Hours!
Phi!(N%%) = (N%% - 12) * Hours!
Positions!(S%%, 0, 0, 4) = 0
Positions!(S%%, 0, 1, 4) = Radius% - Tucked%% * S%%
Positions!(S%%, 0, 0, 3) = Positions!(S%%, 0, 0, 4) + Halfwidth%%
Positions!(S%%, 0, 1, 3) = Positions!(S%%, 0, 1, 4) - Halfheight%%
Positions!(S%%, 0, 0, 2) = Positions!(S%%, 0, 0, 4) - Halfwidth%%
Positions!(S%%, 0, 1, 2) = Positions!(S%%, 0, 1, 4) - Halfheight%%
Positions!(S%%, 0, 0, 1) = Positions!(S%%, 0, 0, 4) + Halfwidth%%
Positions!(S%%, 0, 1, 1) = Positions!(S%%, 0, 1, 4) + Halfheight%%
Positions!(S%%, 0, 0, 0) = Positions!(S%%, 0, 0, 4) - Halfwidth%%
Positions!(S%%, 0, 1, 0) = Positions!(S%%, 0, 1, 4) + Halfheight%%
CALL Angle
((Positions!
(S%%
, 0, 0, M%%
)), (Positions!
(S%%
, 0, 1, M%%
)), Positions!
(S%%
, N%%
, 0, M%%
), Positions!
(S%%
, N%%
, 1, M%%
), (Phi!
(N%%
))) Positions!(S%%, 12, 0, 0) = Tucked%% * (3 - S%%) - Halfwidth%%
Positions!(S%%, 12, 1, 0) = Halfheight%%
Positions!(S%%, 12, 0, 1) = Positions!(S%%, 12, 0, 0) + 2 * Halfwidth%%
Positions!(S%%, 12, 1, 1) = Halfheight%%
Positions!(S%%, 12, 0, 2) = Tucked%% * (3 - S%%) - Halfwidth%%
Positions!(S%%, 12, 1, 2) = -Halfheight%%
Positions!(S%%, 12, 0, 3) = Positions!(S%%, 12, 0, 2) + 2 * Halfwidth%%
Positions!(S%%, 12, 1, 3) = -Halfheight%%
Positions!(S%%, 12, 0, 4) = Tucked%% * (3 - S%%)
Positions!(S%%, 12, 1, 4) = 0
'Images
playingcards&
= _LOADIMAGE("pack of cards.png", 32) R1%% = N%% \ 13
R2%% = R1%% \ 2
R3%% = C1%% \ 5
_PUTIMAGE (XImage%
- 33, YImage%
- 33), Corner&
LINE (16, 0)-(XImage%
- 17, YImage%
- 1), , BF
LINE (0, 16)-(XImage%
- 1, YImage%
- 17), , BF
LINE (16, 0)-(XImage%
- 17, 0), _RGB32(204, 119, 34) LINE (16, YImage%
- 1)-(XImage%
- 17, YImage%
- 1), _RGB32(204, 119, 34) LINE (0, 16)-(0, YImage%
- 17), _RGB32(204, 119, 34) LINE (XImage%
- 1, 16)-(XImage%
- 1, YImage%
- 17), _RGB32(204, 119, 34) X1! = 7 + 203 * C3%% + 996 * C2%%
X2! = 167 + X1!
Y1! = 13 + 267 * R3%% + 786 * R2%%
Y2! = Y1! + 222
_PUTIMAGE (6, 14)-(XImage%
- 7, YImage%
- 15), playingcards&
, , (7 + 203 * C3%%
+ 996 * C2%%
, Y1!
)-(X2!
, Y2!
) Q1$ = "PVDQJDX"
_PUTIMAGE (XImage%
- 33, YImage%
- 33), Corner&
LINE (16, 0)-(XImage%
- 17, YImage%
- 1), , BF
LINE (0, 16)-(XImage%
- 1, YImage%
- 17), , BF
LINE (16, 0)-(XImage%
- 17, 0), _RGB32(204, 119, 34) LINE (16, YImage%
- 1)-(XImage%
- 17, YImage%
- 1), _RGB32(204, 119, 34) LINE (0, 16)-(0, YImage%
- 17), _RGB32(204, 119, 34) LINE (XImage%
- 1, 16)-(XImage%
- 1, YImage%
- 17), _RGB32(204, 119, 34) C3%% = 4
C2%% = 0
R3%% = 2
R2%% = 0
X1! = 7 + 203 * C3%% + 996 * C2%%
X2! = 167 + X1!
Y1! = 13 + 267 * R3%% + 786 * R2%%
Y2! = Y1! + 222
_PUTIMAGE (14, 14)-(XImage%
- 15, YImage%
- 15), playingcards&
, , (14 + 203 * C3%%
+ 996 * C2%%
, Y1!
)-(X2!
- 4, Y2!
) Cards%%(N%%) = N%% + 1 'Cards%%() values adjusted to 1 - 13: then value 0 is empty
Caption(NewGameBT) = "Deal"
SetFocus NewGameBT
SUB __UI_BeforeUpdateDisplay
'This event occurs at approximately 30 frames per second.
'You can change the update frequency by calling SetFrameRate DesiredRate%
STATIC Count%
, InitDone%%
, Grandad&
, XStart%
, YStart%
InitDone%% = True
XStart% = -120
YStart% = 0
_MAPTRIANGLE (0, 0)-(80, 0)-(0, 80), GreenHighlight&
TO(Positions!
(4, PickedHour%%
, 0, 4) - 40, Positions!
(4, PickedHour%%
, 1, 4) + 40, ZOffset!
)-(Positions!
(4, PickedHour%%
, 0, 4) + 40, Positions!
(4, PickedHour%%
, 1, 4) + 40, ZOffset!
)-(Positions!
(4, PickedHour%%
, 0, 4) - 40, Positions!
(4, PickedHour%%
, 1, 4) - 40, ZOffset!
) _MAPTRIANGLE (80, 80)-(0, 80)-(80, 0), GreenHighlight&
TO(Positions!
(4, PickedHour%%
, 0, 4) + 40, Positions!
(4, PickedHour%%
, 1, 4) + -40, ZOffset!
)-(Positions!
(4, PickedHour%%
, 0, 4) - 40, Positions!
(4, PickedHour%%
, 1, 4) - 40, ZOffset!
)-(Positions!
(4, PickedHour%%
, 0, 4) + 40, Positions!
(4, PickedHour%%
, 1, 4) + 40, ZOffset!
) _MAPTRIANGLE (0, 0)-(80, 0)-(0, 80), RedHighlight&
TO(Positions!
(4, PickedHour%%
, 0, 4) - 40, Positions!
(4, PickedHour%%
, 1, 4) + 40, ZOffset!
)-(Positions!
(4, PickedHour%%
, 0, 4) + 40, Positions!
(4, PickedHour%%
, 1, 4) + 40, ZOffset!
)-(Positions!
(4, PickedHour%%
, 0, 4) - 40, Positions!
(4, PickedHour%%
, 1, 4) - 40, ZOffset!
) _MAPTRIANGLE (80, 80)-(0, 80)-(80, 0), RedHighlight&
TO(Positions!
(4, PickedHour%%
, 0, 4) + 40, Positions!
(4, PickedHour%%
, 1, 4) + -40, ZOffset!
)-(Positions!
(4, PickedHour%%
, 0, 4) - 40, Positions!
(4, PickedHour%%
, 1, 4) - 40, ZOffset!
)-(Positions!
(4, PickedHour%%
, 0, 4) + 40, Positions!
(4, PickedHour%%
, 1, 4) + 40, ZOffset!
) 'Display turning-over
Xtent! = 2 * Halfwidth%% * (Anime1%% - 15) / 15
X0! = Positions!(4, OldHour%%, 0, 0)
Y0! = Positions!(4, OldHour%%, 1, 0)
Z0!
= 0.7 * SQR((4 * Halfwidth%%
* Halfwidth%%
) - (Xtent!
* Xtent!
)) X1! = Positions!(4, OldHour%%, 0, 0) + Xtent!
Y1! = Positions!(4, OldHour%%, 1, 0)
Z1! = 0
X2! = Positions!(4, OldHour%%, 0, 2)
Y2! = Positions!(4, OldHour%%, 1, 2)
Z2!
= 0.7 * SQR((4 * Halfwidth%%
* Halfwidth%%
) - (Xtent!
* Xtent!
)) X3! = Positions!(4, OldHour%%, 0, 2) + Xtent!
Y3! = Positions!(4, OldHour%%, 1, 2)
Z3! = 0
_MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), CardsImg&
(PickedCard%%
- 1) TO(X0!
, Y0!
, Z0!
+ ZOffset!
)-(X1!
, Y1!
, Z1!
+ ZOffset!
)-(X2!
, Y2!
, Z2!
+ ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), CardsImg&
(PickedCard%%
- 1) TO(X3!
, Y3!
, Z3!
+ ZOffset!
)-(X2!
, Y2!
, Z2!
+ ZOffset!
)-(X1!
, Y1!
, Z1!
+ ZOffset!
) Psi! = Anime1%% * Pi! / (2 * 15)
X0! = Positions!(4, OldHour%%, 0, 0)
Y0! = Positions!(4, OldHour%%, 1, 0)
Z0! = 0
X1!
= X0!
+ 2 * Halfwidth%%
* COS(Psi!
) Y1! = Y0!
Z1!
= 0.7 * 2 * Halfwidth%%
* SIN(Psi!
) X2! = Positions!(4, OldHour%%, 0, 2)
Y2! = Positions!(4, OldHour%%, 1, 2)
Z2! = 0
X3!
= X2!
+ 2 * Halfwidth%%
* COS(Psi!
) Y3! = Y2!
Z3!
= 0.7 * 2 * Halfwidth%%
* SIN(Psi!
) _MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), Obverse&
TO(X0!
, Y0!
, Z0!
+ ZOffset!
)-(X1!
, Y1!
, Z1!
+ ZOffset!
)-(X2!
, Y2!
, Z2!
+ ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), Obverse&
TO(X3!
, Y3!
, Z3!
+ ZOffset!
)-(X2!
, Y2!
, Z2!
+ ZOffset!
)-(X1!
, Y1!
, Z1!
+ ZOffset!
) Xtent! = 2 * Halfwidth%% * (Anime1%% - 15) / 15
XA! = Positions!(4, 0, 0, 0)
YA! = Positions!(4, 0, 1, 0)
Z0!
= 0.7 * SQR((4 * Halfwidth%%
* Halfwidth%%
) - (Xtent!
* Xtent!
)) XB! = Positions!(4, 0, 0, 0) + Xtent!
YB! = Positions!(4, 0, 1, 0)
Z1! = 0
XC! = Positions!(4, 0, 0, 2)
YC! = Positions!(4, 0, 1, 2)
Z2!
= 0.7 * SQR((4 * Halfwidth%%
* Halfwidth%%
) - (Xtent!
* Xtent!
)) XD! = Positions!(4, 0, 0, 2) + Xtent!
YD! = Positions!(4, 0, 1, 2)
Z3! = 0
CALL Angle
((XA!
), (YA!
), X0!
, Y0!
, Orient0!
) CALL Angle
((XB!
), (YB!
), X1!
, Y1!
, Orient0!
) CALL Angle
((XC!
), (YC!
), X2!
, Y2!
, Orient0!
) CALL Angle
((XD!
), (YD!
), X3!
, Y3!
, Orient0!
) _MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), CardsImg&
(PickedCard%%
- 1) TO(X0!
, Y0!
, Z0!
+ ZOffset!
)-(X1!
, Y1!
, Z1!
+ ZOffset!
)-(X2!
, Y2!
, Z2!
+ ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), CardsImg&
(PickedCard%%
- 1) TO(X3!
, Y3!
, Z3!
+ ZOffset!
)-(X2!
, Y2!
, Z2!
+ ZOffset!
)-(X1!
, Y1!
, Z1!
+ ZOffset!
) Psi! = Anime1%% * Pi! / (2 * 15)
XA! = Positions!(4, 0, 0, 0)
YA! = Positions!(4, 0, 1, 0)
Z0! = 0
XB!
= XA!
+ 2 * Halfwidth%%
* COS(Psi!
) YB! = YA!
Z1!
= 0.7 * 2 * Halfwidth%%
* SIN(Psi!
) XC! = Positions!(4, 0, 0, 2)
YC! = Positions!(4, 0, 1, 2)
Z2! = 0
XD!
= XC!
+ 2 * Halfwidth%%
* COS(Psi!
) YD! = YC!
Z3!
= 0.7 * 2 * Halfwidth%%
* SIN(Psi!
) CALL Angle
((XA!
), (YA!
), X0!
, Y0!
, Orient0!
) CALL Angle
((XB!
), (YB!
), X1!
, Y1!
, Orient0!
) CALL Angle
((XC!
), (YC!
), X2!
, Y2!
, Orient0!
) CALL Angle
((XD!
), (YD!
), X3!
, Y3!
, Orient0!
) _MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), Obverse&
TO(X0!
, Y0!
, Z0!
+ ZOffset!
)-(X1!
, Y1!
, Z1!
+ ZOffset!
)-(X2!
, Y2!
, Z2!
+ ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), Obverse&
TO(X3!
, Y3!
, Z3!
+ ZOffset!
)-(X2!
, Y2!
, Z2!
+ ZOffset!
)-(X1!
, Y1!
, Z1!
+ ZOffset!
) Anime1%% = Anime1%% + 1
TurnOver%% = False
Clock%%(PickedHour%%, 4, 0) = PickedCard%%
Clock%%(PickedHour%%, 4, 1) = True 'Temporary until picked up
'Display Tucking-in
'Horizontal for Kings
Xdelta% = Positions!(1, PickedHour%%, 0, 1) - Positions!(4, PickedHour%%, 0, 0) + Tucked%%
X0! = Positions!(4, PickedHour%%, 0, 0) + Xdelta% * (45 - Anime2%%) / 23
Y0! = Positions!(4, PickedHour%%, 1, 0)
X1! = Positions!(4, PickedHour%%, 0, 1) + Xdelta% * (45 - Anime2%%) / 23
Y1! = Positions!(4, PickedHour%%, 1, 1)
X2! = Positions!(4, PickedHour%%, 0, 2) + Xdelta% * (45 - Anime2%%) / 23
Y2! = Positions!(4, PickedHour%%, 1, 2)
X3! = Positions!(4, PickedHour%%, 0, 3) + Xdelta% * (45 - Anime2%%) / 23
Y3! = Positions!(4, PickedHour%%, 1, 3)
Zpos! = -0.5
_MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), CardsImg&
(PickedCard%%
- 1) TO(X0!
, Y0!
, Zpos!
+ ZOffset!
)-(X1!
, Y1!
, Zpos!
+ ZOffset!
)-(X2!
, Y2!
, Zpos!
+ ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), CardsImg&
(PickedCard%%
- 1) TO(X3!
, Y3!
, Zpos!
+ ZOffset!
)-(X2!
, Y2!
, Zpos!
+ ZOffset!
)-(X1!
, Y1!
, Zpos!
+ ZOffset!
) Xdelta% = Positions!(1, PickedHour%%, 0, 1) - Positions!(4, PickedHour%%, 0, 0) + Tucked%%
X0! = Positions!(4, PickedHour%%, 0, 0) + Xdelta% * Anime2%% / 22
Y0! = Positions!(4, PickedHour%%, 1, 0)
X1! = Positions!(4, PickedHour%%, 0, 1) + Xdelta% * Anime2%% / 22
Y1! = Positions!(4, PickedHour%%, 1, 1)
X2! = Positions!(4, PickedHour%%, 0, 2) + Xdelta% * Anime2%% / 22
Y2! = Positions!(4, PickedHour%%, 1, 2)
X3! = Positions!(4, PickedHour%%, 0, 3) + Xdelta% * Anime2%% / 22
Y3! = Positions!(4, PickedHour%%, 1, 3)
Zpos! = 0.5
_MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), CardsImg&
(PickedCard%%
- 1) TO(X0!
, Y0!
, Zpos!
+ ZOffset!
)-(X1!
, Y1!
, Zpos!
+ ZOffset!
)-(X2!
, Y2!
, Zpos!
+ ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), CardsImg&
(PickedCard%%
- 1) TO(X3!
, Y3!
, Zpos!
+ ZOffset!
)-(X2!
, Y2!
, Zpos!
+ ZOffset!
)-(X1!
, Y1!
, Zpos!
+ ZOffset!
) 'Vertical for others
Ydelta% = Positions!(0, 0, 1, 0) - Positions!(4, 0, 1, 2) + Tucked%%
XA! = Positions!(4, 0, 0, 0)
YA! = Positions!(4, 0, 1, 0) + Ydelta% * (45 - Anime2%%) / 23
XB! = Positions!(4, 0, 0, 1)
YB! = Positions!(4, 0, 1, 1) + Ydelta% * (45 - Anime2%%) / 23
XC! = Positions!(4, 0, 0, 2)
YC! = Positions!(4, 0, 1, 2) + Ydelta% * (45 - Anime2%%) / 23
XD! = Positions!(4, 0, 0, 3)
YD! = Positions!(4, 0, 1, 3) + Ydelta% * (45 - Anime2%%) / 23
CALL Angle
((XA!
), (YA!
), X0!
, Y0!
, Orient!
) CALL Angle
((XB!
), (YB!
), X1!
, Y1!
, Orient!
) CALL Angle
((XC!
), (YC!
), X2!
, Y2!
, Orient!
) CALL Angle
((XD!
), (YD!
), X3!
, Y3!
, Orient!
) Zpos! = -0.5
_MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), CardsImg&
(PickedCard%%
- 1) TO(X0!
, Y0!
, Zpos!
+ ZOffset!
)-(X1!
, Y1!
, Zpos!
+ ZOffset!
)-(X2!
, Y2!
, Zpos!
+ ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), CardsImg&
(PickedCard%%
- 1) TO(X3!
, Y3!
, Zpos!
+ ZOffset!
)-(X2!
, Y2!
, Zpos!
+ ZOffset!
)-(X1!
, Y1!
, Zpos!
+ ZOffset!
) Ydelta% = Positions!(0, 0, 1, 0) - Positions!(4, 0, 1, 2) + Tucked%%
XA! = Positions!(4, 0, 0, 0)
YA! = Positions!(4, 0, 1, 0) + Ydelta% * Anime2%% / 22
XB! = Positions!(4, 0, 0, 1)
YB! = Positions!(4, 0, 1, 1) + Ydelta% * Anime2%% / 22
XC! = Positions!(4, 0, 0, 2)
YC! = Positions!(4, 0, 1, 2) + Ydelta% * Anime2%% / 22
XD! = Positions!(4, 0, 0, 3)
YD! = Positions!(4, 0, 1, 3) + Ydelta% * Anime2%% / 22
CALL Angle
((XA!
), (YA!
), X0!
, Y0!
, Orient!
) CALL Angle
((XB!
), (YB!
), X1!
, Y1!
, Orient!
) CALL Angle
((XC!
), (YC!
), X2!
, Y2!
, Orient!
) CALL Angle
((XD!
), (YD!
), X3!
, Y3!
, Orient!
) Zpos! = 0.5
_MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), CardsImg&
(PickedCard%%
- 1) TO(X0!
, Y0!
, Zpos!
+ ZOffset!
)-(X1!
, Y1!
, Zpos!
+ ZOffset!
)-(X2!
, Y2!
, Zpos!
+ ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), CardsImg&
(PickedCard%%
- 1) TO(X3!
, Y3!
, Zpos!
+ ZOffset!
)-(X2!
, Y2!
, Zpos!
+ ZOffset!
)-(X1!
, Y1!
, Zpos!
+ ZOffset!
) Anime2%% = Anime2%% + 1
IF Anime2%%
= 43 THEN CanPutDown%%
= True
'Display picked-up card
IF __UI_MouseLeft
> 680 AND __UI_MouseTop
> 738 THEN 'Do Nothing
CALL Angle
(-Halfwidth%%
, Halfheight%
, X0!
, Y0!
, Orient!
) CALL Angle
(Halfwidth%%
, Halfheight%
, X1!
, Y1!
, Orient!
) CALL Angle
(-Halfwidth%%
, -Halfheight%
, X2!
, Y2!
, Orient!
) CALL Angle
(Halfwidth%%
, -Halfheight%
, X3!
, Y3!
, Orient!
) X0! = X0! + XM%
Y0! = Y0! + YM%
X1! = X1! + XM%
Y1! = Y1! + YM%
X2! = X2! + XM%
Y2! = Y2! + YM%
X3! = X3! + XM%
Y3! = Y3! + YM%
_MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), CardsImg&
(PickedCard%%
- 1) TO(X0!
, Y0!
, ZOffset!
)-(X1!
, Y1!
, ZOffset!
)-(X2!
, Y2!
, ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), CardsImg&
(PickedCard%%
- 1) TO(X3!
, Y3!
, ZOffset!
)-(X2!
, Y2!
, ZOffset!
)-(X1!
, Y1!
, ZOffset!
) 'Display Piles
FOR S%%
= 4 TO 0 STEP -1 'Maptriangle order is backwards IF Clock%%
(N%%
, S%%
, 0) <> 0 THEN _MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), CardsImg&
(Clock%%
(N%%
, S%%
, 0) - 1) TO(Positions!
(S%%
, N%%
, 0, 0), Positions!
(S%%
, N%%
, 1, 0), ZOffset!
)-(Positions!
(S%%
, N%%
, 0, 1), Positions!
(S%%
, N%%
, 1, 1), ZOffset!
)-(Positions!
(S%%
, N%%
, 0, 2), Positions!
(S%%
, N%%
, 1, 2), ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), CardsImg&
(Clock%%
(N%%
, S%%
, 0) - 1) TO(Positions!
(S%%
, N%%
, 0, 3), Positions!
(S%%
, N%%
, 1, 3), ZOffset!
)-(Positions!
(S%%
, N%%
, 0, 2), Positions!
(S%%
, N%%
, 1, 2), ZOffset!
)-(Positions!
(S%%
, N%%
, 0, 1), Positions!
(S%%
, N%%
, 1, 1), ZOffset!
) _MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), Obverse&
TO(Positions!
(S%%
, N%%
, 0, 0), Positions!
(S%%
, N%%
, 1, 0), ZOffset!
)-(Positions!
(S%%
, N%%
, 0, 1), Positions!
(S%%
, N%%
, 1, 1), ZOffset!
)-(Positions!
(S%%
, N%%
, 0, 2), Positions!
(S%%
, N%%
, 1, 2), ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), Obverse&
TO(Positions!
(S%%
, N%%
, 0, 3), Positions!
(S%%
, N%%
, 1, 3), ZOffset!
)-(Positions!
(S%%
, N%%
, 0, 2), Positions!
(S%%
, N%%
, 1, 2), ZOffset!
)-(Positions!
(S%%
, N%%
, 0, 1), Positions!
(S%%
, N%%
, 1, 1), ZOffset!
) 'Display Stock
_MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), Obverse&
TO(XStart%
- Halfwidth%%
, YStart%
+ Halfheight%%
, ZOffset!
)-(XStart%
+ Halfwidth%%
, YStart%
+ Halfheight%%
, ZOffset!
)-(XStart%
- Halfwidth%%
, YStart%
- Halfheight%%
, ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), Obverse&
TO(XStart%
+ Halfwidth%%
, YStart%
- Halfheight%%
, ZOffset!
)-(XStart%
- Halfwidth%%
, YStart%
- Halfheight%%
, ZOffset!
)-(XStart%
+ Halfwidth%%
, YStart%
+ Halfheight%%
, ZOffset!
) _MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), Obverse&
TO(XStart%
- Halfwidth%%
, YStart%
+ Halfheight%%
- 1, ZOffset!
)-(XStart%
+ Halfwidth%%
, YStart%
+ Halfheight%%
- 1, ZOffset!
)-(XStart%
- Halfwidth%%
, YStart%
- Halfheight%%
- 1, ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), Obverse&
TO(XStart%
+ Halfwidth%%
, YStart%
- Halfheight%%
- 1, ZOffset!
)-(XStart%
- Halfwidth%%
, YStart%
- Halfheight%%
- 1, ZOffset!
)-(XStart%
+ Halfwidth%%
, YStart%
+ Halfheight%%
- 1, ZOffset!
) _MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), Obverse&
TO(XStart%
- Halfwidth%%
, YStart%
+ Halfheight%%
- 2, ZOffset!
)-(XStart%
+ Halfwidth%%
, YStart%
+ Halfheight%%
- 2, ZOffset!
)-(XStart%
- Halfwidth%%
, YStart%
- Halfheight%%
- 2, ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), Obverse&
TO(XStart%
+ Halfwidth%%
, YStart%
- Halfheight%%
- 2, ZOffset!
)-(XStart%
- Halfwidth%%
, YStart%
- Halfheight%%
- 2, ZOffset!
)-(XStart%
+ Halfwidth%%
, YStart%
+ Halfheight%%
- 2, ZOffset!
) _MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), Obverse&
TO(XStart%
- Halfwidth%%
, YStart%
+ Halfheight%%
- 3, ZOffset!
)-(XStart%
+ Halfwidth%%
, YStart%
+ Halfheight%%
- 3, ZOffset!
)-(XStart%
- Halfwidth%%
, YStart%
- Halfheight%%
- 3, ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), Obverse&
TO(XStart%
+ Halfwidth%%
, YStart%
- Halfheight%%
- 3, ZOffset!
)-(XStart%
- Halfwidth%%
, YStart%
- Halfheight%%
- 3, ZOffset!
)-(XStart%
+ Halfwidth%%
, YStart%
+ Halfheight%%
- 3, ZOffset!
) _MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), Obverse&
TO(XStart%
- Halfwidth%%
, YStart%
+ Halfheight%%
- 4, ZOffset!
)-(XStart%
+ Halfwidth%%
, YStart%
+ Halfheight%%
- 4, ZOffset!
)-(XStart%
- Halfwidth%%
, YStart%
- Halfheight%%
- 4, ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), Obverse&
TO(XStart%
+ Halfwidth%%
, YStart%
- Halfheight%%
- 4, ZOffset!
)-(XStart%
- Halfwidth%%
, YStart%
- Halfheight%%
- 4, ZOffset!
)-(XStart%
+ Halfwidth%%
, YStart%
+ Halfheight%%
- 4, ZOffset!
) 'Display dealt card
S%% = (52 - Stock%%) \ 13
N%%
= (52 - Stock%%
) MOD 13 Count% = Count% + 1
Zpos!
= 50 * SIN(Pi!
* Count%
/ 15) ActualAngle! = Phi!(N%%) * Count% / 15
XPos! = XStart% + (Positions!(S%%, N%%, 0, 4) - XStart%) * Count% / 15
YPos! = YStart% + (Positions!(S%%, N%%, 1, 4) - YStart%) * Count% / 15
CALL Angle
((-Halfwidth%%
), (Halfheight%%
), X0!
, Y0!
, (ActualAngle!
)) CALL Angle
((Halfwidth%%
), (Halfheight%%
), X1!
, Y1!
, (ActualAngle!
)) CALL Angle
((-Halfwidth%%
), (-Halfheight%%
), X2!
, Y2!
, (ActualAngle!
)) CALL Angle
((Halfwidth%%
), (-Halfheight%%
), X3!
, Y3!
, (ActualAngle!
)) X0! = XPos! + X0!
Y0! = YPos! + Y0!
X1! = XPos! + X1!
Y1! = YPos! + Y1!
X2! = XPos! + X2!
Y2! = YPos! + Y2!
X3! = XPos! + X3!
Y3! = YPos! + Y3!
_MAPTRIANGLE (0, 0)-(XImage%
- 1, 0)-(0, YImage%
- 1), Obverse&
TO(X0!
, Y0!
, Zpos!
+ ZOffset!
)-(X1!
, Y1!
, Zpos!
+ ZOffset!
)-(X2!
, Y2!
, Zpos!
+ ZOffset!
) _MAPTRIANGLE (XImage%
- 1, YImage%
- 1)-(0, YImage%
- 1)-(XImage%
- 1, 0), Obverse&
TO(X3!
, Y3!
, Zpos!
+ ZOffset!
)-(X2!
, Y2!
, Zpos!
+ ZOffset!
)-(X1!
, Y1!
, Zpos!
+ ZOffset!
) Count% = 0
Clock%%
((52 - Stock%%
) MOD 13, 1 + ((52 - Stock%%
) \
13), 0) = Clock%%
((52 - Stock%%
) MOD 13, 1 + ((52 - Stock%%
) \
13), 2) Stock%% = Stock%% - 1
'If you set __UI_UnloadSignal = False here you can
'cancel the user's request to close.
DoPickUp%% = True
Anime2%% = 0
Control(NewGameBT).Disabled = True
Control(NewGameBT).Hidden = True
Caption(NewGameBT) = "New Game"
SetFocus ExitBT
DoPatience%% = False
Caption(NewGameBT) = "Deal"
'This event occurs right before a control loses focus.
'To prevent a control from losing focus, set __UI_KeepFocus = True below.
'When this event is fired, __UI_KeyHit will contain the code of the key hit.
'You can change it and even cancel it by making it = 0
SUB Angle
(Xin!
, Yin!
, Xout!
, Yout!
, Theta!
) Xout!
= Xin!
* COS(Theta!
) - Yin!
* SIN(Theta!
) Yout!
= Xin!
* SIN(Theta!
) + Yin!
* COS(Theta!
)
BadDeal%% = True
'Deal Sim
S%% = N%% \ 13
Clock%%(R%%, S%% + 1, 2) = Cards%%(N%%)
BadDeal%% = False
FOR M%%
= 0 TO 12 'Cards are in S 1 to 4 IF Clock%%
(M%%
, 1, 2) MOD 13 = Clock%%
(M%%
, 2, 2) MOD 13 AND Clock%%
(M%%
, 1, 2) MOD 13 = Clock%%
(M%%
, 3, 2) MOD 13 AND Clock%%
(M%%
, 1, 2) MOD 13 = Clock%%
(M%%
, 4, 2) MOD 13 THEN BadDeal%%
= True
Stock%% = 52
Anime1%% = 31
Anime2%% = 43
TurnOver%% = True
DoPickUp%% = False
PickedUp%% = False
PickedCard%% = 0
PickedHour%% = 12
CanPutDown%% = False
IsComplete%% = False
DoPatience%% = True
HangOn%% = True
HangStop%% = 50
HCount%% = 0
GreenValid%% = False
RedValid%% = False
HCount%% = HCount%% + 1
HangOn%% = False
HCount%% = 0
HangStop%% = 20
'In _MAPTRIANGLE3D, all distances relative to centre of screen
XM%
= __UI_MouseLeft
- _WIDTH / 2 Orient0! = Phi!(PickedHour%%) 'Start orientation is from where the card is taken
PickedCard%% = Clock%%(PickedHour%%, 4, 0) 'From 1 to 52
Clock%%(PickedHour%%, 4, 0) = 0
OldHour%% = PickedHour%%
Anime1%% = 0
IF SQR((Positions!
(4, PickedHour%%
, 0, 4) - XM%
) * (Positions!
(4, PickedHour%%
, 0, 4) - XM%
) + (Positions!
(4, PickedHour%%
, 1, 4) - YM%
) * (Positions!
(4, PickedHour%%
, 1, 4) - YM%
)) < 40 THEN GreenValid%%
= True
Clock%%(PickedHour%%, R%%, 0) = Clock%%(PickedHour%%, R%% - 1, 0)
Clock%%(PickedHour%%, R%%, 1) = Clock%%(PickedHour%%, R%% - 1, 1)
Clock%%(PickedHour%%, 1, 0) = 0
Clock%%(PickedHour%%, R%%, 0) = Clock%%(PickedHour%%, R%% - 1, 0)
Clock%%(PickedHour%%, R%%, 1) = Clock%%(PickedHour%%, R%% - 1, 1)
Clock%%(PickedHour%%, 0, 0) = 0
PickedHour%%
= PickedCard%%
MOD 13 PickedHour%% = 12
PickedHour%% = 0
Orient1! = Phi!(PickedHour%%)
PickedUp%% = True
DoPickUp%% = False
IF SQR((Positions!
(4, PickedHour%%
, 0, 4) - XM%
) * (Positions!
(4, PickedHour%%
, 0, 4) - XM%
) + (Positions!
(4, PickedHour%%
, 1, 4) - YM%
) * (Positions!
(4, PickedHour%%
, 1, 4) - YM%
)) < 40 THEN Orient! = Orient1!
ELSEIF SQR((Positions!
(4, OldHour%%
, 0, 4) - XM%
) * (Positions!
(4, OldHour%%
, 0, 4) - XM%
) + (Positions!
(4, OldHour%%
, 1, 4) - YM%
) * (Positions!
(4, OldHour%%
, 1, 4) - YM%
)) < 40 THEN Orient! = Orient0!
Orient! = 0
CanPutDown%% = False
PickedUp%% = False
HangOn%% = True
Clock%%(PickedHour%%, 1, 0) = PickedCard%%
Clock%%(PickedHour%%, 1, 1) = True
Clock%%(PickedHour%%, 0, 0) = PickedCard%%
Clock%%(PickedHour%%, 0, 1) = True
PickedCard%% = 0
IF Clock%%
(12, 4, 1) AND Clock%%
(12, 1, 0) <> 0 THEN 'Game Finished IsComplete%% = True
Control(NewGameBT).Disabled = False
Control(NewGameBT).Hidden = False
SetFocus NewGameBT
GotOut%% = True
M%% = 0
IF NOT Clock%%
(M%%
, 4, 1) THEN GotOut%%
= False
M%% = M%% + 1
__UI_DoEvents
SUB Shuffle
(Pack%%
()) 'Fisher Yates or Knuth shuffle SWAP Pack%%
(R%%
), Pack%%
(S%%
)