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 00021 #ifndef PLAYER_H_ 00022 #define PLAYER_H_ 00023 00024 #include "../Config.h" 00025 00026 #include <map> 00027 #include <vector> 00028 00029 #include "GameDebug.h" 00030 #include "Moveable.h" 00031 #include "Bomb.h" 00032 #include "PlayerController.h" 00033 00034 #include "../Graphics/draw.h" 00035 #include "../Parse/ListParser.h" 00036 #include "../Parse/Parse.h" 00037 00038 00039 namespace Game { 00040 00041 Direction getDirectionFromMovement(PlayerAction pa); 00042 PlayerAction getMovementFromDirection(Direction d); 00043 00045 class AbstractPlayer : public Parse::Parseable, public MoveableItem { 00046 public: 00047 AbstractPlayer(Sint16 startX, Sint16 startY); 00048 ~AbstractPlayer(); // remember to delee all allocated images 00049 00050 void draw(SDL_Surface* screen); 00051 00052 Parse::Parser* makeParserToParseMe(std::istream& input); 00053 00054 void setDirection(Direction d); 00055 00056 virtual PlayerAction getInput()=0; 00057 00058 virtual int getBombRadius(); 00059 virtual void setBombRadius(int newRad); 00060 00061 virtual void increaseBombsLeft(); 00062 virtual void decreaseBombsLeft(); 00063 00064 // virtual void die(); 00065 00066 protected: 00067 class PlayerAfterParseValidator: public Parse::ParseAction { 00068 public: 00069 PlayerAfterParseValidator(AbstractPlayer& p); 00070 void getValue(std::istream& input); 00071 void finishingAction(); 00072 private: 00073 AbstractPlayer& playerRef; 00074 }; 00075 00076 friend class PlayerAfterParseValidator; 00077 00078 Graphics::AbstractImage** activeImage; 00079 00080 std::vector<Graphics::AbstractImage*> movingImages; 00081 std::vector<Graphics::AbstractImage*> idleImages; 00082 00083 int bombRadius; 00084 int bombsLeft; 00085 int framesTilNextBomb; 00086 00087 // Graphics::AbstractImage* deathImage; 00088 }; 00089 00091 class LocalPlayer: public AbstractPlayer { 00092 public: 00093 LocalPlayer (Sint16 startX, Sint16 startY); 00094 ~LocalPlayer(); 00095 Parse::Parser* makeParserToParseMe(std::istream& input); 00096 PlayerAction getInput(); 00097 protected: 00098 PlayerController* controller; 00099 }; 00100 00101 }; // namespace Game 00102 00103 #endif // ifndef PLAYER_H_ 00104
1.2.12 written by Dimitri van Heesch,
© 1997-2001