00001 // SuperTux - A Jump'n Run 00002 // Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de> 00003 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de> 00004 // 00005 // This program is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // 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, see <http://www.gnu.org/licenses/>. 00017 00018 #ifndef HEADER_SUPERTUX_WORLDMAP_TUX_HPP 00019 #define HEADER_SUPERTUX_WORLDMAP_TUX_HPP 00020 00021 #include "worldmap/worldmap.hpp" 00022 00023 class Sprite; 00024 00025 namespace worldmap { 00026 00027 class WorldMap; 00028 00029 class Tux : public GameObject 00030 { 00031 public: 00032 Direction back_direction; 00033 private: 00034 WorldMap* worldmap; 00035 SpritePtr sprite; 00036 Controller* controller; 00037 00038 Direction input_direction; 00039 Direction direction; 00040 Vector tile_pos; 00043 float offset; 00044 bool moving; 00045 00046 bool ghost_mode; 00047 00048 private: 00049 void stop(); 00050 bool canWalk(int tile_data, Direction dir); 00051 void updateInputDirection(); 00052 void tryStartWalking(); 00053 void tryContinueWalking(float elapsed_time); 00055 public: 00056 Tux(WorldMap* worldmap_); 00057 ~Tux(); 00058 00059 void setup(); 00060 void draw(DrawingContext& context); 00061 void update(float elapsed_time); 00062 00063 void set_direction(Direction dir); 00064 00065 void set_ghost_mode(bool enabled); 00066 bool get_ghost_mode(); 00067 00068 bool is_moving() const { return moving; } 00069 Vector get_pos(); 00070 Vector get_tile_pos() const { return tile_pos; } 00071 void set_tile_pos(Vector p) { tile_pos = p; } 00072 00073 private: 00074 Tux(const Tux&); 00075 Tux& operator=(const Tux&); 00076 }; 00077 00078 } // namespace worldmap 00079 00080 #endif 00081 00082 /* EOF */