3 blockdata.pir - a tetris block data class
7 # create a new random block
8 data = _BlockData::new( -1 )
10 # rotate the data clockwise
11 _BlockData::rotate( data, 1 )
15 .namespace ["Tetris::BlockData"]
18 $P0 = get_class "Tetris::BlockData"
19 unless null $P0 goto END
20 newclass $P0, "Tetris::BlockData"
21 addattribute $P0, "data"
29 =item blockdata."rotate"( dir )
31 Changes the the C<block data> in a way to make
32 the block look rotated.
36 =item parameter C<dir>
40 -1 = rotate counterclockwise
44 This method returns the old data representation.
48 .sub rotateData :method
58 getattribute olddata, self, 'data'
59 olddata = clone olddata
72 if val != +1 goto WAY2
93 if x >= size goto yLOOP
99 =item rows = blockdata."vfree"()
101 Checks how many free rows exist at the top edge
102 of block represented by this block data.
104 Returns the number of free rows.
117 if size == 0 goto END
122 if i > size2 goto VFREE_END
124 if temp goto VFREE_END
133 =item columns = blockdata."hfree"()
135 Checks how many free columns exist at the left
137 Positive return values means that this many free
138 colums were counted. If the returned value is negative,
139 the absolute value is the number of free colums found at
142 Returns the number of free columns.
163 if temp goto HFREE_ERROR
167 if i < size goto HFREE_LOOPcheck
168 if free < size goto HFREE_LOOPfree
172 if free goto HFREE_END
179 if free < i goto HFREE_ERROR2
181 if offset < 0 goto HFREE_ERROR2
191 if temp goto HFREE_ERROR2
194 if i < size goto HFREE_LOOPcheck2
195 if free < size goto HFREE_LOOPfree2
202 =item size = blockdata."size"()
204 Returns the size of the block represented by this
205 block data. The square of the size is the number of
206 items in the blockdata array.
211 getattribute $P0, self, 'data'
222 .sub __set_pmc :method
225 setattribute self, 'data', data
228 .sub __get_integer_keyed :method
234 getattribute $P0, self, 'data'
237 if index >= $I0 goto ERR
242 print "index out of bounds ("
247 $P0 = new 'Exception'
248 $P0["_message"] = "out of bounds!"
252 .sub __set_integer_keyed :method
259 getattribute $P0, self, 'data'
262 if index >= $I0 goto ERR
267 print "index out of bounds ("
272 $P0 = new 'Exception'
273 $P0["_message"] = "out of bounds!"
281 Jens Rieks E<lt>parrot at jensbeimsurfen dot deE<gt> is the author
283 Please send patches and suggestions to the Perl 6 Internals mailing list.
287 Copyright (C) 2004-2008, The Perl Foundation.
295 # vim: expandtab shiftwidth=4 ft=pir: