//Maybe send all the colors first and than send run void send_tile(Spot table[][8], int i, int j) { if(table[i][j].fire_lvl == 1) { writeTile(table[i][j].LED_ID, color_fire); } else if(table[i][j].fire_lvl == 0) { writeTile(table[i][j].LED_ID, color_tree); } else if(table[i][j].fire_lvl == -2) { writeTile(table[i][j].LED_ID, color_base); } }
//-------------------------------------------------------------- // update texture tiles with new image void mgXPSurface::updateTiles( int left, int top, int right, int bottom) { GdiFlush(); if (m_singleTile) { writeTile(m_tiles[0], 0, 0, m_imageWidth, m_imageHeight); return; } // break DIBitmap into texture tiles for (int i = 0; i < m_vertTiles; i++) { int ly = i*SURFACE_TILE_SIZE; int ht = min(SURFACE_TILE_SIZE, m_imageHeight - ly); int hy = ly+ht; for (int j = 0; j < m_horzTiles; j++) { int lx = j*SURFACE_TILE_SIZE; int wd = min(SURFACE_TILE_SIZE, m_imageWidth - lx); int hx = lx+wd; // if doesn't intersect the damage rectangle, no need to update if (min(right, hx) < max(left, lx) || min(bottom, hy) < max(top, ly)) continue; writeTile(m_tiles[i*m_horzTiles+j], lx, ly, wd, ht); } } }
bool BackgroundTilesIOPC::writeData(const BackgroundTiles &tiles) const { quint16 nbTiles, depth = 1; int w, h; // Layer 1 QSize area = tiles.area(); w = area.width() + 16; h = area.height() + 16; BackgroundTiles tiles1 = tiles.tiles(0, true); nbTiles = tiles1.size(); device()->write((char *)&w, 2); device()->write((char *)&h, 2); device()->write((char *)&nbTiles, 2); device()->write((char *)&depth, 2); device()->write("\0\0", 2); foreach(const Tile &tile, tiles1) { writeTile(tile); }