Tile Class Reference

#include <tile.hpp>

List of all members.

Public Types

enum  {
  SOLID = 0x0001, UNISOLID = 0x0002, BRICK = 0x0004, GOAL = 0x0008,
  SLOPE = 0x0010, FULLBOX = 0x0020, COIN = 0x0040, FIRST_INTERESTING_FLAG = 0x0100,
  ICE = 0x0100, WATER = 0x0200, HURTS = 0x0400, FIRE = 0x0800
}
 bitset for tile attributes More...
enum  {
  WORLDMAP_NORTH = 0x0001, WORLDMAP_SOUTH = 0x0002, WORLDMAP_EAST = 0x0004, WORLDMAP_WEST = 0x0008,
  WORLDMAP_DIR_MASK = 0x000f, WORLDMAP_STOP = 0x0010, WORLDMAP_CNSE = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_EAST, WORLDMAP_CNSW = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_WEST,
  WORLDMAP_CNEW = WORLDMAP_NORTH | WORLDMAP_EAST | WORLDMAP_WEST, WORLDMAP_CSEW = WORLDMAP_SOUTH | WORLDMAP_EAST | WORLDMAP_WEST, WORLDMAP_CNSEW = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_EAST | WORLDMAP_WEST
}
 worldmap flags More...
enum  {
  UNI_DIR_NORTH = 0, UNI_DIR_SOUTH = 1, UNI_DIR_WEST = 2, UNI_DIR_EAST = 3,
  UNI_DIR_MASK = 3
}

Public Member Functions

 Tile ()
 Tile (const std::vector< ImageSpec > &images, const std::vector< ImageSpec > &editor_images, uint32_t attributes, uint32_t data, float fps)
 ~Tile ()
void load_images ()
 load Surfaces, if not already loaded
void draw (DrawingContext &context, const Vector &pos, int z_pos) const
 Draw a tile on the screen.
uint32_t getAttributes () const
int getData () const
bool is_slope () const
 Checks the SLOPE attribute.
bool is_solid (const Rectf &tile_bbox, const Rectf &position, const Vector &movement) const
 Determine the solidity of a tile.
bool is_solid () const
 This version only checks the SOLID flag to determine the solidity of a tile.
bool is_unisolid () const
 Checks the UNISOLID attribute.
void print_debug (int id) const

Static Public Attributes

static bool draw_editor_images

Private Member Functions

void correct_attributes ()
bool check_movement_unisolid (const Vector movement) const
 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_position_unisolid (const Rectf &obj_bbox, const Rectf &tile_bbox) 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.
 Tile (const Tile &)
Tileoperator= (const Tile &)

Private Attributes

std::vector< ImageSpecimagespecs
std::vector< SurfacePtrimages
std::vector< ImageSpeceditor_imagespecs
std::vector< SurfacePtreditor_images
uint32_t attributes
 tile attributes
int data
 General purpose data attached to a tile (content of a box, type of coin).
float fps

Classes

struct  ImageSpec


Detailed Description

Definition at line 31 of file tile.hpp.


Member Enumeration Documentation

anonymous enum

bitset for tile attributes

Enumerator:
SOLID  solid tile that is indestructible by Tux
UNISOLID  uni-directional solid tile
BRICK  a brick that can be destroyed by jumping under it
GOAL  the level should be finished when touching a goaltile.

if data is 0 then the endsequence should be triggered, if data is 1 then we can finish the level instantly.

SLOPE  slope tile
FULLBOX  Bonusbox, content is stored in data.
COIN  Tile is a coin.
FIRST_INTERESTING_FLAG 
ICE  an ice brick that makes tux sliding more than usual
WATER  a water tile in which tux starts to swim
HURTS  a tile that hurts the player if he touches it
FIRE  for lava: WATER, HURTS, FIRE

Definition at line 36 of file tile.hpp.

