Advertisement
SReject

Tetris [Updated]

Apr 18th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 17.37 KB | None | 0 0
  1. alias Tetris {
  2.   Tetris:Cleanup
  3.   window -Bdfhnpl20 +d @Tetris:Buffer -1 -1 376 454
  4.   if (!$isfile($scriptdirTetris.bmp)) { Tetris:MakeSprites }
  5.   drawpic -c @Tetris:Buffer 0 0 $qt($scriptdirTetris.bmp)
  6.   var %x 1 | while (%x < 26) { aline -l @Tetris:Buffer 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | inc %x }
  7.   window -nBdfpk0C +d @Tetris -1 -1 360 454
  8.   set %Tetris:State Play
  9.   Tetris:Shape
  10.   window -a @Tetris
  11.   Tetris:Play
  12. }
  13.  
  14. alias -l Tetris:Color {
  15.   var %r, %g, %b
  16.   if ($0 == 4) {
  17.     return $rgb($iif($calc($1 * $4) > 255, 255, $v1), $iif($calc($2 * $4) > 255, 255, $v1), $iif($calc($3 * $4) > 255, 255, $v1))
  18.   }
  19.   tokenize 44 $rgb($1) $+ , $+ $rgb($2)
  20.   return $rgb($iif($calc(($1 + $4) / 2) > 255, 255, $floor($v1)), $iif($calc(($2 + $5) / 2) > 255, 255, $floor($v1)), $iif($calc(($3 + $6) / 2) > 255, 255, $floor($v1)))
  21. }
  22.  
  23. alias -l Tetris:Cleanup {
  24.   .TimerTetris Off
  25.   unset %Tetris:*
  26.   close -@ @Tetris*
  27. }
  28. alias -l Tetris:Shape {
  29.   :loop
  30.   set -e %Tetris:Shape %Tetris:nShape
  31.   if ($r(1,7) == 1) { set %Tetris:nShape r 1 0 8 -1 8 -2 8 -3 8 }
  32.   if ($v1 == 2) { set %Tetris:nShape g 1 0 8 0 7 -1 7 -1 8 }
  33.   if ($v1 == 3) { set %Tetris:nShape b 1 0 8 0 7 -1 8 -1 9 }
  34.   if ($v1 == 4) { set %Tetris:nShape o 1 0 8 0 9 -1 7 -1 8 }
  35.   if ($v1 == 5) { set %Tetris:nShape y 1 0 8 -1 8 0 9 0 7 }
  36.   if ($v1 == 6) { set %Tetris:nShape p 1 0 8 -1 8 -2 8 -2 7 }
  37.   if ($v1 == 7) { set %Tetris:nShape t 1 0 8 -1 8 -2 8 -2 9 }
  38.   if (!%Tetris:Shape) {
  39.     set -e %Tetris:Shape %Tetris:nShape
  40.     goto loop
  41.   }
  42.   Tetris:Land
  43. }
  44. alias -l Tetris:Land {
  45.   tokenize 32 %Tetris:Shape
  46.   while ($3 < 25) && (!$gettok($line(@Tetris:Buffer,$calc($3 +1),1),$4,32) && !$gettok($line(@Tetris:Buffer,$calc($5 +1),1),$6,32) && !$gettok($line(@Tetris:Buffer,$calc($7 +1),1),$8,32) && !$gettok($line(@Tetris:Buffer,$calc($9 +1),1),$10,32)) {
  47.     tokenize 32 $1-2 $calc($3 + 1) $4 $calc($5 +1) $6 $calc($7 + 1) $8 $calc($9 + 1) $10
  48.   }
  49.   set %Tetris:Land $1-
  50. }
  51. alias -l Tetris:Redraw {
  52.   if (!$window(@Tetris) || !$window(@Tetris:Buffer)) {
  53.     Tetris:Cleanup
  54.   }
  55.   drawcopy -n @Tetris:Buffer 0 0 360 454 @Tetris 0 0
  56.   var %x = 25, %c
  57.   while ((%x && $line(@Tetris:Buffer,%x,1) != 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) {
  58.     tokenize 32 $v1
  59.     var %y = $calc((%x -1) * 17 + 23)
  60.     if ($1) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$1) - 1)) 16 16 @Tetris 7 %y }
  61.     if ($2) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$2) - 1)) 16 16 @Tetris 24 %y }
  62.     if ($3) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$3) - 1)) 16 16 @Tetris 41 %y }
  63.     if ($4) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$4) - 1)) 16 16 @Tetris 58 %y }
  64.     if ($5) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$5) - 1)) 16 16 @Tetris 75 %y }
  65.     if ($6) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$6) - 1)) 16 16 @Tetris 92 %y }
  66.     if ($7) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$7) - 1)) 16 16 @Tetris 109 %y }
  67.     if ($8) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$8) - 1)) 16 16 @Tetris 126 %y }
  68.     if ($9) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$9) - 1)) 16 16 @Tetris 143 %y }
  69.     if ($10) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$10) - 1)) 16 16 @Tetris 160 %y }
  70.     if ($11) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$11) - 1)) 16 16 @Tetris 177 %y }
  71.     if ($12) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$12) - 1)) 16 16 @Tetris 194 %y }
  72.     if ($13) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$13) - 1)) 16 16 @Tetris 211 %y }
  73.     if ($14) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$14) - 1)) 16 16 @Tetris 228 %y }
  74.     if ($15) { drawcopy -n @Tetris:Buffer 360 $calc(16 * ($pos(rgboypt,$15) - 1)) 16 16 @Tetris 245 %y }
  75.     dec %x  
  76.   }
  77.   tokenize 32 %Tetris:nShape
  78.   %c = $calc(16 * ($pos(rgboypt,$1) - 1))
  79.   drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(($4 -8)*17+294) $calc(($3 +3)*17+371)
  80.   drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(($6 -8)*17+294) $calc(($5 +3)*17+371)
  81.   drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(($8 -8)*17+294) $calc(($7 +3)*17+371)
  82.   drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(($10 -8)*17+294) $calc(($9 +3)*17+371)
  83.   var %lv = $floor($calc($iif(%Tetris:Lines,$v1,0) / 10))
  84.   var %ln = $iif($calc(10 - %Tetris:Lines % 10),$v1,10)
  85.   var %sc = $iif(%Tetris:Score,$v1,0)  
  86.   drawtext -rno @Tetris $rgb(128,128,128) Tahoma 12 $calc(348 - $width(%lv,Tahoma,12,1)) 50 %lv
  87.   drawtext -rno @Tetris $rgb(128,128,128) Tahoma 12 $calc(348 - $width(%ln,Tahoma,12,1)) 80 %ln
  88.   drawtext -rno @Tetris $rgb(128,128,128) Tahoma 12 $calc(348 - $width(%sc,Tahoma,12,1)) 110 %sc
  89.   if (%Tetris:Land && !%TetrisHideGhost) {
  90.     tokenize 32 %Tetris:Land
  91.     var %c = $gettok(255 65280 16711680 33023 65535 16711935 16776960,$pos(rgboypt,$1),32)      
  92.     if ($3 > 0) drawrect -rn @Tetris %c 2 $calc($4 *17 - 10) $calc($3 *17 + 6) 16 16
  93.     if ($5 > 0) drawrect -rn @Tetris %c 2 $calc($6 *17 - 10) $calc($5 *17 + 6) 16 16
  94.     if ($7 > 0) drawrect -rn @Tetris %c 2 $calc($8 *17 - 10) $calc($7 *17 + 6) 16 16
  95.     if ($9 > 0) drawrect -rn @Tetris %c 2 $calc($10 *17 - 10) $calc($9 *17 + 6) 16 16
  96.   }
  97.   tokenize 32 %Tetris:Shape
  98.   %c = $calc(16 * ($pos(rgboypt,$1) - 1))
  99.   if ($3 > 0) drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(-10 + $4 * 17) $calc($3 * 17 + 6)
  100.   if ($5 > 0) drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(-10 + $6 * 17) $calc($5 * 17 + 6)
  101.   if ($7 > 0) drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(-10 + $8 * 17) $calc($7 * 17 + 6)
  102.   if ($9 > 0) drawcopy -n @Tetris:Buffer 360 %c 16 16 @Tetris $calc(-10 + $10 * 17) $calc($9 * 17 + 6)
  103.   if (%Tetris:State == GAMEOVER) || (%Tetris:State == PAUSED) {
  104.     var %m = $v1
  105.     drawrect -rfn @Tetris $rgb(96,96,96) 1 34 185 200 100
  106.     drawrect -rn @Tetris $rgb(192,192,192) 1 34 185 200 100
  107.     drawtext -rno @Tetris 0 "Courier New" 40 $calc(34 + (200 - $width(%m,Courier New,40,1)) /2) $calc(185 + (100 - $height(%m,Courier New,40)) / 2) %m
  108.   }
  109.   drawdot @Tetris
  110. }
  111. alias Tetris:MakeSprites {
  112.   if ($isfile($scriptdirTetris.bmp)) { .remove $qt($scriptdirTetris.bmp) }
  113.   var %x = 1, %c = 255,000,000 000,255,000 000,000,255 255,128,000 255,255,000 255,000,255 000,255,255
  114.   if ($window(@Tetris:MakeSprites)) { window -c $v1 }
  115.   window -Bdfhnp +d @Tetris:MakeSprites -1 -1 376 454
  116.   drawrect -nfr @Tetris:MakeSprites 0 1 0 0 360 454
  117.   drawrect -nfr @Tetris:MakeSprites $rgb(128,128,128) 1 1 1 358 15
  118.   drawrect -nrf @Tetris:MakeSprites $rgb(32,32,32) 1 7 23 254 424 268 39 85 90
  119.   drawrect -nfr @Tetris:MakeSprites $rgb(96,96,96) 1 268 346 85 15 268 23 85 15
  120.   drawrect -nr @Tetris:MakeSprites $rgb(192,192,192) 1 0 0 360 454 6 22 256 426 267 345 87 103 267 22 86 108
  121.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 0 16 360 16
  122.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 267 361 353 361
  123.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 267 38 353 38
  124.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 5 12 5 3 14 3 13 4 6 4 6 11 5 12
  125.   drawline -nr @Tetris:MakeSprites $rgb(64,64,64) 1 15 4 15 13 6 13 7 12 14 12 14 5 15 4
  126.   drawrect -nr @Tetris:MakeSprites $rgb(192,192,192) 1 55 2 10 2 55 12 6 2 57 4 2 8 63 4 2 2 62 8 2 6 64 12 2 2 67 2 6 2 67 12 6 2 69 4 2 8 75 4 2 2 83 4 2 2 75 10 2 2 83 10 2 2 75 2 10 2 75 12 10 2 331 10 8 2 19 2 2 4 27 2 2 4 21 2 6 2 23 5 2 7 21 12 6 2 31 2 10 2 31 12 10 2 33 4 2 8 36 7 2 2 39 4 2 2 39 10 2 2 43 2 2 4 51 2 2 4 45 2 6 2 47 5 2 7 45 12 6 2
  127.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 63 5 58 10 58 11 64 5 63 5
  128.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 75 5 83 10 84 10 76 5 75 5
  129.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 345 5 351 11 352 11 346 5 345 5
  130.   drawline -nr @Tetris:MakeSprites $rgb(192,192,192) 1 351 5 345 11 346 11 352 5 351 5
  131.   while (%x < 8) {
  132.     tokenize 44 $gettok(%c,%x,32)
  133.     var %nY = $calc(2 + 16 * (%x - 1)), %nY-2 = $calc(%nY -2), %nY-1 = $calc(%nY -1), %nY+1 = $calc(%nY +11), %nY+2 = $calc(%nY +12), %nY+3 = $calc(%nY +13)
  134.     var %tc = $Tetris:Color($1,$2,$3, 1.75)
  135.     var %bc = $Tetris:Color($1,$2,$3, .50)
  136.     var %sc = $Tetris:Color($1,$2,$3, .75)
  137.     drawline -rn @Tetris:MakeSprites %tc 1 362 %nY-1 373 %nY-1 374 %nY-2 361 %nY-2 362 %nY-1
  138.     drawline -rn @Tetris:MakeSprites %bc 1 362 %nY+2 373 %nY+2 374 %nY+3 361 %nY+3 362 %nY+2
  139.     drawline -rn @Tetris:MakeSprites %sc 1 361 %nY 361 %nY+1 360 %nY+2 360 %nY-1 361 %nY
  140.     drawline -rn @Tetris:MakeSprites %sc 1 374 %nY 374 %nY+1 375 %nY+2 375 %nY-1 374 %nY
  141.     drawdot -rn @Tetris:MakeSprites $Tetris:Color(%tc,%sc) 1 360 %nY-2 361 %nY-1 374 %nY-1 375 %nY-2
  142.     drawdot -rn @Tetris:MakeSprites $Tetris:Color(%bc,%sc) 1 360 %nY+3 361 %nY+2 374 %nY+2 375 %nY+3
  143.     drawrect -fnr @Tetris:MakeSprites $rgb($1,$2,$3) 1 362 %nY 12 12
  144.     inc %x
  145.   }
  146.   %x = 7 | while (%x < 41) { drawdot -rn @Tetris:MakeSprites 4210752 1 %x $iif($calc(%x % 2),56,39) | inc %x }
  147.   %x = 23 | while (%x < 57) { drawdot -rn @Tetris:MakeSprites 4210752 1 $iif($calc(%x % 2),40,23) %x | inc %x }
  148.   %x = 1 | while (%x < 12) { drawcopy -n @Tetris:MakeSprites 7 23 34 $iif(%x == 1,34,50) @Tetris:MakeSprites 7 $calc(23 + 34 * %x) | inc %x }
  149.   %x = 1 | while (%x < 7) { drawcopy -n @Tetris:MakeSprites 7 23 $iif(%x == 1,34,50) 424 @Tetris:MakeSprites $calc(7 + 34 * %x) 23 | inc %x }
  150.   drawcopy @Tetris:MakeSprites 15 31 85 85 @Tetris:MakeSprites 268 362
  151.   drawtext -onr @Tetris:MakeSprites $rgb(192,192,192) Tahoma 12 271 23 Stats
  152.   drawtext -onr @Tetris:MakeSprites $rgb(128,128,128) Tahoma 12 274 39 Level:
  153.   drawtext -onr @Tetris:MakeSprites $rgb(128,128,128) Tahoma 12 274 69 Lines Left:
  154.   drawtext -onr @Tetris:MakeSprites $rgb(128,128,128) Tahoma 12 274 99 Score:
  155.   drawtext -onr @Tetris:MakeSprites $rgb(192,192,192) Tahoma 12 271 346 Next
  156.   drawdot @Tetris:MakeSprites
  157.   drawsave @Tetris:MakeSprites $qt($scriptdirTetris.bmp)
  158.   :error
  159.   if ($window(@Tetris:MakeSprites)) {
  160.     window -c @Tetris:MakeSprites
  161.   }
  162. }
  163.  
  164.  
  165.  
  166.  
  167. on *:CLOSE:@Tetris,@Tetris:{ Tetris:Cleanup }
  168. alias Tetris:Play {
  169.   if ($window(@Tetris) && $window(@Tetris:Buffer)) {
  170.     ;if (!$appactive) || ($window(@Tetris) != $active) { set %Tetris:State PAUSED }
  171.     if (%Tetris:State == Play) {
  172.       :reCheck
  173.       tokenize 32 %Tetris:Shape
  174.       var %s, %sL, %sP, %nL, %x = 3, %ok, %nShape $1-2
  175.       while (%x < 11) {
  176.         var %sL = $(,$ $+ %x), %sP = $(,$ $+ $calc(%x +1)), %nL = $calc(%sL +1)
  177.         if (%sL == 0) && ($gettok($line(@Tetris:Buffer,1,1),%sP,32) != 0) { set %Tetris:State GAMEOVER | break }
  178.         elseif (%sL == 25) || (%sL isnum 0-24 && $gettok($line(@Tetris:Buffer,%nL,1),%sP,32) != 0) { break }
  179.         else { %nShape = %nShape %nL %sP }
  180.         inc %x 2
  181.       }
  182.       if (%Tetris:State == PLAY) {
  183.         if ($numtok(%nShape,32) != 10) || ($v1 == 10 && 25 isin %nShape) {
  184.           if ($numtok(%nShape,32) == 10 && 25 isin %nShape) { tokenize 32 $v2 }
  185.           if ($3 < 1 || $4 < 1 || $7 < 1 || $9 < 1) { %Tetris:State = GAMEOVER | goto end }
  186.           rline -l @Tetris:Buffer $3 $puttok($line(@Tetris:Buffer,$3,1),$1,$4,32)
  187.           rline -l @Tetris:Buffer $5 $puttok($line(@Tetris:Buffer,$5,1),$1,$6,32)
  188.           rline -l @Tetris:Buffer $7 $puttok($line(@Tetris:Buffer,$7,1),$1,$8,32)
  189.           rline -l @Tetris:Buffer $9 $puttok($line(@Tetris:Buffer,$9,1),$1,$10,32)
  190.           var %lns
  191.           while ($fline(@Tetris:Buffer,/^([^0](?:\x20|$)){15}$/,1,3)) {
  192.             dline -l @Tetris:Buffer $v1
  193.             iline -l @Tetris:Buffer 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  194.             inc %lns
  195.           }
  196.           if (%lns) {
  197.             inc -e %Tetris:Lines %lns
  198.             inc -e %Tetris:Score $floor($calc(($floor($calc(%Tetris:Lines / 10)) +1) *10 * (1.2^ %lns)))
  199.           }
  200.           Tetris:Shape
  201.           goto reCheck
  202.         }
  203.         else {  
  204.           set %Tetris:Shape %nShape
  205.           tokenize 32 %nShape
  206.           if ($3 < 1 && $5 < 1 && $7 < 1 && $8 < 1) { goto reCheck }
  207.         }
  208.       }
  209.     }
  210.     :end
  211.     Tetris:Redraw
  212.     .timerTetris -h 1 $iif($iif(%Tetris:State != Play,0,$floor($calc(%Tetris:Lines / 10))) > 19,50,$floor($calc(50 + 1.435 ^(20 - $v1)))) Tetris:Play
  213.   }
  214.   else {
  215.     Tetris:Cleanup
  216.   }
  217. }
  218.  
  219.  
  220.  
  221.  
  222. Menu @Tetris {
  223.   $iif(!%TetrisHideGhost,$style(1)) Show Ghosts:{ set %TetrisHideGhost $iif(%TetrisHideGhost,$false,$true) | Tetris:Redraw }
  224.   Restart:{ Tetris }
  225.   -
  226.   Close:{ Tetris:Cleanup }
  227. }
  228. Menu @Tetris {
  229.   sclick:{
  230.     if (%Tetris:State == PAUSED) {
  231.       set -e %Tetris:State PLAY
  232.       Tetris:Play
  233.     }
  234.     elseif ($inrect($mouse.x,$Mouse.y,329,3,12,11)) { set %Tetris:State PAUSED | window -n @Tetris }
  235.     elseif ($inrect($mouse.x,$mouse.y,344,3,12,11)) { Tetris:Cleanup }
  236.     elseif (%Tetris:State == PLAY) { set -e %Tetris:State PAUSED | Tetris:Redraw }
  237.     elseif (%Tetris:State == GAMEOVER) { Tetris }
  238.   }
  239. }
  240.  
  241.  
  242. on *:KEYDOWN:@Tetris:*:{
  243.   if (!$window(@Tetris:Buffer)) { Tetris:Cleanup }
  244.   elseif (%Tetris:State == GAMEOVER) { Tetris }
  245.   elseif (%Tetris:State == PAUSED) { set -e %Tetris:State PLAY | Tetris:Redraw }
  246.   elseif (%Tetris:State == PLAY) {
  247.     if ($keyval == 32) {
  248.       tokenize 32 %Tetris:Land
  249.       set -e %Tetris:Shape $1-
  250.       Tetris:Play
  251.     }
  252.     elseif ($keyval == 40 || $keyval == 100) && (%Tetris:Shape != %Tetris:Land) {
  253.       tokenize 32 $v1
  254.       set %Tetris:Shape $1-2 $calc($3 +1) $4 $calc($5 + 1) $6 $calc($7 +1) $8 $calc($9 +1) $10
  255.       Tetris:Redraw
  256.     }
  257.     elseif ($istok(37 39 97 100,$Keyval,32)) {
  258.       tokenize 32 %Tetris:Shape
  259.       var %n = $iif($keyval isin 3797,-,+), %n1 = $calc($4 %n 1), %n2 = $calc($6 %n 1), %n3 = $calc($8 %n 1), %n4 = $calc($10 %n 1)
  260.       if (%n1 !isnum 1-15 || %n2 !isnum 1-15 || %n3 !isnum 1-15 || %n4 !isnum 1-15) { return }
  261.       if ($gettok($line(@Tetris:Buffer,$3,1),%n1,32)) { return }
  262.       if ($gettok($line(@Tetris:Buffer,$5,1),%n2,32)) { return }
  263.       if ($gettok($line(@Tetris:Buffer,$7,1),%n3,32)) { return }
  264.       if ($gettok($line(@Tetris:Buffer,$9,1),%n4,32)) { return }
  265.       set %Tetris:Shape $1-3 %n1 $5 %n2 $7 %n3 $9 %n4
  266.       Tetris:Land
  267.       Tetris:Redraw
  268.     }
  269.     elseif ($keyval == 38 || $keyval == 119) {
  270.       tokenize 32 %Tetris:Shape
  271.       var %sL = $3
  272.       var %sP = $4
  273.       var %nShape
  274.       if (!$regex($1,/^[rboypt]$/)) { return }
  275.       elseif ($1 == r) {
  276.         if ($2 == 1) && ($tetris:Check(%sL %sP  %sL $calc(%sP +1) %sL $calc(%sP +2) %sL $calc(%sP -1))) { %nShape = $1 2 $v1 }
  277.         elseif ($2 == 2) && ($tetris:Check(%sL %sP $calc(%sL -1) %sP $calc(%sL -2) %sP $calc(%sL -3) %sP)) { %nShape = $1 1 $v1 }
  278.         else { return }
  279.       }
  280.       elseif ($1 == b) {
  281.         if ($2 == 1) && ($tetris:Check(%sL %sP $calc(%sL -1) %sp $calc(%sL -1) $calc(%sp -1) $calc(%sL -2) $calc(%sP -1))) { %nShape = $1 2 $v1 }
  282.         elseif ($2 == 2) && ($tetris:Check(%sL %sp %sL $calc(%sP -1) $calc(%sL -1) %sp $calc(%sL -1) $calc(%sp +1))) { %nShape = $1 1 $v1 }
  283.         else { return }
  284.       }
  285.       elseif ($1 == o) {
  286.         if ($2 == 1) && ($tetris:Check(%sL %sP, $calc(%sL -1) %sp,$calc(%sL -1) $calc(%sp +1), $calc(%sL -2) $calc(%sP +1))) { %nShape = $1 2 $v1 }
  287.         elseif ($2 == 2) && ($tetris:Check( %sL %sP, %sL $calc(%sP +1), $calc(%sL -1) %sp, $calc(%sL -1) $calc(%sp -1))) { %nShape = $1 1 $v1 }
  288.         else { return }
  289.       }
  290.       elseif ($1 == y) {
  291.         if ($2 == 1) && ($Tetris:Check($calc(%sL -2) %sP $calc(%sL -1) $calc(%sP +1))) { %nShape = $1 2 $3-6 $v1 }
  292.         elseif ($2 == 2) && ($Tetris:Check($calc(%sL -1) $calc(%sP -1) $calc(%sL -1) $calc(%sp +1))) { %nShape = $1 3 $3-6 $v1 }
  293.         elseif ($2 == 3) && ($Tetris:Check($calc(%sL -2) %sp $calc(%sL -1) $calc(%sp -1))) { %nShape = $1 4 $3-6 $v1 }
  294.         elseif ($2 == 4) && ($tetris:Check(%sl $calc(%sP -1) %sL $calc(%sP +1))) { %nShape = $1 1 $3-6 $v1 }
  295.         else { return }
  296.       }
  297.       elseif ($1 == p) {
  298.         if ($2 == 1) && ($Tetris:Check(%sL $calc(%sP -1) %sL $calc(%sP +1) $calc(%sL -1) $calc(%sP +1))) { %nShape = $1 2 $3-4 $v1 }
  299.         elseif ($2 == 2) && ($Tetris:Check(%sL $calc(%sp +1) $calc(%sL -1) %sp $calc(%sL -2) %sp)) { %nShape = $1 3 $3-4 $v1 }
  300.         elseif ($2 == 3) && ($Tetris:Check(%sL $calc(%sp -1) $calc(%sl -1) $calc(%sp -1) $calc(%sL -1) %sp,$calc(%sL -1) $calc(%sP +1))) { %nShape = $1 4 $v1 }
  301.         elseif ($2 == 4) && ($Tetris:Check(%sL $calc(%sp +1) $calc(%sL -1) $calc(%sp +1) $calc(%sL -2) $calc(%sP +1)  $calc(%sL -2) %sP)) { %nShape = $1 1 $v1 }
  302.         else { return }
  303.       }
  304.       elseif ($1 == t) {
  305.         if ($2 == 1) && ($Tetris:Check(%sL $calc(%sP +1) $calc(%sL -1) $calc(%sP +1) $calc(%sL -1) %sp $calc(%sL -1) $calc(%sP -1))) { %nShape = $1 2 $v1 }
  306.         elseif ($2 == 2) && ($Tetris:Check(%sL $calc(%sp -1) %sL $calc(%sp -2) $calc(%sL -1) $calc(%sP -1) $calc(%sL -2) $calc(%sP -1))) { %nShape = $1 3 $v1 }
  307.         elseif ($2 == 3) && ($Tetris:Check(%sL $calc(%sP +1) %sL $calc(%sP -1) $calc(%sl -1) $calc(%sP -1))) { %nShape = $1 4 $3-4 $v1 }
  308.         elseif ($2 == 4) && ($Tetris:Check($calc(%sL -1) %sp $calc(%sL -2) %sp  $calc(%sL -2) $calc(%sP +1))) { %nShape = $1 1 $3-4 $v1 }
  309.         else { return }
  310.       }
  311.       set %Tetris:Shape %nShape
  312.       Tetris:Land
  313.       Tetris:Redraw
  314.     }
  315.   }
  316. }
  317.  
  318. alias -l Tetris:Check {
  319.   tokenize 32 $1-
  320.   var %x = 1, %r
  321.   while (%x < $0) {
  322.     var %sL = $(,$ $+ %x)
  323.     var %sP = $(,$ $+ $calc(%x +1))
  324.     if (%sL > 25) || (%sP !isnum 1-15) || ($gettok($line(@Tetris:Buffer,%sL,1),%sP,32)) {
  325.       return
  326.     }
  327.     %r = %r %sL %sP
  328.     inc %x 2
  329.   }
  330.   return %r
  331. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement