engine.draw Class Reference

This comletely static class holds the various methods to draw a Tetris or preview array. More...

List of all members.

Static Package Functions

static void drawTetris (Tetris t, GL gl)
 To draw a tetris in its whole glory.
static void drawBlockmatrix (IBlock[][] blocks, GL gl, float offsetX, float offsetY)
 Draw an array at a given position.

Static Private Member Functions

static void drawCrate (GL gl, float x0ffset, float y0ffset, Color color)
 to draw a single Box
static void drawBounds (GL gl, float rot, int width, int height)
 Draw the boundary of the Tetris field.

Static Private Attributes

static float rot = 0.0f
 the rotation of the field


Detailed Description

This comletely static class holds the various methods to draw a Tetris or preview array.

Author:
Team Solid Sun

Member Function Documentation

static void engine.draw.drawCrate ( GL  gl,
float  x0ffset,
float  y0ffset,
Color  color 
) [static, private]

to draw a single Box

Parameters:
gl The Gl to draw in.
x0ffset The Position to draw at.
y0ffset The Position to draw at.
color The Color to draw with.

References game.Color.getBlue(), game.Color.getGreen(), game.Color.getRed(), and engine.draw.rot.

Referenced by engine.draw.drawBlockmatrix(), and engine.draw.drawBounds().

00037                                      {
00038 
00039                 gl.glLoadIdentity();
00040                 gl.glTranslatef(0, 0, -55.0f);
00041                 gl.glRotatef(rot, 0.0f, 1.0f, 0.0f);
00042                 gl.glTranslatef(x0ffset, y0ffset, 0);
00043                 gl.glBegin(GL.GL_QUADS);
00044 
00045                 // front
00046                 gl.glColor3f(color.getRed(), color.getGreen(), color.getBlue());
00047                 gl.glVertex3f(1.0f, 1.0f, 1.0f);
00048                 gl.glVertex3f(-1.0f, 1.0f, 1.0f);
00049                 gl.glVertex3f(-1.0f, -1.0f, 1.0f);
00050                 gl.glVertex3f(1.0f, -1.0f, 1.0f);
00051 
00052                 // back
00053                 gl.glColor3f(color.getRed() * 0.3f, color.getGreen() * 0.3f, color
00054                                 .getBlue() * 0.3f);
00055                 gl.glVertex3f(1.0f, 1.0f, -1.0f);
00056                 gl.glVertex3f(-1.0f, 1.0f, -1.0f);
00057                 gl.glVertex3f(-1.0f, -1.0f, -1.0f);
00058                 gl.glVertex3f(1.0f, -1.0f, -1.0f);
00059 
00060                 // left
00061                 gl.glColor3f(color.getRed() * 0.5f, color.getGreen() * 0.5f, color
00062                                 .getBlue() * 0.5f);
00063                 gl.glVertex3f(-1.0f, -1.0f, -1.0f);
00064                 gl.glVertex3f(-1.0f, -1.0f, 1.0f);
00065                 gl.glVertex3f(-1.0f, 1.0f, 1.0f);
00066                 gl.glVertex3f(-1.0f, 1.0f, -1.0f);
00067 
00068                 // right
00069                 gl.glColor3f(color.getRed() * 0.9f, color.getGreen() * 0.9f, color
00070                                 .getBlue() * 0.9f);
00071                 gl.glVertex3f(1.0f, -1.0f, -1.0f);
00072                 gl.glVertex3f(1.0f, -1.0f, 1.0f);
00073                 gl.glVertex3f(1.0f, 1.0f, 1.0f);
00074                 gl.glVertex3f(1.0f, 1.0f, -1.0f);
00075 
00076                 // up
00077                 gl.glColor3f(color.getRed() * 0.7f, color.getGreen() * 0.7f, color
00078                                 .getBlue() * 0.7f);
00079                 gl.glVertex3f(-1.0f, 1.0f, -1.0f);
00080                 gl.glVertex3f(1.0f, 1.0f, -1.0f);
00081                 gl.glVertex3f(1.0f, 1.0f, 1.0f);
00082                 gl.glVertex3f(-1.0f, 1.0f, 1.0f);
00083 
00084                 // down
00085                 gl.glColor3f(color.getRed() * 0.5f, color.getGreen() * 0.5f, color
00086                                 .getBlue() * 0.5f);
00087                 gl.glVertex3f(-1.0f, -1.0f, -1.0f);
00088                 gl.glVertex3f(1.0f, -1.0f, -1.0f);
00089                 gl.glVertex3f(1.0f, -1.0f, 1.0f);
00090                 gl.glVertex3f(-1.0f, -1.0f, 1.0f);
00091 
00092                 gl.glEnd();
00093 
00094         }

