| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> |
| 2 |
<!--NewPage--> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<title>htetris documentation</title> |
| 6 |
</head> |
| 7 |
<body> |
| 8 |
<h1> |
| 9 |
<center>User Manual For htetris Version 1.0</center> |
| 10 |
<center>Henrik Sandin 1999</center> |
| 11 |
</h1> |
| 12 |
<hr> |
| 13 |
<a href="http://lww.CS.Arizona.EDU:80/~henriks/htetrisdoc.html">Main page</a> |
| 14 |
<h2>Implementation details</h2><br> |
| 15 |
<font size="5"> |
| 16 |
The bricks are represented with matrix structures in the game as well as |
| 17 |
the editor. An element in such a matrix represents one square in a brick. |
| 18 |
A matrix is never larger than the actual rectangle which constitutes the |
| 19 |
size of a brick which is measured in number of squares wide and high |
| 20 |
respectively.<br> |
| 21 |
In the editor, a brick-matrix consists of ones and zeros where a one |
| 22 |
represents a colored square and a zero represents an uncolored (black, since |
| 23 |
the backgroud of the edit pane is black) square. |
| 24 |
A string representation of such matrices is used when they are saved to file.<br> |
| 25 |
When a brick is used in the game, the brick-matrix elements plays a different |
| 26 |
role. The area where the bricks fall also has a matrix representation where |
| 27 |
every element, just like the brick matrices in the editor context contains |
| 28 |
one or zero, one representing a position where a brick-square is permanently |
| 29 |
stuck and zero representing a position that is "free".<br> |
| 30 |
<br> |
| 31 |
When a brick is shown and falling, its matrix conceptually resides on top of |
| 32 |
the background matrix. At all times a brick-matrix keeps updated information |
| 33 |
on where a particular square is as well as if that square is colored or not. |
| 34 |
A brick-matrix element contains a record which in turn contains information |
| 35 |
about the current row and column coordinates of the background matrix and |
| 36 |
whether that square is colored or should be drawn transparent (not drawn). |
| 37 |
When a brick changes position (falls one step or is moved to the left or |
| 38 |
to the right), its matrix is updated accordingly.<br> |
| 39 |
When a brick is considered to be stuck somewhere, the background matrix is |
| 40 |
updated by looking at the current information in the current brick-matrix. |
| 41 |
The determining of whether a brick is stuck or can/can not be moved, is done |
| 42 |
by looking at the surrounding elements relative to a brick's current |
| 43 |
position in the background matrix. |
| 44 |
An element in a brick matrix which is market as "colored" can never be |
| 45 |
located "on top" of an element in the background matrix which contains a one.<br> |
| 46 |
<br> |
| 47 |
The actual drawing and erasing of the bricks is based on the background matrix |
| 48 |
indeces where a brick currently resides. |
| 49 |
A brick square has a constant width and height, so it is only a matter of |
| 50 |
multiplying that constant number of pixels by the matrix row or column number |
| 51 |
to determining where the brick image should be drawn.<br> |
| 52 |
<br> |
| 53 |
Graphically, a brick is a rectangular image(string) which is drawn using the |
| 54 |
procedure <b>DrawImage()</b> which support transparency in drawing. |
| 55 |
This is useful since bricks are shaped as they are.<br> |
| 56 |
Erasing of a brick is done by a series of <b>EraseArea()</b> calls each of |
| 57 |
which is erasing one square of the brick. This is a little bit slow but is |
| 58 |
necessary to prevent already stuck bricks from being overwritten. |
| 59 |
This might happen if a falling brick is erased by clearing one single rectangle |
| 60 |
covering the whole brick when it is close enough to already stuck ones. |
| 61 |
</font> |
| 62 |
</body> |
| 63 |
</html> |