home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-06 | 23.1 KB | 1,344 lines |
- * ╥─┐──────┐
- * ╟─┘┌╥─┐o │ 7/22/91
- * ║╓╥┐║╥┐╥╓┐
- * ║║╟┘║║ ║╙╖ Copyright (c) 1991 Gerald F. Garcia, Jr.
- * ╨╙╨ ╨╨ ╨└╜
- * └──v1.0──┘ All Rights Reserved
-
- FUNCTION PopTris
-
- parameters ;
- nRow, nCol, nLvl, nHt
-
- private ;
- cSavSetTalk, cSavSetBlink, cSavSetCursor, ;
- cSavSetEscape, nSavSetTypeahead, lSavSetCapsLock, ;
- lSavSetNumLock
-
-
-
-
-
- * SAVE AND SET ENVIRONMENT
-
- if Set( "talk" ) = "ON"
- set talk off
- cSavSetTalk = "ON"
- else
- cSavSetTalk = "OFF"
- endif
-
- if ! ( "EGA" $ Sys( 2006 ) .or. "VGA" $ Sys( 2006 ) )
- wait "Sorry, PopTris REQUIRES EGA/VGA" window
- RETURN ( "" )
- endif
-
- cSavSetBlink = Set( "blink" )
- cSavSetCursor = Set( "cursor" )
- cSavSetEscape = Set( "escape" )
- nSavSetTypeahead = Set( "typeahead" )
- lSavSetCapsLock = CapsLock()
- lSavSetNumLock = NumLock()
-
- set blink off
- set cursor off
- set escape off
- set typeahead to 1
- = CapsLock( .t. )
- = NumLock( .t. )
-
-
- * CALIBRATE AND DEFINE WINDOWS
-
- if Type( "nLvl" ) = "N"
- nLvl = Iif( Between( nLvl, 0, 9 ), nLvl, 0 )
- else
- nLvl = 0
- endif
-
- if Type( "nHt" ) = "N"
- nHt = Iif( Between( nHt, 0, 9 ), nHt, 0 )
- else
- nHt = 0
- endif
-
- nRow = ;
- Iif( Type( "nRow" ) != "N", ;
- ( SRows() - 22 ) / 2, ;
- Min( Abs( nRow ), SRows() - 22 ) )
-
- nCol = ;
- Iif( Type( "nCol" ) != "N", ;
- ( SCols() - 32 ) / 2, ;
- Min( Abs( nCol ), SCols() - 32 ) )
-
- define window wTetris ;
- from nRow, nCol to nRow + 21, nCol + 31 ;
- float shadow color n/w
-
- define window wNoNext in window wTetris ;
- from 07, 03 to 08, 06 ;
- none color w/w
-
- define window wNoStat in window wTetris ;
- from 11, 01 to 19, 07 ;
- none color w/w
-
- define window wPause in window wTetris ;
- from 08, 11 to 11, 18 color r+/w
-
- activate window wPause noshow
-
- @ 00, 01 say "GAME"
- @ 01, 00 say "PAUSED"
-
- activate window wTetris noshow
-
- show window wNoNext
- show window wNoStat
-
-
- * DRAW PLAYFIELD
-
- * 1 2
- * 012345678901234567890123456789
- @ 00,00 say " Score ░░░░░░░░░░ Level 0 " && 00
- @ 01,00 say " 0 ░░░░░░░░░░ " && 01
- @ 02,00 say " ░░░░░░░░░░ ┌───────╖" && 02
- @ 03,00 say " Lines ░░░░░░░░░░ │ OK ║" && 03
- @ 04,00 say " 0 ░░░░░░░░░░ ╘═══════╝" && 04
- @ 05,00 say " ░░░░░░░░░░ ┌───────╖" && 05
- @ 06,00 say " [ ] Next ░░░░░░░░░░ │Options║" && 06
- @ 07,00 say " ░░░░░░░░░░ ╘═══════╝" && 07
- @ 08,00 say " ░░░░░░░░░░ ┌───────╖" && 08
- @ 09,00 say " ░░░░░░░░░░ │Restart║" && 09
- @ 10,00 say " [ ] Stat ░░░░░░░░░░ ╘═══════╝" && 10
- @ 11,00 say " ■ ░░░░░░░░░░ ┌─╖ " && 11
- @ 12,00 say " ■ ░░░░░░░░░░ │║ " && 12
- @ 13,00 say " ■ ░░░░░░░░░░ ╘═╝ " && 13
- @ 14,00 say " ■ ░░░░░░░░░░ ┌─╖┌─╖┌─╖" && 14
- @ 15,00 say " ■ ░░░░░░░░░░ │║│║│║" && 15
- @ 16,00 say " ■ ░░░░░░░░░░ ╘═╝╘═╝╘═╝" && 16
- @ 17,00 say " ■ ░░░░░░░░░░ ┌─╖ " && 17
- @ 18,00 say " ─────── ░░░░░░░░░░ │║ " && 18
- @ 19,00 say " Σ ░░░░░░░░░░ ╘═╝ " && 19
- * 012345678901234567890123456789
- * 1 2
-
- @ 01, 02 fill to 01, 07 color w+/w
- @ 04, 02 fill to 04, 07 color bg+/w
- @ 00, 28 fill to 00, 28 color bg+/w
-
- @ 03, 25 fill to 03, 25 color gr+/w
- @ 06, 22 fill to 06, 22 color gr+/w
- @ 09, 22 fill to 09, 22 color gr+/w
- @ 06, 05 fill to 06, 05 color gr+/w
- @ 10, 05 fill to 10, 05 color gr+/w
-
- @ 11, 01 fill to 11, 01 color g/g*
- @ 12, 01 fill to 12, 01 color r+/g
- @ 13, 01 fill to 13, 01 color w+/bg
- @ 14, 01 fill to 14, 01 color r/gr*
- @ 15, 01 fill to 15, 01 color br/b
- @ 16, 01 fill to 16, 01 color n/r
- @ 17, 01 fill to 17, 01 color br/br*
-
- @ 00, 10 fill to 19, 19 color n/n
-
- activate window wTetris top
-
- private ;
- nScore, nLines, nStartLevel, nLevel, nHeight, ;
- nHiScore, nHiLines, nHiLevel, nShapeTot, nNextShape, ;
- nNewShape, lRestarted, lShowNext, lShowStat, nFactor, ;
- nKeyPress, cKeyPress, nOrientation, n1, n, ;
- lReady2xit, lOk, cDispNext, cInitShape, cShowShape, ;
- lObstructed
-
- declare ;
- anShapeCnt( 7 ), anShapeRow( 4 ), anShapeCol( 4 ), ;
- alPosFilled( 20, 10 ), anTmpRow( 4 ), anTmpCol( 4 ), ;
- anDelayFactor( 10 ), anOrientMax( 7 )
-
- nScore = 0
- nLines = 0
- nStartLevel = nLvl
- nLevel = nStartLevel
- nHeight = nHt
-
- nHiScore = 0
- nHiLines = 0
- nHiLevel = 0
-
- anShapeRow = 0
- anShapeCol = 0
- anTmpRow = 0
- anTmpCol = 0
-
- anShapeCnt = 0
- nShapeTot = 0
-
- nNextShape = 0
- nNewShape = Int( Rand( -1 ) * 7 + 1 )
-
- alPosFilled = .f.
-
- lRestarted = .f.
-
- lShowNext = .f.
- lShowStat = .f.
-
- nFactor = 0.06
-
- nKeyPress = 0
- cKeyPress = ""
-
- nOrientation = 1
-
- anOrientMax( 1 ) = 4
- anOrientMax( 2 ) = 4
- anOrientMax( 3 ) = 1
- anOrientMax( 4 ) = 2
- anOrientMax( 5 ) = 2
- anOrientMax( 6 ) = 2
- anOrientMax( 7 ) = 4
-
- n1 = 10
-
- for n = 1 to 10
- anDelayFactor( n ) = n1 * nFactor
- n1 = n1 - 1
- endfor
-
- = _ShoLvl()
-
- lReady2xit = .f.
-
- do while !lReady2xit
- if nHeight > 0
- = _PlotHt()
- endif
-
- lOk = .t.
-
- do while lOk
- nNextShape = Int( Rand() * 7 + 1 )
-
- @ 07, 03 fill to 08, 06 color w/w
-
- cDispNext = "_ShoNxt" + Str( nNextShape, 1 )
- do ( cDispNext )
-
- cNewShape = Str( nNewShape, 1 )
-
- anShapeCnt( nNewShape ) = anShapeCnt( nNewShape ) + 1
- nShapeTot = nShapeTot + 1
-
- @ 10 + nNewShape, 03 say anShapeCnt( nNewShape ) picture "99999"
-
- @ 19, 03 say nShapeTot picture "99999"
- @ 01, 02 say nScore picture "999999" color w+/w
-
- nRow = Iif( nNewShape = 3, 1, 0 )
- nCol = Iif( nNewShape = 3, 5, 4 )
-
- nOrientation = 1
-
- cInitShape = "_IntSh" + cNewShape + "1"
- do ( cInitShape )
-
- = _Tmp2Shp()
-
- cShowShape = "_ShoShp" + cNewShape
- do ( cShowShape )
-
- if _OvrLapd()
- = _EndGame()
- = _Restart()
- endif
-
- lObstructed = .f.
-
- = CapsLock( .t. )
-
- do while .not. lObstructed .and. lOk
- nDelay = Seconds() + anDelayFactor( nLevel + 1 )
-
- do while Seconds() < nDelay
- nKeyPress = 0
-
- do while nKeyPress = 0 .and. Seconds() < nDelay
- nKeyPress = Inkey()
- enddo
-
- cKeyPress = LTrim( Str( nKeyPress, 2 ) )
-
- if Seconds() < nDelay .and. ;
- ( "/" + cKeyPress + "/" ) $ ;
- "/4/5/13/19/24/27/32/50/52/53/54/56/75/76/78/79/80/82/83/"
-
- do ( "_Key" + cKeyPress )
- endif
- enddo
-
- nRow = nRow + Iif( lRestarted, 0, 1 )
-
- do ( "_IntSh" + cNewShape + Str( nOrientation, 1 ) )
-
- if _OvrLapd() .and. lOk
- lObstructed = .t.
-
- for n = 1 to 4
- alPosFilled( anShapeRow( n ), anShapeCol( n ) ) = .t.
- endfor
-
- nScore = nScore + nLevel
- else
- = _DelShp()
- = _Tmp2Shp()
-
- do ( "_ShoShp" + cNewShape )
- endif
- enddo
-
- = _ChkLine()
-
- nNewShape = nNextShape
- enddo
-
- if lRestarted
- = _ClrScrn()
- lRestarted = .f.
- endif
- enddo
-
- if cSavSetBlink = "ON"
- set blink on
- endif
-
- if cSavSetCursor = "ON"
- set cursor on
- endif
-
- if cSavSetEscape = "ON"
- set escape on
- endif
-
- set typeahead to nSavSetTypeahead
-
- = CapsLock( lSavSetCapsLock )
- = NumLock( lSavSetNumLock )
-
- if cSavSetTalk = "ON"
- set talk on
- endif
-
- release window wTetris
-
- RETURN ( "" )
-
-
-
- FUNCTION _ChkLine
-
- private ;
- n1, n2, n3, n4, nLine
-
- for n1 = 1 to 20
- nLine = 0
-
- for n2 = 1 to 10
- nLine = nLine + Iif( alPosFilled( n1, n2 ), 1, 0 )
- endfor
-
- if nLine = 10
- scroll 00, 10, n1 - 1, 19, -1
-
- @ 00, 10 fill to 00, 19 color n/n
-
- for n3 = n1 to 2 step -1
- for n4 = 1 to 10
- alPosFilled( n3, n4 ) = alPosFilled( n3 - 1, n4 )
- endfor
- endfor
-
- for n4 = 1 to 10
- alPosFilled( 1, n4 ) = .f.
- endfor
-
- nLines = nLines + 1
-
- @ 04, 02 say nLines picture "999999" color bg+/w
-
- nScore = nScore + 10 + nLevel
-
- if ( nLevel < 9 ) .and. ( nLines >= ( ( nLevel + 2 ) * ( nLevel + 2 ) ) )
- nLevel = nLevel + 1
-
- = _ShoLvl()
- endif
- endif
- endfor
-
- RETURN ( "" )
-
-
-
- FUNCTION _ClrScrn
-
- @ 00, 10 fill to 19, 19 color n/n
-
- RETURN ( "" )
-
-
-
- FUNCTION _DelShp
-
- private n
-
- for n = 1 to 4
- @ anShapeRow( n ) - 1, anShapeCol( n ) + 9 say " " color n/n
- endfor
-
- RETURN ( "" )
-
-
-
- FUNCTION _Drop
-
- private lOk
-
- lOk = .t.
-
- do while lOk
- nRow = nRow + 1
-
- do ( "_IntSh" + cNewShape + Str( nOrientation, 1 ) )
-
- if _OvrLapd()
- nRow = nRow - 1
- lOk = .f.
- else
- nScore = nScore + 0.5
- endif
- enddo
-
- do ( "_IntSh" + cNewShape + Str( nOrientation, 1 ) )
-
- = _DelShp()
- = _Tmp2Shp()
-
- do ( "_ShoShp" + cNewShape )
-
- RETURN ( "" )
-
-
-
- FUNCTION _EndGame
-
- private ;
- n, nKeyPress, lOk
-
- for n = 0 to 9
- @ n, 10 say Replicate( "■", 10 ) color g/g*
- @ 19 - n, 10 say Replicate( "■", 10 ) color g/g*
-
- nDelay = Seconds() + 0.06
-
- do while Seconds() < nDelay
- enddo
- endfor
-
- @ 09, 13 say "GAME" color w+/n
- @ 10, 13 say "OVER" color w+/n
-
- lOk = .f.
-
- nKeyPress = Inkey( 5 )
-
- if nKeyPress = 0
- lOk = .t.
-
- do while lOk
- = _Title()
-
- nKeyPress = Inkey( 10 )
-
- if nKeyPress = 0
- = _ShoHigh()
-
- nKeyPress = Inkey( 10 )
-
- lOk = ( nKeyPress = 0 )
- else
- lOk = .f.
- endif
- enddo
- endif
-
- activate window wTetris
-
- RETURN ( "" )
-
-
-
- PROCEDURE _IntSh11
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + 1
- anTmpCol( n ) = nCol + n - 1
- endfor
-
- anTmpRow( 4 ) = nRow + 2
- anTmpCol( 4 ) = nCol
- RETURN
-
- PROCEDURE _IntSh12
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + n - 1
- anTmpCol( n ) = nCol + 1
- endfor
-
- anTmpRow( 4 ) = nRow + 2
- anTmpCol( 4 ) = nCol + 2
- RETURN
-
- PROCEDURE _IntSh13
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + 1
- anTmpCol( n ) = nCol + n - 1
- endfor
-
- anTmpRow( 4 ) = nRow
- anTmpCol( 4 ) = nCol + 2
- RETURN
-
- PROCEDURE _IntSh14
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + n - 1
- anTmpCol( n ) = nCol + 1
- endfor
-
- anTmpRow( 4 ) = nRow
- anTmpCol( 4 ) = nCol
- RETURN
-
- PROCEDURE _IntSh21
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + 1
- anTmpCol( n ) = nCol + n - 1
- endfor
-
- anTmpRow( 4 ) = nRow + 2
- anTmpCol( 4 ) = nCol + 2
- RETURN
-
- PROCEDURE _IntSh22
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + n - 1
- anTmpCol( n ) = nCol + 1
- endfor
-
- anTmpRow( 4 ) = nRow
- anTmpCol( 4 ) = nCol + 2
- RETURN
-
- PROCEDURE _IntSh23
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + 1
- anTmpCol( n ) = nCol + n - 1
- endfor
-
- anTmpRow( 4 ) = nRow
- anTmpCol( 4 ) = nCol
- RETURN
-
- PROCEDURE _IntSh24
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + n - 1
- anTmpCol( n ) = nCol + 1
- endfor
-
- anTmpRow( 4 ) = nRow + 2
- anTmpCol( 4 ) = nCol
- RETURN
-
- PROCEDURE _IntSh31
- private n
-
- for n = 1 to 2
- anTmpRow( n ) = nRow
- anTmpCol( n ) = nCol + n - 1
- endfor
-
- for n = 3 to 4
- anTmpRow( n ) = nRow + 1
- anTmpCol( n ) = nCol + n - 3
- endfor
- RETURN
-
- PROCEDURE _IntSh41
- private n
-
- for n = 1 to 4
- anTmpRow( n ) = nRow + 1
- anTmpCol( n ) = nCol + n - 1
- endfor
- RETURN
-
- PROCEDURE _IntSh42
- private n
-
- for n = 1 to 4
- anTmpRow( n ) = nRow + n - 1
- anTmpCol( n ) = nCol + 2
- endfor
- RETURN
-
- PROCEDURE _IntSh51
- private n
-
- for n = 1 to 2
- anTmpRow( n ) = nRow + 1
- anTmpCol( n ) = nCol + n
- endfor
-
- for n = 3 to 4
- anTmpRow( n ) = nRow + 2
- anTmpCol( n ) = nCol + n - 3
- endfor
- RETURN
-
- PROCEDURE _IntSh52
- private n
-
- for n = 1 to 2
- anTmpRow( n ) = nRow + n - 1
- anTmpCol( n ) = nCol + 1
- endfor
-
- for n = 3 to 4
- anTmpRow( n ) = nRow + n - 2
- anTmpCol( n ) = nCol + 2
- endfor
- RETURN
-
- PROCEDURE _IntSh61
- private n
-
- for n = 1 to 2
- anTmpRow( n ) = nRow + 1
- anTmpCol( n ) = nCol + n - 1
- endfor
-
- for n = 3 to 4
- anTmpRow( n ) = nRow + 2
- anTmpCol( n ) = nCol + n - 2
- endfor
- RETURN
-
- PROCEDURE _IntSh62
- private n
-
- for n = 1 to 2
- anTmpRow( n ) = nRow + n
- anTmpCol( n ) = nCol
- endfor
-
- for n = 3 to 4
- anTmpRow( n ) = nRow + n - 3
- anTmpCol( n ) = nCol + 1
- endfor
- RETURN
-
- PROCEDURE _IntSh71
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + 1
- anTmpCol( n ) = nCol + n - 1
- endfor
-
- anTmpRow( 4 ) = nRow + 2
- anTmpCol( 4 ) = nCol + 1
- RETURN
-
- PROCEDURE _IntSh72
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + n - 1
- anTmpCol( n ) = nCol + 1
- endfor
-
- anTmpRow( 4 ) = nRow + 1
- anTmpCol( 4 ) = nCol + 2
- RETURN
-
- PROCEDURE _IntSh73
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + 1
- anTmpCol( n ) = nCol + n - 1
- endfor
-
- anTmpRow( 4 ) = nRow
- anTmpCol( 4 ) = nCol + 1
- RETURN
-
- PROCEDURE _IntSh74
- private n
-
- for n = 1 to 3
- anTmpRow( n ) = nRow + n - 1
- anTmpCol( n ) = nCol + 1
- endfor
-
- anTmpRow( 4 ) = nRow + 1
- anTmpCol( 4 ) = nCol
- RETURN
-
-
-
- PROCEDURE _Key4
- = _Right()
- RETURN
-
- PROCEDURE _Key5
- = _Up()
- RETURN
-
- PROCEDURE _Key13
- = _Drop()
- RETURN
-
- PROCEDURE _Key19
- = _Left()
- RETURN
-
- PROCEDURE _Key24
- = _Drop()
- RETURN
-
- PROCEDURE _Key27
- lOk = .f.
- lReady2xit = .t.
- RETURN
-
- PROCEDURE _Key32
- = _Drop()
- RETURN
-
- PROCEDURE _Key50
- = _Drop()
- RETURN
-
- PROCEDURE _Key52
- = _Left()
- RETURN
-
- PROCEDURE _Key53
- = _Rotate()
- RETURN
-
- PROCEDURE _Key54
- = _Right()
- RETURN
-
- PROCEDURE _Key56
- = _Up()
- RETURN
-
- PROCEDURE _Key76
- = _Rotate()
- RETURN
-
- PROCEDURE _Key78
- = _TglNext()
- RETURN
-
- PROCEDURE _Key75
- lOk = .f.
- lReady2xit = .t.
- RETURN
-
- PROCEDURE _Key79
- = _Option()
- = _Restart()
- RETURN
-
- PROCEDURE _Key80
- = _Pause()
- RETURN
-
- PROCEDURE _Key82
- = _Restart()
- RETURN
-
- PROCEDURE _Key83
- = _TglStat()
- RETURN
-
-
-
- FUNCTION _Left
-
- nCol = nCol - 1
-
- do ( "_IntSh" + cNewShape + Str( nOrientation, 1 ) )
-
- if _OvrLapd()
- nCol = nCol + 1
- else
- = _DelShp()
- = _Tmp2Shp()
-
- do ( "_ShoShp" + cNewShape )
- endif
-
- RETURN ( "" )
-
-
-
- FUNCTION _Option
-
- private ;
- nPos, nRow, nCol, n, lOk, nKeyPress
-
- * 1
- * 0123456789
- @ 00, 10 say "Level: " color w+/n
- @ 01, 10 say "┌─┬─┬─┬─┬─" color w/n
- @ 02, 10 say "│0│1│2│3│4" color w/n
- @ 03, 10 say "├─┼─┼─┼─┼─" color w/n
- @ 04, 10 say "│5│6│7│8│9" color w/n
- @ 05, 10 say "└─┴─┴─┴─┴─" color w/n
- @ 06, 10 say " " color w/n
- @ 07, 10 say "Height: " color w+/n
- @ 08, 10 say "┌─┬─┬─┬─┬─" color w/n
- @ 09, 10 say "│0│1│2│3│4" color w/n
- @ 10, 10 say "├─┼─┼─┼─┼─" color w/n
- @ 11, 10 say "│5│6│7│8│9" color w/n
- @ 12, 10 say "└─┴─┴─┴─┴─" color w/n
- @ 13, 10 say " " color w/n
- @ 14, 10 say " " color w+/n
- @ 15, 10 say " Select" color w+/n
- @ 16, 10 say " " color w+/n
- @ 17, 10 say " " color w/n
- @ 18, 10 say "─┘ Choose" color w+/n
- @ 19, 10 say " " color w/n
-
- nPos = nStartLevel
-
- for n = 1 to 2
- lOk = .f.
-
- do while !lOk
- nRow = Iif( n = 1, Iif( nPos > 4, 4, 2 ), Iif( nPos > 4, 11, 9 ) )
- nCol = ( Iif( nPos > 4, ( nPos - 5 ), nPos ) + 1 ) * 2 + 9
-
- @ nRow, nCol fill to nRow, nCol color bg/w*
-
- nKeyPress = Inkey( 0 )
-
- do case
- case nKeyPress = 5 .or. nKeyPress = 56
- nPos = Iif( nPos > 4, nPos - 5, nPos + 5 )
- case nKeyPress = 24 .or. nKeyPress = 50
- nPos = Iif( nPos > 4, nPos - 5, nPos + 5 )
- case nKeyPress = 19 .or. nKeyPress = 52
- nPos = Iif( nPos = 0, 9, nPos - 1 )
- case nKeyPress = 4 .or. nKeyPress = 54
- nPos = Iif( nPos = 9, 0, nPos + 1 )
- case nKeyPress = 13 .or. nKeyPress = 53
- lOk = .t.
- endcase
-
- if !lOk
- @ nRow, nCol fill to nRow, nCol color w/n
- endif
- enddo
-
- if n = 1
- store nPos to nLevel, nStartLevel
- else
- nHeight = nPos
- endif
-
- nPos = nHeight
- endfor
-
- @ 00, 28 say nLevel picture "9" color bg+/w
-
- RETURN ( "" )
-
-
-
- FUNCTION _OvrLapd
-
- private ;
- lOverLapped, n
-
- lOverLapped = .f.
-
- for n = 1 to 4
- if Between( anTmpRow( n ), 1, 20 ) .and. ;
- Between( anTmpCol( n ), 1, 10 )
-
- if alPosFilled( anTmpRow( n ), anTmpCol( n ) )
- lOverLapped = .t.
- exit
- endif
- else
- lOverLapped = .t.
- exit
- endif
- endfor
-
- RETURN ( lOverLapped )
-
-
-
- FUNCTION _Pause
-
- show window wPause
-
- = Inkey( 0 )
-
- hide window wPause
-
- RETURN ( "" )
-
-
-
- FUNCTION _PlotHt
-
- private ;
- n, nCount, nTmp, nColor
-
- store 0 to ;
- n, nCount, nTmp, nColor
-
- for n = 20 to ( 21 - nHeight ) step -1
- nCount = 0
-
- do while nCount < 4
- nTmp = Int( Rand() * 10 + 1 )
-
- if !alPosFilled( n, nTmp )
- alPosFilled( n, nTmp ) = .t.
- nCount = nCount + 1
-
- nColor = Int( Rand() * 7 + 1 )
-
- do case
- case nColor = 1
- @ n - 1, nTmp + 9 say "■" color g/g*
- case nColor = 2
- @ n - 1, nTmp + 9 say "■" color r+/g
- case nColor = 3
- @ n - 1, nTmp + 9 say "■" color w+/bg
- case nColor = 4
- @ n - 1, nTmp + 9 say "■" color r/gr*
- case nColor = 5
- @ n - 1, nTmp + 9 say "■" color br/b
- case nColor = 6
- @ n - 1, nTmp + 9 say "■" color n/r
- case nColor = 7
- @ n - 1, nTmp + 9 say "■" color br/br*
- endcase
- endif
- enddo
- endfor
-
- RETURN ( "" )
-
-
-
- FUNCTION _Restart
-
- lOk = .f.
- alPosFilled = .f.
- lRestarted = .t.
-
- if nScore > nHiScore
- nHiScore = nScore
- nHiLines = nLines
- nHiLevel = nLevel
- endif
-
- nScore = 0
- nLines = 0
- nLevel = nStartLevel
- nNewShape = Int( Rand( -1 ) * 7 + 1 )
- nNewShape = Int( Rand( -1 ) * 7 + 1 )
-
- store 0 to anShapeCnt, nShapeTot
-
- = _ShoLvl()
-
- @ 11, 02 fill to 17, 07 color w/w
- @ 19, 02 fill to 19, 07 color w/w
-
- @ 02, 02 say nHiScore picture "999999" color n+/w
- @ 05, 02 say nHiLines picture "999999" color n+/w
- @ 01, 28 say nHiLevel picture "9" color n+/w
- @ 04, 02 say nLines picture "999999" color bg+/w
-
- RETURN ( "" )
-
-
-
- FUNCTION _Right
-
- nCol = nCol + 1
-
- do ( "_IntSh" + cNewShape + Str( nOrientation, 1 ) )
-
- if _OvrLapd()
- nCol = nCol - 1
- else
- = _DelShp()
- = _Tmp2Shp()
-
- do ( "_ShoShp" + cNewShape )
- endif
-
- RETURN ( "" )
-
-
-
- FUNCTION _Rotate
-
- nOrientation = ;
- Iif( nOrientation = anOrientMax( nNewShape ), ;
- 1, ;
- nOrientation + 1 )
-
- do ( "_IntSh" + cNewShape + Str( nOrientation, 1 ) )
-
- if _OvrLapd()
- nOrientation = ;
- Iif( nOrientation = 1, ;
- anOrientMax( nNewShape ), ;
- nOrientation - 1 )
- else
- = _DelShp()
- = _Tmp2Shp()
-
- do ( "_ShoShp" + cNewShape )
- endif
-
- RETURN ( "" )
-
-
-
- FUNCTION _ShoHigh
-
- activate window wTetris
-
- if nScore > nHiScore
- nHiScore = nScore
- nHiLines = nLines
- nHiLevel = nLevel
- endif
-
- @ 00, 10 say " " color n/bg
- @ 01, 10 say " " color n/bg
- @ 02, 10 say " " color n/bg
- @ 03, 10 say " " color n/bg
- @ 04, 10 say "High Score" color n/bg
- @ 05, 10 say nHiScore picture " 999999" color w+/bg
- @ 06, 10 say " " color n/bg
- @ 07, 10 say " " color n/bg
- @ 08, 10 say " " color n/bg
- @ 09, 10 say "Lines " color n/bg
- @ 10, 10 say nHiLines picture " 999999" color w+/bg
- @ 11, 10 say " " color n/bg
- @ 12, 10 say " " color n/bg
- @ 13, 10 say " " color n/bg
- @ 14, 10 say "Level " color n/bg
- @ 15, 10 say nHiLevel picture " 9" color w+/bg
- @ 16, 10 say " " color n/bg
- @ 17, 10 say " " color n/bg
- @ 18, 10 say " " color n/bg
- @ 19, 10 say " " color n/bg
-
- = Inkey( 2 )
-
- = _Twinkle( 05, 11 )
- = _Twinkle( 10, 11 )
- = _Twinkle( 15, 11 )
-
- RETURN ( "" )
-
-
-
- FUNCTION _ShoLvl
-
- @ 00, 28 say nLevel picture "9" color bg+/w
-
- RETURN ( "" )
-
-
-
- PROCEDURE _ShoNxt1
- @ 7, 3 say "■■■" color g/g*
- @ 8, 3 say "■" color g/g*
- RETURN
-
- PROCEDURE _ShoNxt2
- @ 7, 3 say "■■■" color r+/g
- @ 8, 5 say "■" color r+/g
- RETURN
-
- PROCEDURE _ShoNxt3
- @ 7, 3 say "■■" color w+/bg
- @ 8, 3 say "■■" color w+/bg
- RETURN
-
- PROCEDURE _ShoNxt4
- @ 8, 3 say "■■■■" color r/gr*
- RETURN
-
- PROCEDURE _ShoNxt5
- @ 7, 4 say "■■" color br/b
- @ 8, 3 say "■■" color br/b
- RETURN
-
- PROCEDURE _ShoNxt6
- @ 7, 3 say "■■" color n/r
- @ 8, 4 say "■■" color n/r
- RETURN
-
- PROCEDURE _ShoNxt7
- @ 7, 3 say "■■■" color br/br*
- @ 8, 4 say "■" color br/br*
- RETURN
-
-
-
- PROCEDURE _ShoShp1
- private n
-
- for n = 1 to 4
- @ anShapeRow( n ) - 1, anShapeCol( n ) + 9 say "■" color g/g*
- endfor
- RETURN
-
- PROCEDURE _ShoShp2
- private n
-
- for n = 1 to 4
- @ anShapeRow( n ) - 1, anShapeCol( n ) + 9 say "■" color r+/g
- endfor
- RETURN
-
- PROCEDURE _ShoShp3
- private n
-
- for n = 1 to 4
- @ anShapeRow( n ) - 1, anShapeCol( n ) + 9 say "■" color w+/bg
- endfor
- RETURN
-
- PROCEDURE _ShoShp4
- private n
-
- for n = 1 to 4
- @ anShapeRow( n ) - 1, anShapeCol( n ) + 9 say "■" color r/gr*
- endfor
- RETURN
-
- PROCEDURE _ShoShp5
- private n
-
- for n = 1 to 4
- @ anShapeRow( n ) - 1, anShapeCol( n ) + 9 say "■" color br/b
- endfor
- RETURN
-
- PROCEDURE _ShoShp6
- private n
-
- for n = 1 to 4
- @ anShapeRow( n ) - 1, anShapeCol( n ) + 9 say "■" color n/r
- endfor
- RETURN
-
- PROCEDURE _ShoShp7
- private n
-
- for n = 1 to 4
- @ anShapeRow( n ) - 1, anShapeCol( n ) + 9 say "■" color br/br*
- endfor
- RETURN
-
-
-
- FUNCTION _TglNext
-
- lShowNext = !lShowNext
-
- if lShowNext
- hide window wNoNext
- @ 6, 2 say "X"
- else
- show window wNoNext
- @ 6, 2 say " "
- endif
-
- RETURN ( "" )
-
-
-
- FUNCTION _TglStat
-
- lShowStat = !lShowStat
-
- if lShowStat
- hide window wNoStat
- @ 10, 02 say "X"
- else
- show window wNoStat
- @ 10, 02 say " "
- endif
-
- RETURN ( "" )
-
-
-
- FUNCTION _Title
-
- private ;
- n, nDelay
-
- activate window wTetris
-
- declare acTitle( 20 )
-
- acTitle( 01 ) = " "
- acTitle( 02 ) = "╥─┐──────┐"
- acTitle( 03 ) = "╟─┘┌╥─┐o │"
- acTitle( 04 ) = "║╓╥┐║╥┐╥╓┐"
- acTitle( 05 ) = "║║╟┘║║ ║╙╖"
- acTitle( 06 ) = "╨╙╨ ╨╨ ╨└╜"
- acTitle( 07 ) = "└──v1.0──┘"
- acTitle( 08 ) = " "
- acTitle( 09 ) = " by "
- acTitle( 10 ) = " "
- acTitle( 11 ) = " Gerald "
- acTitle( 12 ) = " Garcia, "
- acTitle( 13 ) = " Jr. "
- acTitle( 14 ) = " "
- acTitle( 15 ) = " "
- acTitle( 16 ) = " (C) 1991 "
- acTitle( 17 ) = " "
- acTitle( 18 ) = "All Rights"
- acTitle( 19 ) = " Reserved "
- acTitle( 20 ) = " "
-
- for n = 10 to 1 step -1
- do case
- case n = 7
- @ n - 1, 10 say acTitle( n ) color w/n
- case Between( n, 4, 6 )
- @ n - 1, 10 say acTitle( n ) color bg+/n
- case n = 3
- @ n - 1, 10 say Left( acTitle( n ), 9 ) color bg+/n
- @ n - 1, 19 say Right( acTitle( n ), 1 ) color w/n
- case n = 2
- @ n - 1, 10 say Left( acTitle( n ), 3 ) color bg+/n
- @ n - 1, 13 say Right( acTitle( n ), 7 ) color w/n
- otherwise
- @ n - 1, 10 say acTitle( n ) color w+/n
- endcase
-
- do case
- case Between( 21 - n, 16, 19 )
- @ 20 - n, 10 say acTitle( 21 - n ) color w/n
- otherwise
- @ 20 - n, 10 say acTitle( 21 - n ) color w+/n
- endcase
-
- nDelay = Seconds() + 0.06
-
- do while Seconds() < nDelay
- enddo
- endfor
-
- = Inkey( 2 )
-
- = _Twinkle( 02, 17 )
-
- RETURN ( "" )
-
-
-
- FUNCTION _Tmp2Shp
-
- private n
-
- for n = 1 to 4
- anShapeRow( n ) = anTmpRow( n )
- anShapeCol( n ) = anTmpCol( n )
- endfor
-
- RETURN ( "" )
-
-
-
- FUNCTION _Twinkle
-
- parameters ;
- nRow, nCol
-
- private ;
- cTwinkle, n
-
- cTwinkle = "·∙"
-
- define window wTwinkle in window wTetris ;
- from nRow, nCol to nRow, nCol none ;
- color w+/n
-
- activate window wTwinkle
-
- for n = 1 to Len( cTwinkle )
- @ 00, 00 say SubStr( cTwinkle, n, 1 )
-
- nDelay = Seconds() + 0.075
-
- do while Seconds() < nDelay
- enddo
- endfor
-
- deactivate window wTwinkle
-
- RETURN ( "" )
-
-
-
- FUNCTION _Up
-
- nLevel = nLevel + Iif( nLevel < 9, 1, 0 )
-
- @ 00, 28 say nLevel picture "9" color bg+/w
-
- RETURN ( "" )