00001 /* This file is part of Annchienta. 00002 * Copyright 2008 (C) Jasper Van der Jeugt 00003 * 00004 * Annchienta is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * Annchienta is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with Annchienta. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef ANNCHIENTA_STATICOBJECT_H 00019 #define ANNCHIENTA_STATICOBJECT_H 00020 00021 #include "Entity.h" 00022 00023 #include <vector> 00024 #include <list> 00025 #include "Point.h" 00026 #include "Engine.h" 00027 00028 namespace Annchienta 00029 { 00030 class Surface; 00031 class Tile; 00032 class Mask; 00033 class Frame; 00034 class Animation; 00035 00040 class StaticObject: public Entity 00041 { 00042 protected: 00043 /* The position indicates the bottom center, like 00044 * ___________ 00045 * | | 00046 * | | 00047 * | | 00048 * |__(pos)__| 00049 * 00050 * This almost equals the "depth sort y". 00051 */ 00052 Point position; 00053 Point mapPosition; 00054 Surface *sprite; 00055 Mask *mask; 00056 00057 std::vector<Frame*> frames; 00058 std::vector<Animation*> animations; 00059 std::list<Tile*> collidingTiles; 00060 Tile *tileStandingOn; 00061 00062 int currentAnimation, currentFrame, speedTimer; 00063 00064 bool passable; 00065 00066 char *onInteractScript, *onInteractCode; 00067 00068 char xmlFile[DEFAULT_STRING_SIZE]; 00069 00070 public: 00071 00076 StaticObject( const char *name, const char *configfile ); 00077 00085 StaticObject( const char *name, Surface *surf, Mask *mask ); 00086 virtual ~StaticObject(); 00087 00092 void calculateCollidingTiles(); 00093 00099 float getZFromCollidingTiles(); 00100 00105 bool collidesWithOtherObjects() const; 00106 00109 virtual EntityType getEntityType() const; 00110 00114 virtual void update(); 00115 00118 virtual void draw(); 00119 00122 virtual int getDepth(); 00123 00126 virtual Mask *getMask() const; 00127 00131 virtual void setPosition( Point position ); 00132 00135 virtual Point getPosition() const; 00136 00139 virtual Point getMaskPosition() const; 00140 00143 const char *getXmlFile() const; 00144 00150 virtual void setSprite( const char *filename ); 00151 00154 Surface *getSprite() const; 00155 00161 bool setAnimation( const char *animationName ); 00162 00166 const char *getAnimation() const; 00167 00172 virtual void setPassable( bool passable ); 00173 00178 virtual bool isPassable() const; 00179 00184 virtual void setOnInteractScript( const char *script ); 00185 00190 virtual void setOnInteractCode( const char *code ); 00191 00194 virtual bool canInteract() const; 00195 00199 virtual void onInteract(); 00200 00201 /* Should only be used for Persons, but this is needed because of 00202 * abstracting to Python scripts. Always returns true. 00203 */ 00204 virtual void freeze( bool ); 00205 virtual bool stepTo( Point ); 00206 virtual void setStandAnimation( bool b=false); 00207 virtual void lookAt( StaticObject *other ); 00208 }; 00209 00210 #ifndef SWIG 00211 void setActiveObject( StaticObject *object ); 00212 void setPassiveObject( StaticObject *object ); 00213 #endif 00214 00220 StaticObject *getActiveObject(); 00221 00227 StaticObject *getPassiveObject(); 00228 }; 00229 00230 #endif