Advertisement
RaZgRiZ

CS Tetris WIP1

Aug 28th, 2012
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.82 KB | None | 0 0
  1. tetris = [showgui tetris]
  2. append = [$arg1 = (concat (getalias $arg1) $arg2)]
  3.  
  4. _tetris_clearrows = [
  5.     loop i 20 [[_tetris_row@i] = ""]
  6. ]
  7.  
  8. _tetris_genrows = [
  9.     _tetris_clearrows
  10.     looplist i $_tetris_static [
  11.         cond (< $i 10) [
  12.             append _tetris_row0 $i
  13.         ] (< $i 100) [
  14.             append _tetris_row@(substr $i 0 1) (substr $i 1 1)
  15.         ] (< $i 200) [
  16.             append _tetris_row@(substr $i 0 2) (substr $i 2 1)
  17.         ]
  18.     ]
  19. ]
  20.  
  21. _tetris_i = "-4 -5 -6 -7"
  22. _tetris_j = "-14 -15 -16 -6"
  23. _tetris_l = "-13 -14 -15 -3"
  24. _tetris_o = "-15 -16 -5 -6"
  25. _tetris_s = "-15 -16 -4 -5"
  26. _tetris_t = "-15 -16 -17 -6"
  27. _tetris_z = "-14 -15 -5 -6"
  28.  
  29. _tetris_static = "" // coords that have settled down
  30. _tetris_active = "" // active block coords
  31. _tetris_newpos = "" // coords used for boundary measurements
  32.  
  33. _tetris_valid   = 1
  34. _tetris_cleared = 0
  35.  
  36. _tetris_clearrows
  37.  
  38. // TEMP STUFF //
  39. test = [say STATIC: $_tetris_static / ACTIVE: $_tetris_active / NEWPOS: $_tetris_newpos]
  40. guicondbutton = [
  41.     guibutton (concatword (? $arg1 $arg2 $arg3) $arg4) (
  42.         ? $arg1 $arg5 (? (= $arg6 1) $arg5 $arg6)
  43.     ) (? $arg1 $arg7 (? (= $arg8 1) $arg7 $arg8))
  44. ]
  45. rndo = [at $arg1 (rnd (listlen $arg1))]
  46. // TEMP STUFF //
  47.  
  48. newgui tetris [
  49.     guistayopen [
  50.         guilist [
  51.             guilist [
  52.                 loop i 20 [
  53.                     guilist [
  54.                         loop p 10 [
  55.                             guicondbutton (
  56.                                 || [> (listfind z $_tetris_active [= $z (concatword $i $p)]) -1] [
  57.                                     > (indexof $_tetris_row@i $p) -1
  58.                                 ]
  59.                             ) "" "" "" [
  60.                                 _tetris_row@i = (listdel $_tetris_row@i @p)
  61.                             ] [
  62.                                 append _tetris_row@i @p
  63.                             ] "radio_on" "radio_off"
  64.                         ]
  65.                     ]
  66.                 ]
  67.             ]
  68.             guistrut 2
  69.             guilist [
  70.                 guibutton "Spawn Block" [
  71.                     _tetris_active = $_tetris_@(rndo "i j l o s t z") // spawn random block
  72.                 ]
  73.                 guibutton "Move Down" [
  74.                     if (listlen $_tetris_active) [
  75.                         _tetris_newpos = ""
  76.                         _tetris_valid = 1
  77.                         _tetris_cleared = 0
  78.                         //-----------------------
  79.                         looplist p $_tetris_active [ // calculate new coords
  80.                             append _tetris_newpos (+ $p 10)
  81.                         ]
  82.                         looplist i $_tetris_newpos [ // check move-down conditions
  83.                             if (|| [> $i 199] [> (indexof $_tetris_static $i) -1]) [_tetris_valid = 0]
  84.                         ]
  85.                         if $_tetris_valid [_tetris_active = $_tetris_newpos] [ // move block to new coords
  86.                             _tetris_static = $_tetris_active // move block coords to static
  87.                             _tetris_active = ""              // clear active block
  88.                             _tetris_genrows                  // generate row hits
  89.                             loop i 20 [
  90.                                 if (= (listlen $[_tetris_row@i]) 10) [
  91.                                     _tetris_cleared = (+ $_tetris_cleared 1) // compute rows cleared
  92.                                     _tetris_row@i = ""                       // clear full row
  93.                                 ]
  94.                             ]
  95.                             // continue with moving STATIC above a cleared row, below. work on scoring tech.
  96.                            
  97.                         ]
  98.                     ]
  99.             ]
  100.             ]
  101.         ]
  102.     ]
  103. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement