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

objects.cpp

Go to the documentation of this file.
00001 
00005 /***************************************************************************
00006                           gamemap.cpp  -  description
00007                              -------------------
00008     begin                : Tue May 21 2005
00009     copyright            : (C) 2005 by Martin Bickel
00010     email                : bickel@asc-hq.org
00011  ***************************************************************************/
00012 
00013 /***************************************************************************
00014  *                                                                         *
00015  *   This program is free software; you can redistribute it and/or modify  *
00016  *   it under the terms of the GNU General Public License as published by  *
00017  *   the Free Software Foundation; either version 2 of the License, or     *
00018  *   (at your option) any later version.                                   *
00019  *                                                                         *
00020  ***************************************************************************/
00021 
00022 #include <algorithm>
00023 #include <ctime>
00024 #include <cmath>
00025 
00026 #include "global.h"
00027 #include "misc.h"
00028 #include "typen.h"
00029 #include "vehicletype.h"
00030 #include "buildingtype.h"
00031 #include "itemrepository.h"
00032 #include "graphics/blitter.h"
00033 #include "iconrepository.h"
00034 #include "objects.h"
00035 #include "graphics/blitter.h"
00036 
00037 
00038 const char* MineNames[cminenum]  = {"antipersonnel mine", "antitank mine", "antisub mine", "antiship mine"};
00039 const int MineBasePunch[cminenum]  = { 60, 120, 180, 180 };
00040 
00041 void MineType :: paint ( Surface& surface, const SPoint& pos ) const 
00042 {
00043    paint( type, 0, surface, pos );
00044 }
00045 
00046 void MineType::paint( MineTypes type, int player, Surface& surf, const SPoint& pos )
00047 {
00048    static Surface* images[5] = { NULL, NULL, NULL, NULL, NULL };
00049    if ( !images[type] ) {
00050       switch ( type ) {
00051          case cmantipersonnelmine: images[type] = & IconRepository::getIcon( "antipersonellmine.png" );
00052          break;
00053          case cmantitankmine: images[type] = & IconRepository::getIcon( "antitankmine.png" );
00054          break;
00055          case cmfloatmine:
00056          case cmmooredmine: images[type] = & IconRepository::getIcon( "antishipmine.png" );
00057          break;
00058      };
00059    }
00060    if ( images[type] ) {
00061       if ( type != cmmooredmine )
00062          megaBlitter< ColorTransform_None, ColorMerger_AlphaOverwrite, SourcePixelSelector_Plain, TargetPixelSelector_All > 
00063                 ( *images[type], surf, pos, nullParam,nullParam, nullParam,nullParam);
00064       else
00065          megaBlitter< ColorTransform_None, ColorMerger_AlphaMixer, SourcePixelSelector_Plain, TargetPixelSelector_All > 
00066                 ( *images[type], surf, pos, nullParam,nullParam, nullParam,nullParam);
00067    }
00068 }
00069 
00070 
00071 bool AgeableItem::age( AgeableItem& obj )
00072 {
00073    if ( obj.lifetimer > 0 ) {
00074       --obj.lifetimer;
00075       return obj.lifetimer==0;
00076    } else
00077       return false;
00078 }
00079 
00080 
00081 Object :: Object ( )
00082 {
00083    typ = NULL;
00084    dir = 0;
00085    damage = 0;
00086    remainingGrowthTime = -1;
00087 }
00088 
00089 Object :: Object ( const ObjectType* o )
00090 {
00091    lifetimer = o->lifetime;
00092    typ = o;
00093    dir = 0;
00094    damage = 0;
00095    remainingGrowthTime = o->growthDuration;
00096 }
00097 
00098 
00099 void Object :: setdir ( int direc )
00100 {
00101    dir = direc;
00102 }
00103 
00104 int  Object :: getdir ( void )
00105 {
00106    return dir;
00107 }
00108 
00109 void Object :: display ( Surface& surface, const SPoint& pos, int weather ) const
00110 {
00111    typ->display ( surface, pos, dir, weather );
00112 }
00113 
00114 const OverviewMapImage* Object :: getOverviewMapImage( int weather )
00115 {
00116    return typ->getOverviewMapImage( dir, weather );
00117 }
00118 

Generated on Tue Jun 24 01:27:46 2008 for Advanced Strategic Command by  doxygen 1.4.2