#include #include "board.h" #include "constant.h" extern RLE_SPRITE *wall[0x20]; extern bool blitWalls; extern BITMAP *vramWall[0x20]; extern bool christmasTime; tile Board::getTile(int x, int y) { x %= boardW; y %= boardH; return content[(x + boardW) % boardW][(y + boardH) % boardH]; } void Board::setTile(int x, int y, tile value) { x %= boardW; y %= boardH; content[(x + boardW) % boardW][(y + boardH) % boardH] = value; } void Board::drawTile(BITMAP *canvas, int x, int y) { x %= boardW; y %= boardH; const int realX = (x + boardW) % boardW, realY = (y + boardH) % boardH; const int x1 = realX * tileSize, y1 = realY * tileSize; const int x2 = x1 + tileSize - 1, y2 = y1 + tileSize - 1; const int centerX = x1 + halfTileSize, centerY = y1 + halfTileSize; const int wallIndex = (christmasTime << 4) | ((getTile(realX, realY - 1) == wallTile) << 3) | ((getTile(realX - 1, realY) == wallTile) << 2) | ((getTile(realX + 1, realY) == wallTile) << 1) | (getTile(realX, realY + 1) == wallTile); rectfill(canvas, x1, y1, x2, y2, 0); switch (content[realX][realY]) { case wallTile: if (blitWalls) blit(vramWall[wallIndex], canvas, 0, 0, x1, y1, tileSize, tileSize); else draw_rle_sprite(canvas, wall[wallIndex], x1, y1); break; case dotTile: _putpixel(canvas, centerX, centerY, 15); break; case energyTile: case forbiddenEnergyTile: case gateEnergyTile: circlefill(canvas, centerX, centerY, energyRadius, 249); } #ifdef DEBUG if (content[realX][realY] == forbiddenTile || content[realX][realY] == forbiddenEnergyTile) { line(canvas, x1, y1, x2, y2, 12); line(canvas, x2, y1, x1, y2, 12); } #endif } void Board::drawBoard(BITMAP *canvas) { for (int x = 0; x < boardW; x++) for (int y = 0; y < boardH; y++) drawTile(canvas, x, y); }