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

explode.cpp

Go to the documentation of this file.
00001 #include "explode.h"
00002 #include "util.h"
00003 #include "object.h"
00004 #include "objmgr.h"
00005 
00006 ExplodeObject::ExplodeObject(ObjectManager &om) : GameObject(om)
00007 {
00008         sprite = new Sprite(EXPLODE_IMAGE, "Explode");
00009         birthtime = Util_GetTime();
00010 }
00011 
00012 ExplodeObject::ExplodeObject(ObjectManager &om, double ex, double ey) 
00013         : GameObject(om)
00014 {
00015         sprite = new Sprite(EXPLODE_IMAGE, "Explode");
00016         SetPosition(ex, ey);
00017         birthtime = Util_GetTime();
00018 }
00019 
00020 ExplodeObject::~ExplodeObject()
00021 {
00022 }
00023 
00024 void ExplodeObject::SetStrength(double str)
00025 {
00026         strength = str;
00027 }
00028 
00029 void ExplodeObject::think()
00030 {
00031         if (IsDead())
00032                 return;
00033 
00034         if(Util_TimePassed(&birthtime, EXPLODE_LIFETIME) > 0) {
00035                 Rect R1 = Util_BuildRect(GetXint()-1, GetYint()-1, 2, 2);
00036 
00037                 GameObject *o = OM.FindFirstCollision(R1);
00038 
00039                 if(o && o->IsDamagable()) 
00040                         o->Damage(strength);
00041 
00042                 SetDead(true);
00043         }
00044 }
00045 
00046 

Generated on Sun Dec 8 12:02:19 2002 for nnc by doxygen1.3-rc1