00036        {
00038     SOLID     = 0x0001,
00040     UNISOLID  = 0x0002,
00042     BRICK     = 0x0004,
00047     GOAL      = 0x0008,
00049     SLOPE     = 0x0010,
00051     FULLBOX   = 0x0020,
00053     COIN      = 0x0040,
00054 
00055     /* interesting flags (the following are passed to gameobjects) */
00056     FIRST_INTERESTING_FLAG = 0x0100,
00057 
00059     ICE       = 0x0100,
00061     WATER     = 0x0200,
00063     HURTS     = 0x0400,
00065     FIRE      = 0x0800
00066   };

anonymous enum

worldmap flags

Enumerator:
WORLDMAP_NORTH 
WORLDMAP_SOUTH 
WORLDMAP_EAST 
WORLDMAP_WEST 
WORLDMAP_DIR_MASK 
WORLDMAP_STOP 
WORLDMAP_CNSE 
WORLDMAP_CNSW 
WORLDMAP_CNEW 
WORLDMAP_CSEW 
WORLDMAP_CNSEW 

Definition at line 69 of file tile.hpp.

00069        {
00070     WORLDMAP_NORTH = 0x0001,
00071     WORLDMAP_SOUTH = 0x0002,
00072     WORLDMAP_EAST  = 0x0004,
00073     WORLDMAP_WEST  = 0x0008,
00074     WORLDMAP_DIR_MASK = 0x000f,
00075 
00076     WORLDMAP_STOP  = 0x0010,
00077 
00078     // convenience values ("C" stands for crossroads)
00079     WORLDMAP_CNSE  = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_EAST,
00080     WORLDMAP_CNSW  = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_WEST,
00081     WORLDMAP_CNEW  = WORLDMAP_NORTH | WORLDMAP_EAST  | WORLDMAP_WEST,
00082     WORLDMAP_CSEW  = WORLDMAP_SOUTH | WORLDMAP_EAST  | WORLDMAP_WEST,
00083     WORLDMAP_CNSEW = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_EAST | WORLDMAP_WEST
00084   };

anonymous enum

Enumerator:
UNI_DIR_NORTH 
UNI_DIR_SOUTH 
UNI_DIR_WEST 
UNI_DIR_EAST 
UNI_DIR_MASK 

Definition at line 95 of file tile.hpp.

00096   {
00097     UNI_DIR_NORTH = 0,
00098     UNI_DIR_SOUTH = 1,
00099     UNI_DIR_WEST  = 2,
00100     UNI_DIR_EAST  = 3,
00101     UNI_DIR_MASK  = 3
00102   };


Constructor & Destructor Documentation

Tile::Tile (  ) 

Definition at line 28 of file tile.cpp.

00028            :
00029   imagespecs(),
00030   images(),
00031   editor_imagespecs(),
00032   editor_images(),
00033   attributes(0), 
00034   data(0), 
00035   fps(1)
00036 {
00037 }

Tile::Tile ( const std::vector< ImageSpec > &  images,
const std::vector< ImageSpec > &  editor_images,
uint32_t  attributes,
uint32_t  data,
float  fps 
)

Definition at line 39 of file tile.cpp.

References correct_attributes().

00040                                                           :
00041   imagespecs(imagespecs_),
00042   images(),
00043   editor_imagespecs(editor_imagespecs_),
00044   editor_images(),
00045   attributes(attributes), 
00046   data(data), 
00047   fps(fps)
00048 {
00049   correct_attributes();
00050 }

Tile::~Tile (  ) 

Definition at line 52 of file tile.cpp.

00053 {
00054 }

Tile::Tile ( const Tile  )  [private]


Member Function Documentation

void Tile::load_images (  ) 

load Surfaces, if not already loaded

Definition at line 57 of file tile.cpp.

References Surface::create(), editor_images, editor_imagespecs, images, and imagespecs.

00058 {
00059   if(images.size() == 0 && imagespecs.size() != 0)
00060   {
00061     assert(images.size() == 0);
00062     for(std::vector<ImageSpec>::iterator i = imagespecs.begin(); i != imagespecs.end(); ++i) 
00063     {
00064       const ImageSpec& spec = *i;
00065 
00066       SurfacePtr surface;
00067       if(spec.rect.get_width() <= 0) 
00068       {
00069         surface = Surface::create(spec.file);
00070       }
00071       else 
00072       {
00073         surface = Surface::create(spec.file,
00074                                   Rect((int) spec.rect.p1.x,
00075                                        (int) spec.rect.p1.y,
00076                                        Size((int) spec.rect.get_width(),
00077                                             (int) spec.rect.get_height())));
00078       }
00079       images.push_back(surface);
00080     }
00081   }
00082 
00083   if(editor_images.size() == 0 && editor_imagespecs.size() != 0)
00084   {
00085     assert(editor_images.size() == 0);
00086     for(std::vector<ImageSpec>::iterator i = editor_imagespecs.begin(); i != editor_imagespecs.end(); ++i) 
00087     {
00088       const ImageSpec& spec = *i;
00089 
00090       SurfacePtr surface;
00091       if(spec.rect.get_width() <= 0) 
00092       {
00093         surface = Surface::create(spec.file);
00094       }
00095       else 
00096       {
00097         surface = Surface::create(spec.file,
00098                                   Rect((int) spec.rect.p1.x,
00099                                        (int) spec.rect.p1.y,
00100                                        Size((int) spec.rect.get_width(),
00101                                             (int) spec.rect.get_height())));
00102       }
00103       editor_images.push_back(surface);
00104     }
00105   }
00106 }

void Tile::draw ( DrawingContext context,
const Vector pos,
int  z_pos 
) const

Draw a tile on the screen.

Definition at line 109 of file tile.cpp.

References draw_editor_images, DrawingContext::draw_surface(), editor_images, fps, game_time, and images.

Referenced by TileMap::draw().

00110 {
00111   if(draw_editor_images) {
00112     if(editor_images.size() > 1) {
00113       size_t frame = size_t(game_time * fps) % editor_images.size();
00114       context.draw_surface(editor_images[frame], pos, z_pos);
00115       return;
00116     } else if (editor_images.size() == 1) {
00117       context.draw_surface(editor_images[0], pos, z_pos);
00118       return;
00119     }
00120   }
00121 
00122   if(images.size() > 1) {
00123     size_t frame = size_t(game_time * fps) % images.size();
00124     context.draw_surface(images[frame], pos, z_pos);
00125   } else if (images.size() == 1) {
00126     context.draw_surface(images[0], pos, z_pos);
00127   }
00128 }

uint32_t Tile::getAttributes (  )  const [inline]

Definition at line 130 of file tile.hpp.

References attributes.

Referenced by Sector::collision_tile_attributes(), Sector::fix_old_tiles(), Ispy::free_line_of_sight(), Sector::is_free_of_tiles(), and print_debug().

00131   { return attributes; }

int Tile::getData (  )  const [inline]

Definition at line 133 of file tile.hpp.

References data.

Referenced by check_movement_unisolid(), check_position_unisolid(), Sector::collision_tilemap(), Sector::fix_old_tiles(), Sector::is_free_of_tiles(), print_debug(), and worldmap::WorldMap::tile_data_at().

00134   { return data; }

bool Tile::is_slope (  )  const [inline]

Checks the SLOPE attribute.

Returns "true" if set, "false" otherwise.

Definition at line 137 of file tile.hpp.

References attributes, and SLOPE.

Referenced by Sector::collision_tilemap(), and Sector::is_free_of_tiles().

00138   {
00139     return attributes & SLOPE;
00140   }

bool Tile::is_solid ( const Rectf tile_bbox,
const Rectf position,
const Vector movement 
) const

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.

Definition at line 416 of file tile.cpp.

References attributes, check_movement_unisolid(), check_position_unisolid(), SOLID, and UNISOLID.

Referenced by Sector::collision_tilemap().

00417 {
00418   if (!(attributes & SOLID))
00419     return false;
00420 
00421   if (!(attributes & UNISOLID))
00422     return true;
00423 
00424   return check_movement_unisolid (movement) &&
00425          check_position_unisolid (position, tile_bbox);
00426 } /* bool Tile::is_solid */

bool Tile::is_solid (  )  const [inline]

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).

Definition at line 153 of file tile.hpp.

References attributes, and SOLID.

00154   {
00155     return attributes & SOLID;
00156   }

