#include "Tile.h"
#include "../graphics/Sprite.h"
+#include "../sdl/utility.h"
#include <stdexcept>
destRect.x = inOffset.X();
destRect.y = inOffset.Y();
destRect.w = Width() * tileset->Width();
- destRect.h = 1;
- SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0x00, 0x00, 0xFF));
- destRect.y += Height() * tileset->Height() - 1;
- SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0x00, 0x00, 0xFF));
- destRect.y = inOffset.Y();
- destRect.w = 1;
destRect.h = Height() * tileset->Height();
- SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0x00, 0x00, 0xFF));
- destRect.x += Width() * tileset->Width() - 1;
- SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0x00, 0x00, 0xFF));
+ sdl::OutlineRect(dest, &destRect, SDL_MapRGB(dest->format, 0x00, 0x00, 0xFF));
+
+ Uint32 color(SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
for (int i(0); i < numTiles; ++i) {
Vector<int> offset(
const Tile &tile(tiles[i]);
if (tile.BlocksNorth()) {
- destRect.x = offset.X();
- destRect.y = offset.Y();
- destRect.w = tileset->Width();
- destRect.h = 1;
- SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+ sdl::HorizontalLine(dest, offset, tileset->Width(), color);
}
-
if (tile.BlocksEast()) {
- destRect.x = offset.X() + tileset->Width() - 1;
- destRect.y = offset.Y();
- destRect.w = 1;
- destRect.h = tileset->Height();
- SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+ sdl::VerticalLine(dest, Vector<int>(offset.X() + tileset->Width() - 1, offset.Y()), tileset->Height(), color);
}
-
if (tile.BlocksSouth()) {
- destRect.x = offset.X();
- destRect.y = offset.Y() + tileset->Height() - 1;
- destRect.w = tileset->Width();
- destRect.h = 1;
- SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+ sdl::HorizontalLine(dest, Vector<int>(offset.X(), offset.Y() + tileset->Height() - 1), tileset->Width(), color);
}
-
if (tile.BlocksWest()) {
- destRect.x = offset.X();
- destRect.y = offset.Y();
- destRect.w = 1;
- destRect.h = tileset->Height();
- SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+ sdl::VerticalLine(dest, offset, tileset->Height(), color);
}
}
}