1 /* 2 * Copyright (C) 2006-2019 Christopho, Solarus - http://www.solarus-games.org 3 * 4 * Solarus is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * Solarus is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License along 15 * with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 #ifndef SOLARUS_TILE_PATTERN_H 18 #define SOLARUS_TILE_PATTERN_H 19 20 #include "solarus/core/Common.h" 21 #include "solarus/core/Size.h" 22 #include "solarus/entities/Ground.h" 23 #include "solarus/graphics/SurfacePtr.h" 24 25 namespace Solarus { 26 27 class Point; 28 class Rectangle; 29 class Surface; 30 class Tileset; 31 32 /** 33 * \brief Abstract class for a tile pattern. 34 * 35 * A tile pattern defines a rectangle image in a tileset and has a ground property. 36 * It may have a special animation. 37 * The width and the height of a tile pattern are always multiples or 8. 38 */ 39 class TilePattern { 40 41 public: 42 43 virtual ~TilePattern(); 44 45 int get_width() const; 46 int get_height() const; 47 const Size& get_size() const; 48 Ground get_ground() const; 49 50 void fill_surface( 51 const SurfacePtr& dst_surface, 52 const Rectangle& dst_position, 53 const Tileset& tileset, 54 const Point& viewport 55 ) const; 56 57 virtual void update(); 58 59 /** 60 * \brief Draws the tile image on a surface. 61 * \param dst_surface The surface to draw. 62 * \param dst_position Position where the tile pattern should be drawn. 63 * \param tileset The tileset of this tile. 64 * \param viewport Coordinates of the top-left corner of dst_surface 65 * relative to the map (may be used for scrolling tiles). 66 */ 67 virtual void draw( 68 const SurfacePtr& dst_surface, 69 const Point& dst_position, 70 const Tileset& tileset, 71 const Point& viewport 72 ) const = 0; 73 virtual bool is_animated() const; 74 virtual bool is_drawn_at_its_position() const; 75 76 protected: 77 78 TilePattern(Ground ground, const Size& size); 79 80 const Ground ground; /**< Kind of tile. */ 81 82 Size size; /**< Pattern size (multiple of 8). */ 83 84 }; 85 86 } 87 88 #endif 89 90