bool Tile::is_unisolid (  )  const [inline]

Checks the UNISOLID attribute.

Returns "true" if set, "false" otherwise.

Definition at line 159 of file tile.hpp.

References attributes, and UNISOLID.

Referenced by Sector::collision_tilemap(), and Sector::is_free_of_tiles().

00160   {
00161     return attributes & UNISOLID;
00162   }

void Tile::print_debug ( int  id  )  const

Definition at line 142 of file tile.cpp.

References editor_imagespecs, getAttributes(), getData(), imagespecs, and log_debug.

00143 {
00144   log_debug << " Tile: id " << id << ", data " << getData() << ", attributes " << getAttributes() << ":" << std::endl;
00145   for(std::vector<Tile::ImageSpec>::const_iterator im = editor_imagespecs.begin(); im != editor_imagespecs.end(); ++im) 
00146     log_debug << "  Editor Imagespec: file " << im->file << "; rect " << im->rect << std::endl;
00147   for(std::vector<Tile::ImageSpec>::const_iterator im = imagespecs.begin(); im != imagespecs.end(); ++im) 
00148     log_debug << "  Imagespec:        file " << im->file << "; rect " << im->rect << std::endl;
00149 }

void Tile::correct_attributes (  )  [private]

Definition at line 131 of file tile.cpp.

References attributes, imagespecs, log_warning, SLOPE, SOLID, and UNISOLID.

Referenced by Tile().

00132 {
00133   //Fix little oddities in attributes (not many, currently...)
00134   if(!(attributes & SOLID) && (attributes & SLOPE || attributes & UNISOLID)) {
00135     attributes |= SOLID;
00136     //But still be vocal about it
00137     log_warning << "Tile with image " << imagespecs[0].file << " needs solid attribute." << std::endl;
00138   }
00139 }

bool Tile::check_movement_unisolid ( const Vector  movement  )  const [private]

Returns zero if a unisolid tile is non-solid due to the movement direction, non-zero if the tile is solid due to direction.

Definition at line 157 of file tile.cpp.

References AATriangle::DEFORM_BOTTOM, AATriangle::DEFORM_LEFT, AATriangle::DEFORM_MASK, AATriangle::DEFORM_RIGHT, AATriangle::DEFORM_TOP, AATriangle::DIRECTION_MASK, getData(), AATriangle::NORTHEAST, AATriangle::NORTHWEST, AATriangle::SOUTHEAST, AATriangle::SOUTHWEST, UNI_DIR_EAST, UNI_DIR_MASK, UNI_DIR_NORTH, UNI_DIR_SOUTH, UNI_DIR_WEST, Vector::x, and Vector::y.

Referenced by is_solid().

00158 {
00159   int slope_info;
00160   double mv_x;
00161   double mv_y;
00162   double mv_tan;
00163   double slope_tan;
00164 
00165   /* If the tile is not a slope, this is very easy. */
00166   if (!this->is_slope())
00167   {
00168     int dir = this->getData() & Tile::UNI_DIR_MASK;
00169 
00170     return ((dir == Tile::UNI_DIR_NORTH) && (movement.y >= 0))  /* moving down */
00171         || ((dir == Tile::UNI_DIR_SOUTH) && (movement.y <= 0))  /* moving up */
00172         || ((dir == Tile::UNI_DIR_WEST ) && (movement.x >= 0))  /* moving right */
00173         || ((dir == Tile::UNI_DIR_EAST ) && (movement.x <= 0)); /* moving left */
00174   }
00175 
00176   /* Initialize mv_x and mv_y. Depending on the slope the axis are inverted so
00177    * that we can always use the "SOUTHEAST" case of the slope. The southeast
00178    * case is the following:
00179    *     .
00180    *    /!
00181    *   / !
00182    *  +--+
00183    */
00184   mv_x = (double) movement.x; //note switch to double for no good reason
00185   mv_y = (double) movement.y;
00186 
00187   slope_info = this->getData();
00188   switch (slope_info & AATriangle::DIRECTION_MASK)
00189   {
00190     case AATriangle::SOUTHEAST: /*    . */
00191       /* do nothing */          /*   /! */
00192       break;                    /*  / ! */
00193                                 /* +--+ */
00194     case AATriangle::SOUTHWEST: /* .    */
00195       mv_x *= (-1.0);           /* !\   */
00196       break;                    /* ! \  */
00197                                 /* +--+ */
00198     case AATriangle::NORTHEAST: /* +--+ */
00199       mv_y *= (-1.0);           /*  \ ! */
00200       break;                    /*   \! */
00201                                 /*    ' */
00202     case AATriangle::NORTHWEST: /* +--+ */
00203       mv_x *= (-1.0);           /* ! /  */
00204       mv_y *= (-1.0);           /* !/   */
00205       break;                    /* '    */
00206   } /* switch (slope_info & DIRECTION_MASK) */
00207 
00208   /* Handle the easy cases first */
00209   /* If we're moving to the right and down, then the slope is solid. */
00210   if ((mv_x >= 0.0) && (mv_y >= 0.0)) /* 4th quadrant */
00211     return true;
00212   /* If we're moving to the left and up, then the slope is not solid. */
00213   else if ((mv_x <= 0.0) && (mv_y <= 0.0)) /* 2nd quadrant */
00214     return false;
00215 
00216   /* The pure up-down and left-right movements have already been handled. */
00217   assert (mv_x != 0.0);
00218   assert (mv_y != 0.0);
00219 
00220   /* calculate tangent of movement */
00221   mv_tan = (-1.0) * mv_y / mv_x;
00222 
00223   /* determine tangent of the slope */
00224   slope_tan = 1.0;
00225   if (((slope_info & AATriangle::DEFORM_MASK) == AATriangle::DEFORM_BOTTOM)
00226       || ((slope_info & AATriangle::DEFORM_MASK) == AATriangle::DEFORM_TOP))
00227     slope_tan = 0.5; /* ~= 26.6 deg */
00228   else if (((slope_info & AATriangle::DEFORM_MASK) == AATriangle::DEFORM_LEFT)
00229       || ((slope_info & AATriangle::DEFORM_MASK) == AATriangle::DEFORM_RIGHT))
00230     slope_tan = 2.0; /* ~= 63.4 deg */
00231 
00232   /* up and right */
00233   if (mv_x > 0.0) /* 1st quadrant */
00234   {
00235     assert (mv_y < 0.0);
00236     return (mv_tan <= slope_tan);
00237   }
00238   /* down and left */
00239   else if (mv_x < 0.0) /* 3rd quadrant */
00240   {
00241     assert (mv_y > 0.0);
00242     return (mv_tan >= slope_tan);
00243   }
00244 
00245   assert (1 != 1);
00246   return false;
00247 } /* int check_movement_unisolid */

bool Tile::check_position_unisolid ( const Rectf obj_bbox,
const Rectf tile_bbox 
) const [private]

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.

Definition at line 265 of file tile.cpp.

References AATriangle::DEFORM_BOTTOM, AATriangle::DEFORM_LEFT, AATriangle::DEFORM_MASK, AATriangle::DEFORM_RIGHT, AATriangle::DEFORM_TOP, AATriangle::DIRECTION_MASK, Rectf::get_bottom(), Rectf::get_left(), Rectf::get_right(), Rectf::get_top(), getData(), is_above_line(), is_below_line(), AATriangle::NORTHEAST, AATriangle::NORTHWEST, SHIFT_DELTA, AATriangle::SOUTHEAST, AATriangle::SOUTHWEST, UNI_DIR_EAST, UNI_DIR_MASK, UNI_DIR_NORTH, UNI_DIR_SOUTH, and UNI_DIR_WEST.

Referenced by is_solid().

00267 {
00268   int slope_info;
00269   float tile_x;
00270   float tile_y;
00271   float gradient;
00272   float delta_x;
00273   float delta_y;
00274   float obj_x;
00275   float obj_y;
00276 
00277   /* If this is not a slope, this is - again - easy */
00278   if (!this->is_slope())
00279   {
00280     int dir = this->getData() & Tile::UNI_DIR_MASK;
00281 
00282     return ((dir == Tile::UNI_DIR_NORTH) && ((obj_bbox.get_bottom() - SHIFT_DELTA) <= tile_bbox.get_top()   ))
00283         || ((dir == Tile::UNI_DIR_SOUTH) && ((obj_bbox.get_top()    + SHIFT_DELTA) >= tile_bbox.get_bottom()))
00284         || ((dir == Tile::UNI_DIR_WEST ) && ((obj_bbox.get_right()  - SHIFT_DELTA) <= tile_bbox.get_left()  ))
00285         || ((dir == Tile::UNI_DIR_EAST ) && ((obj_bbox.get_left()   + SHIFT_DELTA) >= tile_bbox.get_right() ));
00286   }
00287 
00288   /* There are 20 different cases. For each case, calculate a line that
00289    * describes the slope's surface. The line is defined by x, y, and m, the
00290    * gradient. */
00291   slope_info = this->getData();
00292   switch (slope_info
00293       & (AATriangle::DIRECTION_MASK | AATriangle::DEFORM_MASK))
00294   {
00295     case AATriangle::SOUTHWEST:
00296     case AATriangle::SOUTHWEST | AATriangle::DEFORM_TOP:
00297     case AATriangle::SOUTHWEST | AATriangle::DEFORM_LEFT:
00298     case AATriangle::NORTHEAST:
00299     case AATriangle::NORTHEAST | AATriangle::DEFORM_TOP:
00300     case AATriangle::NORTHEAST | AATriangle::DEFORM_LEFT:
00301       tile_x = tile_bbox.get_left();
00302       tile_y = tile_bbox.get_top();
00303       gradient = 1.0;
00304       break;
00305 
00306     case AATriangle::SOUTHEAST:
00307     case AATriangle::SOUTHEAST | AATriangle::DEFORM_TOP:
00308     case AATriangle::SOUTHEAST | AATriangle::DEFORM_RIGHT:
00309     case AATriangle::NORTHWEST:
00310     case AATriangle::NORTHWEST | AATriangle::DEFORM_TOP:
00311     case AATriangle::NORTHWEST | AATriangle::DEFORM_RIGHT:
00312       tile_x = tile_bbox.get_right();
00313       tile_y = tile_bbox.get_top();
00314       gradient = -1.0;
00315       break;
00316 
00317     case AATriangle::SOUTHEAST | AATriangle::DEFORM_BOTTOM:
00318     case AATriangle::SOUTHEAST | AATriangle::DEFORM_LEFT:
00319     case AATriangle::NORTHWEST | AATriangle::DEFORM_BOTTOM:
00320     case AATriangle::NORTHWEST | AATriangle::DEFORM_LEFT:
00321       tile_x = tile_bbox.get_left();
00322       tile_y = tile_bbox.get_bottom();
00323       gradient = -1.0;
00324       break;
00325 
00326     case AATriangle::SOUTHWEST | AATriangle::DEFORM_BOTTOM:
00327     case AATriangle::SOUTHWEST | AATriangle::DEFORM_RIGHT:
00328     case AATriangle::NORTHEAST | AATriangle::DEFORM_BOTTOM:
00329     case AATriangle::NORTHEAST | AATriangle::DEFORM_RIGHT:
00330       tile_x = tile_bbox.get_right();
00331       tile_y = tile_bbox.get_bottom();
00332       gradient = 1.0;
00333       break;
00334 
00335     default:
00336       assert (23 == 42);
00337       return 0;
00338   }
00339 
00340   /* delta_x, delta_y: Gradient aware version of SHIFT_DELTA. Here, we set the
00341    * sign of the values only. Also, we determine here which corner of the
00342    * object's bounding box is the interesting one for us. */
00343   delta_x = 1.0 * SHIFT_DELTA;
00344   delta_y = 1.0 * SHIFT_DELTA;
00345   switch (slope_info & AATriangle::DIRECTION_MASK)
00346   {
00347     case AATriangle::SOUTHWEST:
00348       delta_x *= 1.0;
00349       delta_y *= -1.0;
00350       obj_x = obj_bbox.get_left();
00351       obj_y = obj_bbox.get_bottom();
00352       break;
00353 
00354     case AATriangle::SOUTHEAST:
00355       delta_x *= -1.0;
00356       delta_y *= -1.0;
00357       obj_x = obj_bbox.get_right();
00358       obj_y = obj_bbox.get_bottom();
00359       break;
00360 
00361     case AATriangle::NORTHWEST:
00362       delta_x *= 1.0;
00363       delta_y *= 1.0;
00364       obj_x = obj_bbox.get_left();
00365       obj_y = obj_bbox.get_top();
00366       break;
00367 
00368     case AATriangle::NORTHEAST:
00369       delta_x *= -1.0;
00370       delta_y *= 1.0;
00371       obj_x = obj_bbox.get_right();
00372       obj_y = obj_bbox.get_top();
00373       break;
00374   }
00375 
00376   /* Adapt the delta_x, delta_y and the gradient for the 26.6 deg and 63.4 deg
00377    * cases. */
00378   switch (slope_info & AATriangle::DEFORM_MASK)
00379   {
00380     case 0:
00381       delta_x *= .70710678118654752440; /* 1/sqrt(2) */
00382       delta_y *= .70710678118654752440; /* 1/sqrt(2) */
00383       break;
00384 
00385     case AATriangle::DEFORM_BOTTOM:
00386     case AATriangle::DEFORM_TOP:
00387       delta_x *= .44721359549995793928; /* 1/sqrt(5) */
00388       delta_y *= .89442719099991587856; /* 2/sqrt(5) */
00389       gradient *= 0.5;
00390       break;
00391 
00392     case AATriangle::DEFORM_LEFT:
00393     case AATriangle::DEFORM_RIGHT:
00394       delta_x *= .89442719099991587856; /* 2/sqrt(5) */
00395       delta_y *= .44721359549995793928; /* 1/sqrt(5) */
00396       gradient *= 2.0;
00397       break;
00398   }
00399 
00400   /* With a south slope, check if all points are above the line. If one point
00401    * isn't, the slope is not solid. => You can pass through a south-slope from
00402    * below but not from above. */
00403   if (((slope_info & AATriangle::DIRECTION_MASK) == AATriangle::SOUTHWEST)
00404    || ((slope_info & AATriangle::DIRECTION_MASK) == AATriangle::SOUTHEAST))
00405   {
00406     return !is_below_line(tile_x, tile_y, gradient, obj_x + delta_x, obj_y + delta_y);
00407   }
00408   /* northwest or northeast. Same as above, but inverted. You can pass from top
00409    * to bottom but not vice versa. */
00410   else
00411   {
00412     return !is_above_line (tile_x, tile_y, gradient, obj_x + delta_x, obj_y + delta_y);
00413   }
00414 } /* int check_position_unisolid */

