int TileMap::getTile(int x, int y) { if (x < 0) { x = 0; } if (y < 0) { y = 0; } if (x >= getWidth()) { x = getWidth() - 1; } if (y >= getHeight()) { y = getHeight() - 1; } int pixel = _getpixel24(mTileMapBitmap, x, y); return getr24(pixel) | (getg24(pixel) << 8); }
void TileMap::setTileFlags(int x, int y, int flags) { if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight()) { return; } int pixel = _getpixel24(mTileMapBitmap, x, y); int newPixel = makecol24(getr24(pixel), getg24(pixel), flags); _putpixel24(mTileMapBitmap, x, y, newPixel); }
void TileMap::setTile(int x, int y, int tileNumber) { if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight()) { return; } int pixel = _getpixel24(mTileMapBitmap, x, y); int newPixel = makecol24(tileNumber, getg24(pixel), getb24(pixel)); _putpixel24(mTileMapBitmap, x, y, newPixel); }
void rsave(BITMAP * bmp, int x, int y, int d) { /* save pixel information into array */ // clipping if (x < GUIWIDTH || x >= XMAX || y < 0 || y >= YMAX) return; savedpixels[pos_sp].x = x; savedpixels[pos_sp].y = y; savedpixels[pos_sp].color = _getpixel24(bmp, x, y); pos_sp++; /* Doing this will remove the need to call circle again */ _putpixel24(bmp, x, y, d); }
int Bitmap::GetPixel(int x, int y) const { if (x < 0 || x >= _alBitmap->w || y < 0 || y >= _alBitmap->h) { return -1; // Allegros getpixel() implementation returns -1 in this case } switch (bitmap_color_depth(_alBitmap)) { case 8: return _getpixel(_alBitmap, x, y); case 15: return _getpixel15(_alBitmap, x, y); case 16: return _getpixel16(_alBitmap, x, y); case 24: return _getpixel24(_alBitmap, x, y); case 32: return _getpixel32(_alBitmap, x, y); } assert(0); // this should not normally happen return getpixel(_alBitmap, x, y); }
int TileMap::getTileEntity(int x, int y) { if (x < 0) { x = 0; } if (y < 0) { y = 0; } if (x >= getWidth()) { x = getWidth() - 1; } if (y >= getHeight()) { y = getHeight() - 1; } return _getpixel24(mEntityMapBitmap, x, y); }
int TileMap::getTileFlags(int x, int y) { if (x < 0) { x = 0; } if (y < 0) { y = 0; } if (x >= getWidth()) { x = getWidth() - 1; } if (y >= getHeight()) { y = getHeight() - 1; } return getb24(_getpixel24(mTileMapBitmap, x, y)); }