X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsupertux%2Ftile.hpp;h=92fa06e495ad0806a4881cefa8448ae6b3a01d78;hb=58afd70ea8a836bc41e6da8dd376728d90d27431;hp=690aef32310158222201a014576de8ad799a3f9b;hpb=ff08b8e1983016221967a024dab76799a3d75059;p=supertux.git diff --git a/src/supertux/tile.hpp b/src/supertux/tile.hpp index 690aef323..92fa06e49 100644 --- a/src/supertux/tile.hpp +++ b/src/supertux/tile.hpp @@ -1,6 +1,7 @@ // SuperTux // Copyright (C) 2004 Tobias Glaesser // Copyright (C) 2006 Matthias Braun +// Copyright (C) 2010 Florian Forster // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -25,12 +26,12 @@ #include "video/surface.hpp" #include "util/reader_fwd.hpp" -class TileSet; class DrawingContext; class Tile { public: + static bool draw_editor_images; /// bitset for tile attributes enum { /** solid tile that is indestructible by Tux */ @@ -91,10 +92,20 @@ public: Rectf rect; }; + enum + { + UNI_DIR_NORTH = 0, + UNI_DIR_SOUTH = 1, + UNI_DIR_WEST = 2, + UNI_DIR_EAST = 3, + UNI_DIR_MASK = 3 + }; + private: - const TileSet& tileset; std::vector imagespecs; - std::vector images; + std::vector images; + std::vector editor_imagespecs; + std::vector editor_images; /// tile attributes uint32_t attributes; @@ -102,12 +113,12 @@ private: /** General purpose data attached to a tile (content of a box, type of coin)*/ int data; - float anim_fps; + float fps; public: - Tile(const TileSet& tileset); - Tile(const TileSet& tileset, const std::vector& images, - uint32_t attributes, uint32_t data, float animfps); + Tile(); + Tile(const std::vector& images, const std::vector& editor_images, + uint32_t attributes, uint32_t data, float fps); ~Tile(); /** load Surfaces, if not already loaded */ @@ -122,6 +133,34 @@ public: int getData() const { return data; } + /** Checks the SLOPE attribute. Returns "true" if set, "false" otherwise. */ + bool is_slope() const + { + return attributes & SLOPE; + } + + /** Determine the solidity of a tile. This version behaves correctly for + * unisolid tiles by taking position and movement of the object in question + * into account. Because creating the arguments for this function can be + * expensive, you should handle trivial cases using the "is_solid()" and + * "is_unisolid()" methods first. */ + bool is_solid (const Rectf& tile_bbox, const Rectf& position, const Vector& movement) const; + + /** This version only checks the SOLID flag to determine the solidity of a + * tile. This means it will always return "true" for unisolid tiles. To + * determine the *current* solidity of unisolid tiles, use the "is_solid" + * method that takes position and movement into account (see above). */ + bool is_solid() const + { + return attributes & SOLID; + } + + /** Checks the UNISOLID attribute. Returns "true" if set, "false" otherwise. */ + bool is_unisolid() const + { + return attributes & UNISOLID; + } + void print_debug(int id) const; private: @@ -129,6 +168,15 @@ private: //might miss (and rebuke them for it) void correct_attributes(); + /** Returns zero if a unisolid tile is non-solid due to the movement + * direction, non-zero if the tile is solid due to direction. */ + bool check_movement_unisolid (const Vector movement) const; + + /** Returns zero if a unisolid tile is non-solid due to the position of the + * tile and the object, non-zero if the tile is solid. */ + bool check_position_unisolid (const Rectf& obj_bbox, + const Rectf& tile_bbox) const; + private: Tile(const Tile&); Tile& operator=(const Tile&);