Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tetris = [showgui tetris]
- append = [$arg1 = (concat (getalias $arg1) $arg2)]
- rndo = [at $arg1 (rnd (listlen $arg1))]
- _tetris_clearrows = [loop i 20 [[_tetris_row@i] = ""]]
- _tetris_genrows = [
- _tetris_clearrows
- looplist i $_tetris_static [
- cond (< $i 10) [
- append _tetris_row0 $i
- ] (< $i 100) [
- append _tetris_row@(substr $i 0 1) (substr $i 1 1)
- ] (< $i 200) [
- append _tetris_row@(substr $i 0 2) (substr $i 2 1)
- ]
- ]
- ]
- _tetris_spawnblock = [
- _tetris_curblock = $_tetris_nextblock
- _tetris_active = $[_tetris_@_tetris_curblock]
- _tetris_nextblock = (rndo "i j l o s t z")
- ]
- _tetris_moveblock = [
- if (listlen $_tetris_active) [
- local newpos valid tmp
- valid = 1
- looplist p $_tetris_active [
- tmp = (+ $p $arg2)
- if (|| arg1 [> (indexof $_tetris_static $tmp) -1]) [valid = 0] [append newpos $tmp]
- ]
- if $valid [_tetris_active = $newpos] arg3
- ]
- ]
- _tetris_i = "-4 -5 -6 -7"
- _tetris_j = "-14 -15 -16 -6"
- _tetris_l = "-13 -14 -15 -3"
- _tetris_o = "-15 -16 -5 -6"
- _tetris_s = "-15 -16 -4 -5"
- _tetris_t = "-15 -16 -17 -6"
- _tetris_z = "-15 -16 -6 -7"
- _tetris_static = "" // settled blocks
- _tetris_active = "" // moving block
- _tetris_colors = "" // colors of settled blocks
- _tetris_cleared = 0
- _tetris_score = 0
- _tetris_curblock = (rndo "i j l o s t z")
- _tetris_nextblock = $_tetris_curblock
- _tetris_clearrows
- newgui tetris [
- guistayopen [
- guilist [
- guilist [
- loop i 20 [
- guilist [
- loop p 10 [
- tmp = (concatword $i $p)
- guitext "" (concatword "tetris/" (
- ? (> (listfind z $_tetris_active [= $z $tmp]) -1) $_tetris_curblock (
- ? (> (indexof $_tetris_row@i $p) -1) (
- at $_tetris_colors (listfind z $_tetris_colors [= (at $z 0) $tmp]) 1
- ) "_"
- )
- ) ".png")
- ]
- ]
- ]
- ]
- guibar
- guilist [
- guibutton "Spawn Block" _tetris_spawnblock
- guibutton "Move Down" [
- _tetris_moveblock [> $tmp 199] 10 [
- append _tetris_static $_tetris_active // move block coords to static
- looplist i $_tetris_active [
- append _tetris_colors [[@@(concat $i $_tetris_curblock)]]
- ]
- _tetris_active = "" // clear active block
- _tetris_genrows // generate row hits
- loop i 20 [
- if (= (listlen $[_tetris_row@i]) 10) [
- _tetris_cleared = (+ $_tetris_cleared 1) // compute rows cleared
- _tetris_row@i = "" // clear full row
- ]
- ]
- // continue with moving STATIC above a cleared row, below. work on scoring tech.
- ]
- ]
- guibutton "Move Left" [
- _tetris_moveblock [< (div $tmp 10) (div $p 10)] -1
- ]
- guibutton "Move Right" [
- _tetris_moveblock [> (div $tmp 10) (div $p 10)] 1
- ]
- ]
- ]
- ]
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement