SHOW:
|
|
- or go back to the newest paste.
| 1 | tetris = [showgui tetris] | |
| 2 | append = [$arg1 = (concat (getalias $arg1) $arg2)] | |
| 3 | rndo = [at $arg1 (rnd (listlen $arg1))] | |
| 4 | ||
| 5 | - | _tetris_clearrows = [loop i 20 [[_tetris_row@i] = ""]] |
| 5 | + | _tetris_clearrows = [ |
| 6 | loop i 20 [ | |
| 7 | [_tetris_row@i] = "" | |
| 8 | ] | |
| 9 | ] | |
| 10 | ||
| 11 | _tetris_genrows = [ | |
| 12 | _tetris_clearrows | |
| 13 | looplist i $_tetris_static [ | |
| 14 | cond (< $i 10) [ | |
| 15 | append _tetris_row0 $i | |
| 16 | ] (< $i 100) [ | |
| 17 | append _tetris_row@(substr $i 0 1) (substr $i 1 1) | |
| 18 | ] (< $i 200) [ | |
| 19 | append _tetris_row@(substr $i 0 2) (substr $i 2 1) | |
| 20 | ] | |
| 21 | ] | |
| 22 | - | _tetris_active = $[_tetris_@_tetris_curblock] |
| 22 | + | |
| 23 | - | _tetris_nextblock = (rndo "i j l o s t z") |
| 23 | + | |
| 24 | _tetris_scorerows = [ | |
| 25 | local tmp1 tmp2 | |
| 26 | loop i 20 [ | |
| 27 | - | if (listlen $_tetris_active) [ |
| 27 | + | if (= (listlen $[_tetris_row@i]) 10) [ |
| 28 | _tetris_cleared = (+ $_tetris_cleared 1) // compute rows cleared | |
| 29 | _tetris_row@i = "" // clear full row | |
| 30 | - | looplist p $_tetris_active [ |
| 30 | + | |
| 31 | ] | |
| 32 | looplist z $_tetris_static [ | |
| 33 | //if (! (>< $z | |
| 34 | - | if $valid [_tetris_active = $newpos] arg3 |
| 34 | + | |
| 35 | ] | |
| 36 | ||
| 37 | _tetris_spawnblock = [ | |
| 38 | - | _tetris_i = "-4 -5 -6 -7" |
| 38 | + | |
| 39 | - | _tetris_j = "-14 -15 -16 -6" |
| 39 | + | _tetris_active = (at $[_tetris_@_tetris_curblock] 0) |
| 40 | - | _tetris_l = "-13 -14 -15 -3" |
| 40 | + | _tetris_rotation = $_tetris_active |
| 41 | - | _tetris_o = "-15 -16 -5 -6" |
| 41 | + | _tetris_nextblock = (? (rnd 100) (rndo "i j l o s t z") "b") |
| 42 | - | _tetris_s = "-15 -16 -4 -5" |
| 42 | + | |
| 43 | - | _tetris_t = "-15 -16 -17 -6" |
| 43 | + | |
| 44 | - | _tetris_z = "-15 -16 -6 -7" |
| 44 | + | |
| 45 | if (listlen $arg3) [ | |
| 46 | local newpos valid tmp | |
| 47 | valid = 1 | |
| 48 | looplist p $arg3 [ | |
| 49 | tmp = (+ $p $arg2) | |
| 50 | if (|| arg1 [> (indexof $_tetris_static $tmp) -1]) [valid = 0] [append newpos $tmp] | |
| 51 | ] | |
| 52 | - | _tetris_curblock = (rndo "i j l o s t z") |
| 52 | + | if $valid [_tetris_active = $newpos] arg4 |
| 53 | ] | |
| 54 | ] | |
| 55 | ||
| 56 | _tetris_i = ["-6 -7 -5 -4" "-5 -15 5 15" "5 7 6 4" "4 -16 -6 14"] | |
| 57 | _tetris_j = ["-16 -27 -17 -15" "-16 -26 -25 -6" "-16 -17 -15 -5" "-16 -26 -7 -6"] | |
| 58 | _tetris_l = ["-16 -17 -15 -7" "-16 -27 -26 -6" "-16 -25 -17 -15" "-16 -26 -6 -5"] | |
| 59 | _tetris_o = ["-15 -16 -5 -6"] | |
| 60 | _tetris_s = ["-16 -15 -7 -6" "-16 -26 -15 -5"] | |
| 61 | _tetris_t = ["-16 -26 -17 -15" " -16 -26 -15 -6" "-16 -17 -15 -6" "-16 -26 -17 -6"] | |
| 62 | _tetris_z = ["-16 -17 -6 -5" "-16 -26 -17 -7"] | |
| 63 | _tetris_b = ["-1 -2 -3 -4 -5 -6 -7 -8 -9 -10"] | |
| 64 | ||
| 65 | _tetris_static = "" // settled blocks | |
| 66 | _tetris_active = "" // moving block | |
| 67 | - | ? (> (indexof $_tetris_row@i $p) -1) ( |
| 67 | + | |
| 68 | - | at $_tetris_colors (listfind z $_tetris_colors [= (at $z 0) $tmp]) 1 |
| 68 | + | |
| 69 | - | ) "_" |
| 69 | + | _tetris_rotation = "" |
| 70 | _tetris_cleared = 0 | |
| 71 | _tetris_score = 0 | |
| 72 | _tetris_curblock = (rndo "i j l o s t z") | |
| 73 | _tetris_nextblock = $_tetris_curblock | |
| 74 | ||
| 75 | _tetris_clearrows | |
| 76 | ||
| 77 | newgui tetris [ | |
| 78 | guistayopen [ | |
| 79 | guilist [ | |
| 80 | - | _tetris_moveblock [> $tmp 199] 10 [ |
| 80 | + | |
| 81 | loop i 20 [ | |
| 82 | guilist [ | |
| 83 | - | append _tetris_colors [[@@(concat $i $_tetris_curblock)]] |
| 83 | + | |
| 84 | tmp = (concatword $i $p) | |
| 85 | guitext "" (concatword "tetris/" ( | |
| 86 | ? (> (listfind z $_tetris_active [= $z $tmp]) -1) $_tetris_curblock ( | |
| 87 | - | loop i 20 [ |
| 87 | + | ? (> (indexof $_tetris_row@i $p) -1) (substr ( |
| 88 | - | if (= (listlen $[_tetris_row@i]) 10) [ |
| 88 | + | at $_tetris_colors (listfind z $_tetris_colors [= (substr $z 1) $tmp]) |
| 89 | - | _tetris_cleared = (+ $_tetris_cleared 1) // compute rows cleared |
| 89 | + | ) 0 1) "_" |
| 90 | - | _tetris_row@i = "" // clear full row |
| 90 | + | |
| 91 | - | ] |
| 91 | + | |
| 92 | ] | |
| 93 | - | // continue with moving STATIC above a cleared row, below. work on scoring tech. |
| 93 | + | |
| 94 | ] | |
| 95 | ] | |
| 96 | guibar | |
| 97 | - | _tetris_moveblock [< (div $tmp 10) (div $p 10)] -1 |
| 97 | + | |
| 98 | guibutton "Spawn Block" _tetris_spawnblock | |
| 99 | guibutton "Move Down" [ | |
| 100 | - | _tetris_moveblock [> (div $tmp 10) (div $p 10)] 1 |
| 100 | + | _tetris_moveblock [> $tmp 199] 10 $_tetris_active [ |
| 101 | append _tetris_static $_tetris_active // move block coords to static | |
| 102 | - | |
| 102 | + | |
| 103 | - | |
| 103 | + | append _tetris_colors (concatword $_tetris_curblock $i) |
| 104 | ] | |
| 105 | _tetris_active = "" // clear active block | |
| 106 | _tetris_genrows // generate row hits | |
| 107 | _tetris_scorerows // clear scored rows and move blocks down | |
| 108 | ] | |
| 109 | ] | |
| 110 | guibutton "Move Left" [ | |
| 111 | _tetris_moveblock [< (div $tmp 10) (div $p 10)] -1 $_tetris_active | |
| 112 | ] | |
| 113 | guibutton "Move Right" [ | |
| 114 | _tetris_moveblock [> (div $tmp 10) (div $p 10)] 1 $_tetris_active | |
| 115 | ] | |
| 116 | guibutton "Rotate Right" [ | |
| 117 | cur = $_tetris_@_tetris_curblock | |
| 118 | _tetris_rotation = (at $cur (mod (+ (indexof $cur $_tetris_rotation) 1) (listlen $cur))) | |
| 119 | _tetris_moveblock [] (- (at $_tetris_active 0) (at $cur $_tetris_rotation 0)) $_tetris_rotation | |
| 120 | ||
| 121 | ] | |
| 122 | // | |
| 123 | ] | |
| 124 | ] | |
| 125 | ] | |
| 126 | ] |