home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / UT / UT070.ZIP / MENUS.EXE / SLIDE.MNU < prev    next >
Text File  |  1990-11-11  |  9KB  |  419 lines

  1. Comment
  2. =======================================
  3. Slide.mnu
  4.  
  5. The object of this game is to move the tiles into numerical order.
  6. The shuffle feature does not generate a truly random order, it just
  7. starts you at a different place. Marc is going to work on the RANDOM
  8. function in MarxMenu to work better.
  9.  
  10. Enjoy!
  11.    KLM (06-01-90)
  12.  
  13. Kevin L. Moore
  14. Computer Tyme
  15. (417)866-1665
  16. (417)546-3130
  17.  
  18. =======================================
  19. EndComment
  20.  
  21. Var
  22.    TileArr Row Col TmpArr OldCol OldRow ClearChar
  23.    MainScreenForeColor       MainScreenBackColor
  24.    TitleForeColor            TitleBackColor
  25.    WindowBorderForeColor     WindowBorderBackColor
  26.    WindowInsideForeColor     WindowInsideBackColor
  27.    TileForeColor             TileBackColor
  28.    TileNumForeColor          TileNumBackColor
  29.    MessageWinBorderForeColor MessageWinBorderBackColor
  30.    MessageWinInsideForeColor MessageWinInsideBackColor
  31.  
  32. Const
  33.    MaxRow = 4
  34.    MaxCol = 4
  35.  
  36. Main
  37.  
  38. Procedure Setup
  39.    if ColorScreen
  40.       MainScreenForeColor       = White
  41.       MainScreenBackColor       = Blue
  42.       TitleForeColor            = Yellow
  43.       TitleBackColor            = Mag
  44.       WindowBorderForeColor     = LRed
  45.       WindowBorderBackColor     = Brown
  46.       WindowInsideForeColor     = Blue
  47.       WindowInsideBackColor     = Brown
  48.       TileForeColor             = Blue
  49.       TileBackColor             = Brown
  50.       TileNumForeColor          = White
  51.       TileNumBackColor          = Blue
  52.       MessageWinBorderForeColor = Green
  53.       MessageWinBorderBackColor = Brown
  54.       MessageWinInsideForeColor = Yellow
  55.       MessageWinInsideBackColor = Brown
  56.       ClearChar                 = 32
  57.    else
  58.       MainScreenForeColor       = Grey
  59.       MainScreenBackColor       = Black
  60.       TitleForeColor            = Black
  61.       TitleBackColor            = Grey
  62.       WindowBorderForeColor     = White
  63.       WindowBorderBackColor     = Brown
  64.       WindowInsideForeColor     = White
  65.       WindowInsideBackColor     = Brown
  66.       TileForeColor             = Green
  67.       TileBackColor             = Black
  68.       TileNumForeColor          = Black
  69.       TileNumBackColor          = Grey
  70.       MessageWinBorderForeColor = Green
  71.       MessageWinBorderBackColor = Brown
  72.       MessageWinInsideForeColor = Yellow
  73.       MessageWinInsideBackColor = Brown
  74.       ClearChar                 = 177
  75.    endif
  76.  
  77.    UseArrows Off
  78.    TextColor MainScreenForeColor MainScreenBackColor
  79.    ClearScreen ClearChar
  80.    TextColor TitleForeColor TitleBackColor
  81.    GotoXY 1 1
  82.    ClearLine
  83.    GotoXY 63 1
  84.    Write 'Slide Puzzle 1.00'
  85.    GotoXY 1 24
  86.    ClearLine
  87.    WriteCenter 'F1 - Panic Button * F10 - Shuffle * ESC - Exit '
  88.    GotoXY 1 25
  89.    ClearLine
  90.    WriteCenter '(C) Copyright 1990 Computer Tyme * All rights reserved'
  91.    ClockColor TitleForeColor TitleBackColor
  92.    ClockPos 1 1
  93.  
  94.    Explode Off
  95.    Shadow Off
  96.  
  97.    BlockBox
  98.    BoxBorderColor WindowBorderForeColor WindowBorderBackColor
  99.    BoxInsideColor WindowInsideForeColor WindowInsideBackColor
  100.    DrawBox 20 3 45 19
  101.  
  102.    DrawBoard
  103.    Shuffle
  104.    NumberBoard
  105.  
  106. EndProc ;Setup
  107.  
  108. ;---
  109.  
  110.  
  111. Procedure DrawBoard
  112. Var X Y
  113.  
  114.    TextColor TileForeColor TileBackColor
  115.    X = 1
  116.    While X < (MaxRow + 1)
  117.       GotoXY 1, ((X * 4) - 2)
  118.       Writeln '        ██████ ██████ ██████ ██████'
  119.       Writeln '        ██████ ██████ ██████ ██████'
  120.       Write   '        ██████ ██████ ██████ ██████'
  121.       X = X + 1
  122.  
  123.    EndWhile
  124.  
  125. EndProc ;DrawBoard
  126.  
  127. ;---
  128.  
  129. Procedure NumberBoard
  130. Var X Y
  131.  
  132.    TextColor TileNumForeColor TileNumBackColor
  133.    X = 1
  134.    While X < (MaxRow + 1)
  135.       Y = 1
  136.       While Y < (MaxCol + 1)
  137.          NumberTile (X, Y)
  138.          Y = Y + 1
  139.       EndWhile
  140.       X = X + 1
  141.    EndWhile
  142.  
  143.    DrawEmptyTile
  144.  
  145. EndProc ;NumberBoard
  146.  
  147. ;---
  148.  
  149. Procedure DrawEmptyTile
  150.  
  151.    NoBoxBorder
  152.    BoxInsideColor TileBackColor TileBackColor
  153.    DrawBox (((Col + 3) * 7) + 1)  (((Row + 1) * 4) - 3) 6 3
  154.  
  155. EndProc ;DrawEmptyTile
  156.  
  157. ;---
  158.  
  159. Procedure Shuffle
  160. Var X Y C  Seed
  161.  
  162.    BlockBox
  163.    BoxInsideColor Yellow Brown
  164.    DrawBox 27 10 30 3
  165.  
  166.    WriteCenter 'Shuffling . . .'
  167.  
  168.    Seed = Random
  169.  
  170.    C = 1
  171.    While C < ((MaxRow * MaxCol) + 1)
  172.       TmpArr[C] = C
  173.       C = C + 1
  174.    EndWhile
  175.  
  176.    C = 0
  177.    X = 1
  178.    While X < (MaxRow + 1)
  179.       Y = 1
  180.       While Y < (MaxCol + 1)
  181.          TileArr[X,Y] = 99
  182.          While TileArr[X,Y] = 99
  183.             C = ( Random Mod (MaxRow * MaxCol)) + 1
  184.             if TmpArr[C] <> 0
  185.                If C = (MaxRow * MaxCol)
  186.                   TileArr[X,Y] = 0
  187.                   Row = X
  188.                   Col = Y
  189.                else
  190.                   TileArr[X,Y] = C
  191.                endif
  192.                TmpArr[C] = 0
  193.             endif
  194.          EndWhile
  195.          Y = Y + 1
  196.       EndWhile
  197.       X = X + 1
  198.    EndWhile
  199.  
  200.    EraseTopWindow
  201.  
  202. EndProc ;Shuffle
  203.  
  204. ;---
  205.  
  206. Procedure SlideRight
  207.  
  208.    if Col > 1
  209.       TileArr[Row, Col] = Tilearr[Row, Col - 1]
  210.       OldRow = Row
  211.       OldCol = Col
  212.       TileArr[Row, Col - 1] = 0
  213.       Col = Col - 1
  214.       MoveTile
  215.    endif
  216.  
  217. EndProc ;SlideRight
  218.  
  219. ;---
  220.  
  221. Procedure SlideLeft
  222.  
  223.    If Col < MaxCol
  224.       TileArr[Row, Col] = TileArr[Row, Col + 1]
  225.       OldCol = Col
  226.       OldRow = Row
  227.       TileArr[Row, Col + 1] = 0
  228.       Col = Col + 1
  229.       MoveTile
  230.    endif
  231.  
  232. EndProc ;SlideLeft
  233.  
  234. ;---
  235.  
  236. Procedure SlideUp
  237.  
  238.    If Row < MaxRow
  239.       TileArr[Row, Col] = TileArr[Row + 1, Col]
  240.       OldCol = Col
  241.       OldRow = Row
  242.       TileArr[Row + 1, Col] = 0
  243.       Row = Row + 1
  244.       MoveTile
  245.    endif
  246.  
  247. EndProc ;SlideUp
  248.  
  249. ;---
  250.  
  251. Procedure SlideDown
  252.  
  253.    If Row > 1
  254.       TileArr[Row, Col] = TileArr[Row - 1, Col]
  255.       OldRow = Row
  256.       OldCol = Col
  257.       TileArr[Row - 1, Col] = 0
  258.       Row = Row - 1
  259.       MoveTile
  260.    endif
  261.  
  262. EndProc ;SlideDown
  263.  
  264. ;---
  265.  
  266. Procedure MoveTile
  267.  
  268.    EraseTopWindow
  269.    NumberTile (OLdRow, OldCol)
  270.    DrawEmptyTile
  271.    if CheckForWin
  272.       AdmitDefeat
  273.       ClearScreen
  274.       if AskYesNo('   Play again')
  275.          Shuffle
  276.          DrawBoard
  277.       else
  278.          ExitMenu
  279.       endif
  280.    endif
  281.  
  282. EndProc ;MoveTile
  283.  
  284. ;---
  285.  
  286. Procedure NumberTile (X, Y)
  287.  
  288.    TextColor TileNumForeColor TileNumBackColor
  289.    GotoXY ((Y * 7) + 4) ((X * 4) - 1)
  290.    If TileArr[X, Y] < 10 then Write ' '
  291.    Write TileArr[X,Y]
  292.  
  293. EndProc ;NumberTile
  294.  
  295. ;---
  296.  
  297. Procedure CheckForWin
  298. Var X Y C
  299.  
  300.    C = 0
  301.    X = 1
  302.    While X < (MaxRow + 1)
  303.       Y = 1
  304.       While Y < (MaxCol + 1)
  305.          C = C + 1
  306.          if (TileArr[X,Y] <> 0)
  307.             if TileArr[X,Y] <> C then Return False
  308.          endif
  309.          Y = Y + 1
  310.       EndWhile
  311.       X = X + 1
  312.    EndWhile
  313.  
  314.    Return True
  315.  
  316. EndProc ;CheckForWin
  317.  
  318. ;---
  319.  
  320. Procedure AdmitDefeat
  321.  
  322.    BlockBox
  323.    BoxBorderColor MessageWinBorderForeColor MessageWinBorderBackColor
  324.    BoxInsideColor MessageWinInsideForeColor MessageWinInsideBackColor
  325.    Drawbox  27 11 31 3
  326.    WriteCenter 'You Win !!!'
  327.    Write Char(7)
  328.    Write Char(7)
  329.    Wait(150)
  330.  
  331. EndProc ;AdmitDefeat
  332.  
  333. ;---
  334.  
  335. Procedure AskYesNo (Question)
  336. Var YesNo
  337.  
  338.    Write ' ',Question,' [Y,N] ? '
  339.    YesNo = UpperCase(ReadKey)
  340.    YesNo = YesNo = 'Y'
  341.    if YesNo
  342.       Write 'Yes'
  343.    else
  344.       Write 'No'
  345.    endif
  346.    Wait 50
  347.    EraseTopWindow
  348.    Return (YesNo)
  349.  
  350. EndProc ;AskYesNo
  351.  
  352. ;---
  353.  
  354. Procedure PanicButton
  355. Var AllClear
  356.  
  357.    NoBoxBorder
  358.    ClockPos 0,0
  359.    BoxInsideColor White Blue
  360.    DrawBox 1 1 80 25
  361.    Writeln 'SuperCalc 1.00                                            Memory: 52163'
  362.    Writeln '1         A         B         C         D         E         F         G'
  363.    Writeln '1'
  364.    Writeln '2'
  365.    Writeln '3'
  366.    Writeln '4'
  367.    Writeln '5'
  368.    Writeln '6'
  369.    Writeln '7'
  370.    Writeln '8'
  371.    Writeln '9'
  372.    Writeln '10'
  373.    Writeln '11'
  374.    Writeln '12'
  375.    Writeln '13'
  376.    Writeln '14'
  377.    Writeln '15'
  378.    Writeln '16'
  379.    Writeln '17'
  380.    Writeln '18'
  381.    Writeln '19'
  382.    Writeln 'A3 Empty             No file'
  383.    Writeln
  384.    Writeln
  385.    Write   'F2-Save F3-Load F7-Formula F8-AutoCalc F9-Recalc F10-Menu Ins-Block Alt-X-Exit'
  386.  
  387.    AllClear = ReadKey
  388.    EraseTopWindow
  389.    ClockColor TitleForeColor TitleBackColor
  390.    ClockPos 1 1
  391.  
  392. EndProc ;PanicButton
  393.  
  394. ;---
  395.  
  396. Procedure Main
  397. Var Key
  398.  
  399.    Setup
  400.  
  401.    Repeat
  402.       Key = ReadKey
  403.       if Key = Char(4) then SlideRight
  404.       if Key = Char(19) then SlideLeft
  405.       if Key = Char(5) then SlideUp
  406.       if Key = Char(24) then SlideDown
  407.       if Key = F10
  408.          Shuffle
  409.          EraseTopWindow
  410.          NumberBoard
  411.       endif
  412.       if Key = F1 then PanicButton
  413.  
  414.    Until Key = ESC
  415.  
  416. EndProc ;Main
  417.  
  418.  
  419.