Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 5791

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Qt 4.6: tetrixpiece.js Example File (script/qstetrix/tetrixpiece.js)</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">tetrixpiece.js Example File<br /><span class="small-subtitle">script/qstetrix/tetrixpiece.js</span>
</h1>
<pre> TetrixShape = {
     NoShape:0,
     ZShape:1,
     SShape:2,
     LineShape:3,
     TShape:4,
     SquareShape:5,
     LShape:6,
     MirroredLShape:7
 }

 TetrixCoordsTable = [
     [ [ 0,   0 ], [ 0,  0 ], [ 0,  0 ], [ 0,  0 ] ],
     [ [ 0,  -1 ], [ 0,  0 ], [ -1, 0 ], [ -1, 1 ] ],
     [ [ 0,  -1 ], [ 0,  0 ], [ 1,  0 ], [ 1,  1 ] ],
     [ [ 0,  -1 ], [ 0,  0 ], [ 0,  1 ], [ 0,  2 ] ],
     [ [ -1,  0 ], [ 0,  0 ], [ 1,  0 ], [ 0,  1 ] ],
     [ [ 0,   0 ], [ 1,  0 ], [ 0,  1 ], [ 1,  1 ] ],
     [ [ -1, -1 ], [ 0, -1 ], [ 0,  0 ], [ 0,  1 ] ],
     [ [ 1,  -1 ], [ 0, -1 ], [ 0,  0 ], [ 0,  1 ] ]
 ]

 function TetrixPiece()
 {
     this.shape = TetrixShape.NoShape;
 }

 TetrixPiece.prototype.__defineGetter__(
     &quot;shape&quot;,
     function() {
       return this._shape;
     }
 );

 TetrixPiece.prototype.__defineSetter__(
     &quot;shape&quot;,
     function(shape) {
       this._shape = shape;
       this._coords = new Array(4);
       for (var i = 0; i &lt; 4; ++i)
           this._coords[i] = TetrixCoordsTable[shape][i].slice();
     }
 );

 TetrixPiece.prototype.setRandomShape = function() {
     this.shape = Math.floor(((Math.random() * 100000) % 7) + 1);
 }

 TetrixPiece.prototype.getX = function(index) {
     return this._coords[index][0];
 }

 TetrixPiece.prototype.getY = function(index) {
     return this._coords[index][1];
 }

 TetrixPiece.prototype._setX = function(index, x) {
     this._coords[index][0] = x;
 }

 TetrixPiece.prototype._setY = function(index, y) {
     this._coords[index][1] = y;
 }

 TetrixPiece.prototype.__defineGetter__(
     &quot;minX&quot;,
     function() {
         var min = this._coords[0][0];
         for (var i = 1; i &lt; 4; ++i)
             min = Math.min(min, this._coords[i][0]);
         return min;
     }
 );

 TetrixPiece.prototype.__defineGetter__(
     &quot;maxX&quot;,
     function() {
         var max = this._coords[0][0];
         for (var i = 1; i &lt; 4; ++i)
             max = Math.max(max, this._coords[i][0]);
         return max;
     }
 );

 TetrixPiece.prototype.__defineGetter__(
     &quot;minY&quot;,
     function() {
       var min = this._coords[0][1];
       for (var i = 1; i &lt; 4; ++i)
           min = Math.min(min, this._coords[i][1]);
       return min;
     }
 );

 TetrixPiece.prototype.__defineGetter__(
     &quot;maxY&quot;,
     function() {
         var max = this._coords[0][1];
         for (var i = 1; i &lt; 4; ++i)
             max = Math.max(max, this._coords[i][1]);
         return max;
     }
 );

 TetrixPiece.prototype.rotatedLeft = function() {
     var result = new TetrixPiece();
     if (this._shape == TetrixShape.SquareShape) {
         result.shape = this._shape;
         return result;
     }
     result._shape = this._shape;
     for (var i = 0; i &lt; 4; ++i) {
         result._setX(i, this.getY(i));
         result._setY(i, -this.getX(i));
     }
     return result;
 }

 TetrixPiece.prototype.rotatedRight = function() {
     var result = new TetrixPiece();
     if (this._shape == TetrixShape.SquareShape) {
         result.shape = this._shape;
         return result;
     }
     result._shape = this._shape;
     for (var i = 0; i &lt; 4; ++i) {
         result._setX(i, -this.getY(i));
         result._setY(i, this.getX(i));
     }
     return result;
 }</pre>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>