static void engine.draw.drawBounds ( GL  gl,
float  rot,
int  width,
int  height 
) [static, private]

Draw the boundary of the Tetris field.

Parameters:
gl The Gl to draw in.
rot The rotation.
width The width of the field.
height The height of the field.

References engine.draw.drawCrate().

Referenced by engine.draw.drawTetris().

00108                                                                                 {
00109 
00110                 for (int boden = 0; boden < width; boden++)
00111                         drawCrate(gl, ((int) (width / 2)) * -2.2f + 2.2f * boden,
00112                                         (-1.2f - (2.2f * (height / 2))), new game.Color(0.9f, 0.9f,
00113                                                         0.9f));
00114                 for (int seite = 0; seite <= 22; seite++) {
00115                         drawCrate(gl, (-2.2f - (2.2f * (width / 2))), (-1.2f
00116                                         - (2.2f * (height / 2)) + (2.2f * seite)), new game.Color(
00117                                         0.9f, 0.9f, 0.9f));
00118                         drawCrate(gl, (2.2f + (2.2f * (width / 2))), (-1.2f
00119                                         - (2.2f * (height / 2)) + (2.2f * seite)), new game.Color(
00120                                         0.9f, 0.9f, 0.9f));
00121                 }
00122 
00123         }

static void engine.draw.drawTetris ( Tetris  t,
GL  gl 
) [static, package]

To draw a tetris in its whole glory.

Parameters:
t The Tetris to draw
gl The Gl to draw in.

References engine.draw.drawBlockmatrix(), engine.draw.drawBounds(), and game.Tetris.getBlockMatrix().

00133                                                 {
00134                 IBlock[][] blocks = t.getBlockMatrix();
00135                 drawBlockmatrix(blocks, gl, (float) -blocks[1].length,
00136                                 (float) blocks.length + 1);
00137                 drawBounds(gl, 0, blocks[1].length, blocks.length);
00138                 // rot += 0.5f;
00139                 // de-comment for spin
00140 
00141         }

static void engine.draw.drawBlockmatrix ( IBlock  blocks[][],
GL  gl,
float  offsetX,
float  offsetY 
) [static, package]

Draw an array at a given position.

Parameters:
blocks The Array to draw.
gl The Gl to draw in.
offsetX The Position to draw at.
offsetY The Gl Position draw at.

References engine.draw.drawCrate().

Referenced by engine.draw.drawTetris().

00156                                        {
00157                 for (int col = 1; col < blocks.length; col++)
00158                         for (IBlock bl : blocks[col])
00159                                 if (bl != null && !bl.isEmpty())
00160                                         drawCrate(gl, offsetX + 2.2f * bl.getCol(), offsetY - 2.2f
00161                                                         * bl.getRow(), ((Block) bl).getColor());
00162         }


Member Data Documentation

float engine.draw.rot = 0.0f [static, private]

the rotation of the field

Referenced by engine.draw.drawCrate().


The documentation for this class was generated from the following file:

Generated on Mon Jul 28 19:03:03 2008 for SolidJavaTetris by  doxygen 1.5.5