Tile& Tile::operator= ( const Tile  )  [private]


Member Data Documentation

bool Tile::draw_editor_images [static]

Definition at line 34 of file tile.hpp.

Referenced by scripting::debug_draw_editor_images(), and draw().

std::vector<ImageSpec> Tile::imagespecs [private]

Definition at line 105 of file tile.hpp.

Referenced by correct_attributes(), load_images(), and print_debug().

std::vector<SurfacePtr> Tile::images [private]

Definition at line 106 of file tile.hpp.

Referenced by draw(), and load_images().

std::vector<ImageSpec> Tile::editor_imagespecs [private]

Definition at line 107 of file tile.hpp.

Referenced by load_images(), and print_debug().

std::vector<SurfacePtr> Tile::editor_images [private]

Definition at line 108 of file tile.hpp.

Referenced by draw(), and load_images().

uint32_t Tile::attributes [private]

tile attributes

Definition at line 111 of file tile.hpp.

Referenced by correct_attributes(), getAttributes(), is_slope(), is_solid(), and is_unisolid().

int Tile::data [private]

General purpose data attached to a tile (content of a box, type of coin).

Definition at line 114 of file tile.hpp.

Referenced by getData().

float Tile::fps [private]

Definition at line 116 of file tile.hpp.

Referenced by draw().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:37 2014 for SuperTux by  doxygen 1.5.1