00001 // 00002 // Copyright (C) 2002 Robert Renaud 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU General Public License 00006 // as published by the Free Software Foundation; either version 2 00007 // of the License, or (at your option) any later version. 00008 // 00009 // This program 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. 00012 // 00013 // See the GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 00020 #ifndef MOVEABLE_H_ 00021 #define MOVEABLE_H_ 00022 00023 #include "../Config.h" 00024 00025 #include "Constants.h" 00026 #include "../Graphics/draw.h" 00027 00028 #include "GameDebug.h" 00029 00030 namespace Game { 00031 00032 enum Direction { 00033 LEFT=0, RIGHT=1, UP=2, DOWN=3, NO_DIRECTION=4 00034 }; 00035 00036 class PlaceableItem: public Graphics::Drawable { 00037 public: 00038 /* 00039 * @param startX initial row occupied by the object 00040 * @param startY initial column occupied by the object 00041 */ 00042 PlaceableItem(Sint16 x, Sint16 y); 00043 00044 virtual ~PlaceableItem() { } 00045 00046 virtual Sint16 getXpixel() const; 00047 virtual Sint16 getYpixel() const; 00048 00049 protected: 00050 SDL_Rect picPosition; 00051 }; 00052 00057 class MoveableItem : public PlaceableItem { 00058 public: 00059 00060 MoveableItem(Sint16 startX, Sint16 startY, int speed=0); 00061 virtual ~MoveableItem() { } 00062 00063 virtual void move(); 00064 virtual void move(int amnt); 00065 00066 virtual int getSpeed(); 00067 virtual void setSpeed(int newSpeed); 00068 00075 virtual void inch(int amount, Direction d); 00076 00078 virtual Direction getDirection(); 00080 virtual void setDirection(Direction dir); 00081 00082 virtual void lockMovement(); 00083 virtual void unlockMovement(); 00084 00085 virtual void setXpixel(Sint16 x); 00086 virtual void setYpixel(Sint16 y); 00087 00088 protected: 00089 int speed; 00090 Direction dir; 00091 bool dirIsLocked; 00092 }; 00093 00094 }; // namespace Game 00095 00097 std::istream& operator >> (std::istream& in, Game::Direction& d); 00098 00099 #endif // ifndef MOVEABLE_H_ 00100
1.2.12 written by Dimitri van Heesch,
© 1997-2001