home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / CARDGAME / PFIELDS.BAS < prev    next >
Encoding:
BASIC Source File  |  1992-05-12  |  19.5 KB  |  686 lines

  1. ' Crispy1 (Kings on top, Queens on the side, and Jacks in the corners)
  2. ' A diversion by Chris Pando
  3. ' IF IT IS SQUINKY, THEN YOU KNOW IT IS BrilligWare!
  4. '
  5. ' I dedicate this program to the public domain.
  6. '
  7. DefInt A-Z
  8.  
  9. Declare Function CardVersion Lib "VBCards.dll" () As Integer
  10.  
  11. Declare Sub GetCard Lib "VBCards.dll" (ByVal Card As Integer)
  12. Declare Sub GetCardBack Lib "VBCards.dll" (ByVal C As Integer)
  13. Declare Sub GetCardMisc Lib "VBCards.dll" (ByVal C As Integer)
  14.  
  15. Declare Function SameCardValue Lib "VBCards.dll" (ByVal C1 As Integer, ByVal C2 As Integer) As Integer
  16.  
  17. Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
  18. Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
  19.  
  20.  
  21.  
  22. Const TRUE = -1
  23. Const FALSE = 0
  24. Const PIXEL = 3
  25. Const ROYALMOD = 13
  26. Const KING = 0
  27. Const QUEEN = 12
  28. Const JACK = 11
  29.  
  30. Const KING1 = 1   ' valid squares for face cards
  31. Const KING2 = 2
  32. Const KING3 = 13
  33. Const KING4 = 14
  34. Const QUEEN1 = 4
  35. Const QUEEN2 = 7
  36. Const QUEEN3 = 8
  37. Const QUEEN4 = 11
  38. Const JACK1 = 0
  39. Const JACK2 = 3
  40. Const JACK3 = 12
  41. Const JACK4 = 15
  42.  
  43. Const CENTER1 = 5   'symbolic values for the center squares
  44. Const CENTER2 = 6
  45. Const CENTER3 = 9
  46. Const CENTER4 = 10
  47.  
  48. Const CLOSEDFIELD = 1   ' here are the various states
  49. Const OPENFIELD = 2
  50. Const APENDING = 3
  51. Const CPENDING = 4
  52.  
  53. Dim Deck(1 To 52) As Integer    'Deck contains the deal
  54. Dim Field(15) As Integer        'Field contains the playing field
  55.  
  56.             ' State Variables
  57.  
  58. Dim FromCard As Integer         'Contains Card to Match
  59. Dim NumberOpen As Integer       'open places on field
  60. Dim NextCard As Integer         'Pointer to Deck
  61. Dim State As Integer            'Current State
  62. Dim BackDesign As Integer       'Card Back
  63.  
  64. Sub ShuffleDeck ()
  65.    For i = 1 To 10
  66.       For J = 1 To 52
  67.          K = Int(1 + (52 * Rnd))
  68.          Temp = Deck(J)
  69.          Deck(J) = Deck(K)
  70.          Deck(K) = Temp
  71.       Next
  72.    Next
  73. End Sub
  74.  
  75. Sub DealDeck ()
  76.  
  77.    NextCard = 1
  78.    For i = 0 To 15
  79.       Field(i) = Deck(NextCard)
  80.       NextCard = NextCard + 1
  81.       GetCard (Field(i))
  82.       Pfield.Picture1(i).Picture = ClipBoard.GetData(2)
  83.    Next
  84.  
  85.    GetCardBack (BackDesign)
  86.    Pfield.NewCards.Picture = ClipBoard.GetData(2)
  87.    
  88.    GetCardMisc (1)
  89.    Pfield.OldCards.Picture = ClipBoard.GetData(2)
  90.     
  91.    CtlEnable 2
  92.    NumberOpen = 0
  93.    State = CLOSEDFIELD
  94.  
  95. End Sub
  96.  
  97. Sub AppExit ()
  98.    WriteProfile
  99.    End
  100. End Sub
  101.  
  102. Function RoyalCard (Index As Integer) As Integer
  103.    i = Field(Index) Mod ROYALMOD
  104.    If (i = KING Or i = QUEEN Or i = JACK) Then
  105.       RoyalCard = TRUE
  106.    Else
  107.       RoyalCard = FALSE
  108.    End If
  109. End Function
  110.  
  111. Sub ReverseImage (Source As Control)
  112. ' assumes drawmode and fillcolor,fillstyle have all been set
  113.    Source.Line (0, 0)-(Source.ScaleWidth, Source.ScaleHeight), , B
  114. End Sub
  115.  
  116. Sub OpenOrClosed ()
  117. '
  118. ' if any places are open, the we want OPENFIELD & ENABLED
  119. '
  120.    i = -1
  121.    State = CLOSEDFIELD
  122.    CtlEnable 2              'click2 off, menus on
  123.  
  124.    Do
  125.       i = i + 1
  126.       If Field(i) = -1 Then
  127.          State = OPENFIELD
  128.          CtlEnable 3        'everything enabled
  129.       End If
  130.   Loop Until (i = 15 Or Field(i) = -1)
  131.  
  132. End Sub
  133.  
  134. Sub Remove (Card1 As Integer, Card2 As Integer)
  135.  '
  136.  ' remove the matching cards, and update state varaible NumberOpen
  137.  '
  138.     Pfield.OldCards.Picture = Pfield.Picture1(Card1).Picture
  139.     GetCardMisc (1)
  140.     Pfield.Picture1(Card1).Picture = ClipBoard.GetData(2)
  141.     Pfield.Picture1(Card2).Picture = ClipBoard.GetData(2)
  142.     Field(Card1) = -1
  143.     Field(Card2) = -1
  144.     NumberOpen = NumberOpen + 2
  145. End Sub
  146.  
  147. Function ValidEmpty (Index As Integer) As Integer
  148. ' determine if a valid TO location for a face card
  149.    ValidEmpty = FALSE
  150.    If (Field(Index) = -1) Then
  151.  
  152.       i = Field(FromCard) Mod ROYALMOD
  153.       Select Case i
  154.          Case KING
  155.             If (Index = KING1 Or Index = KING2 Or Index = KING3 Or Index = KING4) Then
  156.                ValidEmpty = TRUE
  157.             End If
  158.          Case QUEEN
  159.             If (Index = QUEEN1 Or Index = QUEEN2 Or Index = QUEEN3 Or Index = QUEEN4) Then
  160.                ValidEmpty = TRUE
  161.             End If
  162.          Case JACK
  163.             If (Index = JACK1 Or Index = JACK2 Or Index = JACK3 Or Index = JACK4) Then
  164.                ValidEmpty = TRUE
  165.             End If
  166.       End Select
  167.  
  168.    End If
  169. End Function
  170.  
  171. Sub Swap (Card1 As Integer, Card2 As Integer)
  172.     Pfield.Picture1(Card2).Picture = Pfield.Picture1(Card1).Picture
  173.     GetCardMisc (1)
  174.     Pfield.Picture1(Card1).Picture = ClipBoard.GetData(2)
  175.     Field(Card2) = Field(Card1)
  176.     Field(Card1) = -1
  177. End Sub
  178.  
  179. Sub LoadCardBack ()
  180.    Load CardBack
  181.  
  182.    CardBack.WindowState = 0
  183.    CardBack.AutoRedraw = TRUE
  184.    CardBack.BackColor = RGB(192, 192, 192)
  185.    CardBack.ScaleMode = PIXEL
  186.  
  187.    For i = 0 To 6
  188.  
  189.    'resize a little bit
  190.       CardBack.CardBackPic(i).Width = 71
  191.       CardBack.CardBackPic(i).Height = 96
  192.  
  193.    'now assign card back
  194.       J = i + 1
  195.       GetCardBack (J)
  196.       CardBack.CardBackPic(i).Picture = ClipBoard.GetData(2)
  197.  
  198.    'now raise card - 4 thick, raised
  199.       RaiseControl CardBack, CardBack.CardBackPic(i), 3, 1
  200.    
  201.    'now set the properties for reverse imaging
  202.       CardBack.CardBackPic(i).FillStyle = 0                   'solid
  203.       CardBack.CardBackPic(i).FillColor = RGB(192, 0, 0)
  204.       CardBack.CardBackPic(i).DrawMode = 10                   'NOT XOR
  205.       CardBack.CardBackPic(i).AutoRedraw = TRUE
  206.    Next i
  207.  
  208.    ReverseImage CardBack.CardBackPic(BackDesign - 1)
  209.    CardBack.Top = 690
  210.    CardBack.Left = 480
  211.    CardBack.Height = 6135
  212.    CardBack.Width = 5055
  213.  
  214.     
  215. ' go ahead and center the command button
  216.    CenterCtlBottom CardBack, CardBack.CardBackOK, 15
  217.  
  218. ' go ahead and frame the form
  219.    FrameForm CardBack
  220.  
  221. ' now lets print something
  222.    CardBack.FontName = "Helv"
  223.    CardBack.FontSize = 24
  224.  
  225.    CardBack.ForeColor = RGB(128, 128, 128)
  226.    CardBack.CurrentX = 40
  227.    CardBack.CurrentY = 20
  228.    CardBack.Print "Pick A Card Back"
  229.  
  230.    CardBack.ForeColor = RGB(128, 128, 128)
  231.    CardBack.CurrentX = 41
  232.    CardBack.CurrentY = 19
  233.    CardBack.Print "Pick A Card Back"
  234.  
  235.    CardBack.ForeColor = RGB(255, 255, 255)
  236.    CardBack.CurrentX = 42
  237.    CardBack.CurrentY = 18
  238.    CardBack.Print "Pick A Card Back"
  239.  
  240.    CardBack.Show 1
  241. End Sub
  242.  
  243. Sub ChangeCardBack (Index As Integer)
  244.     ReverseImage CardBack.CardBackPic(BackDesign - 1)
  245.     ReverseImage CardBack.CardBackPic(Index)
  246.     BackDesign = Index + 1
  247.     If (NextCard <> 53) Then
  248.        Pfield.NewCards.Picture = CardBack.CardBackPic(Index).Picture
  249.     End If
  250. End Sub
  251.  
  252. Sub FrameForm (Source As Form)
  253.    Source.Line (0, 0)-(Source.ScaleWidth - 1, Source.ScaleHeight - 1), RGB(0, 0, 0), B
  254.    Source.Line (1, 1)-(Source.ScaleWidth - 2, Source.ScaleHeight - 2), RGB(255, 255, 255), B
  255.    Source.Line (4, 4)-(Source.ScaleWidth - 5, Source.ScaleHeight - 5), RGB(128, 128, 128), B
  256. End Sub
  257.  
  258. Sub RaiseControl (Source1 As Form, Source2 As Control, Thickness As Integer, TopColor As Integer)
  259. '
  260. ' will draw a border around a control, with actual graphics on the form
  261. ' assuming everthing is done in pixels
  262. '
  263. Dim Color1 As Long
  264. Dim Color2 As Long
  265.  
  266.    x = Source2.Left
  267.    y = Source2.Top
  268.    w = Source2.Width
  269.    h = Source2.Height
  270.  
  271.    If TopColor = 1 Then
  272.       Color1 = RGB(255, 255, 255)
  273.       Color2 = RGB(128, 128, 128)
  274.    Else
  275.       Color1 = RGB(128, 128, 128)
  276.       Color2 = RGB(255, 255, 255)
  277.    End If
  278.  
  279.    For i = 1 To Thickness
  280.       Source1.Line (x - i, y - i)-Step(w + (2 * i - 1), 0), Color1
  281.       Source1.Line -Step(0, h + (2 * i - 1)), Color1
  282.       Source1.Line -Step(-(w + (2 * i - 1)), 0), Color2
  283.       Source1.Line -Step(0, -(h + 2 * i)), Color2
  284.    Next
  285.  
  286.  
  287. End Sub
  288.  
  289. Sub LoadHelp ()
  290.  
  291.    Dim Color1 As Long
  292.    Dim Color2 As Long
  293.     
  294.    Color2 = RGB(255, 255, 255)
  295.    Color1 = RGB(128, 128, 128)
  296.  
  297.    Load Form1
  298.  
  299.    Form1.WindowState = 0
  300.    Form1.AutoRedraw = TRUE
  301.    Form1.BackColor = RGB(192, 192, 192)
  302.   
  303.    Form1.Top = 690
  304.    Form1.Left = 480
  305.    Form1.Height = 6135
  306.    Form1.Width = 5055
  307.  
  308. ' position command button
  309.    CenterCtlBottom Form1, Form1.Command1, 10
  310.  
  311. ' go ahead and frame the form
  312.    FrameForm Form1
  313.  
  314. ' now lets print something
  315.    Form1.FontName = "Helv"
  316.    Form1.FontSize = 24
  317.  
  318.    Form1.ForeColor = Color2
  319.    Form1.CurrentX = 10
  320.    Form1.CurrentY = 10
  321.    Form1.Print "Crispy1 Quick Help"
  322.  
  323.    Form1.ForeColor = Color1
  324.    Form1.CurrentX = 9
  325.    Form1.CurrentY = 9
  326.    Form1.Print "Crispy1 Quick Help"
  327.  
  328.    Form1.ForeColor = Color1
  329.    Form1.CurrentX = 8
  330.    Form1.CurrentY = 8
  331.    Form1.Print "Crispy1 Quick Help"
  332.  
  333. ' now lets print the actual Form1 text
  334.    Form1.FontName = "Helv"
  335.    Form1.FontSize = 9.75
  336.                              
  337.    Print3D Form1, 10, 55, -1, -1, Color1, Color2, "        Kings on Top, Queens on the Side     "
  338.    Print3D Form1, 10, 70, -1, -1, Color1, Color2, "             and Jacks in the Corner         "
  339.    Print3D Form1, 10, 90, -1, -1, Color1, Color2, "The object of the game is to place the face  "
  340.    Print3D Form1, 10, 110, -1, -1, Color1, Color2, "cards on the edges while removing all non-   "
  341.    Print3D Form1, 10, 130, -1, -1, Color1, Color2, "face cards a pair at a time. To remove a     "
  342.    Print3D Form1, 10, 150, -1, -1, Color1, Color2, "pair, click the first card. It will reverse  "
  343.    Print3D Form1, 10, 170, -1, -1, Color1, Color2, "image. Click matching card and the pair will "
  344.    Print3D Form1, 10, 190, -1, -1, Color1, Color2, "be removed. To migrate a face card to the    "
  345.    Print3D Form1, 10, 210, -1, -1, Color1, Color2, "edge, first click the face card, and then the"
  346.    Print3D Form1, 10, 230, -1, -1, Color1, Color2, "eligible edge position to which you wish to  "
  347.    Print3D Form1, 10, 250, -1, -1, Color1, Color2, "move it. (Kings go on top (and bottom),      "
  348.    Print3D Form1, 10, 270, -1, -1, Color1, Color2, "queens go on the sides, and jacks in the cor-"
  349.    Print3D Form1, 10, 290, -1, -1, Color1, Color2, "ner). Click a reverse imaged card to cancel  "
  350.    Print3D Form1, 10, 310, -1, -1, Color1, Color2, "the operation. If the face cards are all in  "
  351.    Print3D Form1, 10, 330, -1, -1, Color1, Color2, "valid edge positions and all other cards have"
  352.    Print3D Form1, 10, 350, -1, -1, Color1, Color2, "been removed, then you have won!.            "
  353.  
  354.   Form1.Show 1
  355. End Sub
  356.  
  357. Sub Print3D (Source As Form, x As Integer, y As Integer, xdir As Integer, ydir As Integer, Color1 As Long, Color2 As Long, PrintMe As String)
  358.    Dim OldColor As Long
  359.    OldColor = Source.ForeColor
  360.  
  361.    Source.ForeColor = Color1
  362.    Source.CurrentX = x
  363.    Source.CurrentY = y
  364.    Source.Print PrintMe
  365.     
  366.    Source.ForeColor = Color2
  367.    Source.CurrentX = x + xdir
  368.    Source.CurrentY = y + ydir
  369.    Source.Print PrintMe
  370.  
  371.    Source.ForeColor = OldColor
  372. End Sub
  373.  
  374. Sub Init ()
  375.    GetProfile
  376.    InitDeck
  377.    ShuffleDeck
  378.    DealDeck
  379. End Sub
  380.  
  381. Sub InitDeck ()
  382. ' randomize, load cards into array, and condition control array
  383.    Randomize
  384.  
  385.    For i = 1 To 52
  386.       Deck(i) = i
  387.    Next i
  388.  
  389.    For i = 0 To 15
  390.       Pfield.Picture1(i).FillStyle = 0                   'solid
  391.       Pfield.Picture1(i).FillColor = RGB(192, 192, 192)  'gray
  392.       Pfield.Picture1(i).DrawMode = 10           ' NOT XOR
  393.       Pfield.Picture1(i).ScaleMode = PIXEL
  394.       Pfield.Picture1(i).ScaleHeight = 96
  395.       Pfield.Picture1(i).ScaleWidth = 71
  396.    Next i
  397. End Sub
  398.  
  399. Sub CtlEnable (SetMe As Integer)
  400. ' 1 = Click2 off, menus off
  401. ' 2 = Click2 off, menus on
  402. ' 3 = Click2 on, menus on
  403.  
  404.    Select Case SetMe
  405.       Case 1
  406.          Pfield.Click2.Enabled = FALSE
  407.          Pfield.CardBacks.Enabled = FALSE
  408.          Pfield.Shelp.Enabled = FALSE
  409.          Pfield.CAbout.Enabled = FALSE
  410.       Case 2
  411.          Pfield.Click2.Enabled = FALSE
  412.          Pfield.CardBacks.Enabled = TRUE
  413.          Pfield.Shelp.Enabled = TRUE
  414.          Pfield.CAbout.Enabled = TRUE
  415.       Case 3
  416.          Pfield.Click2.Enabled = TRUE
  417.          Pfield.CardBacks.Enabled = TRUE
  418.          Pfield.Shelp.Enabled = TRUE
  419.          Pfield.CAbout.Enabled = TRUE
  420.    End Select
  421.  
  422. End Sub
  423.  
  424. Sub LoadAbout ()
  425.    Dim Color1 As Long
  426.    Dim Color2 As Long
  427.  
  428.    Color2 = RGB(255, 255, 255)
  429.    Color1 = RGB(128, 128, 128)
  430.  
  431.    Load Form1
  432.  
  433.    Form1.WindowState = 0
  434.    Form1.AutoRedraw = TRUE
  435.    Form1.ScaleMode = PIXEL
  436.    Form1.BackColor = RGB(192, 192, 192)
  437.   
  438.    Form1.Top = 690
  439.    Form1.Left = 480
  440.    Form1.Height = 6135
  441.    Form1.Width = 5055
  442.  
  443. ' position the command botton
  444.    CenterCtlBottom Form1, Form1.Command1, 10
  445.    
  446. ' go ahead and frame the form
  447.    FrameForm Form1
  448.  
  449. ' now lets print something
  450.    Form1.FontName = "Helv"
  451.    Form1.FontSize = 24
  452.  
  453.    Form1.ForeColor = Color2
  454.    Form1.CurrentX = 85
  455.    Form1.CurrentY = 15
  456.    Form1.Print "Crispy1"
  457.  
  458.    Form1.ForeColor = Color1
  459.    Form1.CurrentX = 84
  460.    Form1.CurrentY = 14
  461.    Form1.Print "Crispy1"
  462.  
  463.    Form1.ForeColor = Color1
  464.    Form1.CurrentX = 83
  465.    Form1.CurrentY = 13
  466.    Form1.Print "Crispy1"
  467.  
  468.    'now lets print the actual Form1 text
  469.    Form1.FontName = "Helv"
  470.    Form1.FontSize = 18
  471.                              
  472.    Print3D Form1, 10, 55, -1, -1, Color1, Color2, "A game by Chris Pando                        "
  473.    Form1.FontSize = 9.75
  474.    Print3D Form1, 10, 95, -1, -1, Color1, Color2, "71020,2545 (CIS)                             "
  475.    Color2 = RGB(255, 0, 0)
  476.    Color1 = RGB(0, 0, 0)
  477.    Form1.FontSize = 18
  478.    Print3D Form1, 10, 130, 2, -2, Color1, Color2, "If it is squinky, then you "
  479.    Print3D Form1, 10, 155, 2, -2, Color1, Color2, "know it is BrilligWare!    "
  480.  
  481.    SplitFramedForm Form1
  482.  
  483.    Color2 = RGB(255, 255, 255)
  484.    Color1 = RGB(128, 128, 128)
  485.    Form1.FontSize = 9.75
  486.    Print3D Form1, 10, 220, -1, -1, Color1, Color2, "Many thanks to Richard R. Sands, the creator "
  487.    Print3D Form1, 10, 240, -1, -1, Color1, Color2, "of VBCARDS.DLL, who developed the tools      "
  488.    Print3D Form1, 10, 260, -1, -1, Color1, Color2, "and techniques that made this game possible. "
  489.  
  490.  ' Print3D Form1, 10, 290, -1, -1, Color1, Color2, "Also, many thanks to my co-workers who,      "
  491.  ' Print3D Form1, 10, 310, -1, -1, Color1, Color2, "despite great personal hardship, found the   "
  492.  ' Print3D Form1, 10, 330, -1, -1, Color1, Color2, "time to test (and criticize) this game.      "
  493.  
  494.    Form1.Show 1
  495. End Sub
  496.  
  497. Sub SplitFramedForm (Source As Form)
  498. 'assuming Source.ScaleMode = PIXEL
  499.    Source.Line (5, (Int(Source.ScaleHeight / 2)))-Step(Source.ScaleWidth - 10, 0), RGB(0, 0, 0)
  500.    Source.Line (5, (Int(Source.ScaleHeight / 2)) + 1)-Step(Source.ScaleWidth - 10, 0), RGB(255, 255, 255)
  501. End Sub
  502.  
  503. Sub Engine (Index As Integer)
  504.     ' This is the routine that does all the work
  505.     ' I decided this routine would be most reliably implemented
  506.     ' as a semi-rigorous finite state machine
  507.     '
  508.     '
  509.     '
  510.     Select Case State
  511.        Case CLOSEDFIELD
  512.  
  513.           If (RoyalCard(Index) <> TRUE) Then
  514.              ReverseImage Pfield.Picture1(Index)
  515.              State = APENDING
  516.              CtlEnable 1
  517.              FromCard = Index
  518.           End If
  519.  
  520.  
  521.        Case OPENFIELD
  522.  
  523.           If (Field(Index) <> -1) Then
  524.              If (RoyalCard(Index) <> TRUE) Then
  525.                 ReverseImage Pfield.Picture1(Index)
  526.                 State = APENDING
  527.                 CtlEnable 1
  528.                 FromCard = Index
  529.              Else
  530.                 ReverseImage Pfield.Picture1(Index)
  531.                 State = CPENDING
  532.                 CtlEnable 1
  533.                 FromCard = Index
  534.              End If
  535.           End If
  536.  
  537.        Case APENDING
  538.           If (FromCard = Index) Then
  539.              ReverseImage Pfield.Picture1(Index)
  540.              OpenOrClosed                        ' set state
  541.           ElseIf (SameCardValue(Field(FromCard), Field(Index))) Then
  542.              Remove FromCard, Index
  543.              OpenOrClosed                        ' set state
  544.           End If
  545.  
  546.        Case CPENDING
  547.  
  548.           If (FromCard = Index) Then
  549.              ReverseImage Pfield.Picture1(Index)
  550.              State = OPENFIELD
  551.              CtlEnable 3
  552.           ElseIf (ValidEmpty(Index)) Then
  553.              Swap FromCard, Index
  554.              State = OPENFIELD
  555.              CtlEnable 3
  556.           End If
  557.  
  558.     End Select
  559.  
  560.     If TestWin() Then
  561.       LoadWin
  562.     End If
  563. End Sub
  564.  
  565. Sub DealCards ()
  566. ' deal a card to all empty positions on the playing field
  567.    i = 0
  568.    Do While (NextCard < 53 And NumberOpen > 0) 'NumberOpen > 0 implies that
  569.       Do While (Field(i) <> -1)                ' there exists a Field(I)
  570.          i = i + 1                             ' = -1
  571.       Loop
  572.  
  573.       Field(i) = Deck(NextCard)
  574.       GetCard (Field(i))
  575.       Pfield.Picture1(i).Picture = ClipBoard.GetData(2)
  576.       NumberOpen = NumberOpen - 1
  577.       NextCard = NextCard + 1
  578.       If (NextCard = 53) Then
  579.          GetCardMisc (1)
  580.       Else
  581.          GetCardBack (BackDesign)
  582.       End If
  583.       Pfield.NewCards.Picture = ClipBoard.GetData(2)
  584.     
  585.       State = CLOSEDFIELD      'set state
  586.       CtlEnable 2
  587.    Loop
  588. End Sub
  589.  
  590. Sub NewGame ()
  591.    ShuffleDeck
  592.    DealDeck
  593. End Sub
  594.  
  595. Sub GetProfile ()
  596. ' set a couple of the global variables
  597.    Pfield.WindowState = GetPrivateProfileInt("Crispy1", "WindowState", 2, "CRISPY.INI")
  598.    BackDesign = GetPrivateProfileInt("Crispy1", "BackDesign", 1, "CRISPY.INI")
  599. End Sub
  600.  
  601. Sub WriteProfile ()
  602.    x = WritePrivateProfileString("Crispy1", "WindowState", Str$(Pfield.WindowState), "CRISPY.INI")
  603.    x = WritePrivateProfileString("Crispy1", "BackDesign", Str$(BackDesign), "CRISPY.INI")
  604. End Sub
  605.  
  606. Function TestWin () As Integer
  607. ' if the four center places are empty, and all cards have been dealt, then we have a winner
  608.    If NextCard = 53 And Field(CENTER1) = -1 And Field(CENTER2) = -1 And Field(CENTER3) = -1 And Field(CENTER4) = -1 Then
  609.       TestWin = TRUE
  610.    Else
  611.       TestWin = FALSE
  612.    End If
  613. End Function
  614.  
  615. Sub CenterCtlBottom (Source As Form, Ctl As Control, Alt As Integer)
  616.  ' center control a specified distance above the bottom of the form
  617.  ' works regardless of ScaleMode
  618.  
  619.    Ctl.Top = Source.ScaleHeight - Ctl.Height - Alt
  620.    Ctl.Left = (Source.ScaleWidth - Ctl.Width) / 2
  621. End Sub
  622.  
  623. Sub LoadWin ()
  624.    Dim Color1 As Long
  625.    Dim Color2 As Long
  626.  
  627.    Color2 = RGB(255, 255, 255)
  628.    Color1 = RGB(128, 128, 128)
  629.  
  630.    Load Form1
  631.  
  632.    Form1.WindowState = 0
  633.    Form1.AutoRedraw = TRUE
  634.    Form1.ScaleMode = PIXEL
  635.    Form1.BackColor = RGB(192, 192, 192)
  636.   
  637.    Form1.Top = 2250
  638.    Form1.Left = 1800
  639.    Form1.Height = 3015
  640.    Form1.Width = 2415
  641.  
  642. ' center the command button
  643.    CenterCtlBottom Form1, Form1.Command1, 10
  644.     
  645. ' go ahead and frame the form
  646.    FrameForm Form1
  647.  
  648. ' now lets print something
  649.    Form1.FontName = "Helv"
  650.    Form1.FontSize = 24
  651.  
  652.    Form1.ForeColor = Color2
  653.    Form1.CurrentX = 15
  654.    Form1.CurrentY = 15
  655.    Form1.Print "CRISPY1"
  656.  
  657.    Form1.ForeColor = Color1
  658.    Form1.CurrentX = 14
  659.    Form1.CurrentY = 14
  660.    Form1.Print "CRISPY1"
  661.  
  662.    Form1.ForeColor = Color1
  663.    Form1.CurrentX = 13
  664.    Form1.CurrentY = 13
  665.    Form1.Print "CRISPY1"
  666.  
  667.    'now lets print the actual Form1 text
  668.    Form1.FontName = "Helv"
  669.    Form1.FontSize = 18
  670.                              
  671.    Print3D Form1, 10, 55, -1, -1, Color1, Color2, "We Have  "
  672.    Print3D Form1, 10, 75, -1, -1, Color1, Color2, "A Winner!"
  673.  
  674.    Form1.Show 1
  675.  
  676. End Sub
  677.  
  678. Sub PaintPfield ()
  679. 'not using persistent bit maps, so if Pfield is redisplayed
  680. '(minimized, and then un-minimized) redo graphic effects
  681.    If State = APENDING Or State = CPENDING Then
  682.       ReverseImage Pfield.Picture1(FromCard)
  683.    End If
  684. End Sub
  685.  
  686.