Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Sight.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TSGL - Teddy Space Game Library
00004     Copyright (C) 2002 Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: Sight.cpp,v 1.1 2002/01/08 20:47:05 tksuoran Exp $
00022 */
00023 
00024 
00025 #include "Teddy/SpaceGame/Sight.h"
00026 #include "Teddy/PhysicalComponents/LayoutConstraint.h"
00027 #include "Teddy/PhysicalComponents/GradientFill.h"
00028 #include "Teddy/PhysicalComponents/Frame.h"
00029 #include "Teddy/Graphics/Features.h"
00030 #include "Teddy/Graphics/View.h"
00031 using namespace Teddy::PhysicalComponents;
00032 
00033 
00034 namespace Teddy     {
00035 namespace SpaceGame {
00036 
00037 
00038 /*virtual*/ void Sight::place( int offset_x, int offset_y ){
00039     Area::place( offset_x, offset_y );
00040 }
00041 
00042 
00044 Sight::Sight():Area("Sight"){
00045     size = 16;
00046 
00047     constraint = new LayoutConstraint();
00048     constraint->local_x_offset_relative  = -0.5;
00049     constraint->local_y_offset_relative  = -0.5;
00050     constraint->parent_x_offset_relative =  0.5;
00051     constraint->parent_y_offset_relative =  0.5;
00052     constraint->local_x_fill_pixels      = 4*size;
00053     constraint->local_y_fill_pixels      = 4*size;
00054 }
00055 
00056 
00058 /*virtual*/ Sight::~Sight(){
00059 }
00060 
00061 
00062 
00064 void Sight::drawSelf(){
00065     view->disable( TEXTURE_2D );
00066     color( C_LIGHT_GREEN );
00067     beginLines();
00068     vertex2i( 0*size, 2*size );
00069     vertex2i( 1*size, 2*size );
00070     vertex2i( 3*size, 2*size );
00071     vertex2i( 4*size, 2*size );
00072     vertex2i( 2*size, 0*size );
00073     vertex2i( 2*size, 1*size );
00074     vertex2i( 2*size, 3*size );
00075     vertex2i( 2*size, 4*size );
00076     end();
00077     
00078     color( C_BLACK );
00079     beginLines();
00080     vertex2i( 0*size,   2*size-1 );
00081     vertex2i( 1*size,   2*size-1 );
00082     vertex2i( 3*size,   2*size-1 );
00083     vertex2i( 4*size,   2*size-1 );
00084     vertex2i( 0*size,   2*size+1 );
00085     vertex2i( 1*size,   2*size+1 );
00086     vertex2i( 3*size,   2*size+1 );
00087     vertex2i( 4*size,   2*size+1 );
00088     vertex2i( 2*size-1, 0*size );
00089     vertex2i( 2*size-1, 1*size );
00090     vertex2i( 2*size-1, 3*size );
00091     vertex2i( 2*size-1, 4*size );
00092     vertex2i( 2*size+1, 0*size );
00093     vertex2i( 2*size+1, 1*size );
00094     vertex2i( 2*size+1, 3*size );
00095     vertex2i( 2*size+1, 4*size );
00096     end();
00097 }
00098 
00099 
00100 };  //  namespace SpaceGame
00101 };  //  namespace Teddy