1 ! Copyright (C) 2006, 2007, 2008 Alex Chapman
2 ! See https://factorcode.org/license.txt for BSD license.
4 USING: colors math namespaces random sequences ;
8 TUPLE: tetromino states color ;
10 C: <tetromino> tetromino
17 { 0 0 } { 1 0 } { 2 0 } { 3 0 }
28 { 0 1 } { 1 1 } { 2 1 }
34 { 0 0 } { 1 0 } { 2 0 }
48 { { 0 0 } { 1 0 } { 2 0 }
56 { 0 1 } { 1 1 } { 2 1 }
65 { { 0 0 } { 1 0 } { 2 0 }
73 { 0 1 } { 1 1 } { 2 1 }
102 } [ first2 <tetromino> ] map tetrominoes set-global
104 : random-tetromino ( -- tetromino )
105 tetrominoes get random ;
107 : blocks-max ( blocks quot -- max )
108 map maximum 1 + ; inline
110 : blocks-width ( blocks -- width )
111 [ first ] blocks-max ;
113 : blocks-height ( blocks -- height )
114 [ second ] blocks-max ;