public element_big obroc(int alfa) { if (alfa != 0 && alfa != 90 && alfa != 180 && alfa != 270) return this; element_big nowy = new element_big(); nowy.kat = alfa; nowy.kolor = kolor; nowy.ktory = ktory; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) nowy.tablica[i, j] = false; switch (ktory) { case klocek.I: switch (alfa) { case 0: nowy.tablica[0, 0] = nowy.tablica[0, 1] = nowy.tablica[0, 2] = nowy.tablica[0, 3] = true; break; case 180: nowy.tablica[0, 0] = nowy.tablica[0, 1] = nowy.tablica[0, 2] = nowy.tablica[0, 3] = true; break; case 90: nowy.tablica[0, 0] = nowy.tablica[1, 0] = nowy.tablica[2, 0] = nowy.tablica[3, 0] = true; break; case 270: nowy.tablica[0, 0] = nowy.tablica[1, 0] = nowy.tablica[2, 0] = nowy.tablica[3, 0] = true; break; } break; case klocek.kwadrat: nowy.tablica[0, 0] = nowy.tablica[1, 0] = nowy.tablica[0, 1] = nowy.tablica[1, 1] = true; break; case klocek.podium: switch (alfa) { case 0: nowy.tablica[1, 0] = nowy.tablica[1, 1] = nowy.tablica[0, 1] = nowy.tablica[2, 1] = true; break; case 90: nowy.tablica[0, 0] = nowy.tablica[0, 1] = nowy.tablica[0, 2] = nowy.tablica[1, 1] = true; break; case 180: nowy.tablica[0, 0] = nowy.tablica[1, 0] = nowy.tablica[2, 0] = nowy.tablica[1, 1] = true; break; case 270: nowy.tablica[1, 0] = nowy.tablica[1, 1] = nowy.tablica[0, 1] = nowy.tablica[1, 2] = true; break; } break; case klocek.L: switch (alfa) { case 0: nowy.tablica[0, 0] = nowy.tablica[0, 1] = nowy.tablica[0, 2] = nowy.tablica[1, 2] = true; break; case 90: nowy.tablica[0, 0] = nowy.tablica[1, 0] = nowy.tablica[0, 1] = nowy.tablica[2, 0] = true; break; case 180: nowy.tablica[0, 0] = nowy.tablica[1, 0] = nowy.tablica[1, 1] = nowy.tablica[1, 2] = true; break; case 270: nowy.tablica[0, 1] = nowy.tablica[2, 0] = nowy.tablica[1, 1] = nowy.tablica[2, 1] = true; break; } break; case klocek.L_revers: switch (alfa) { case 0: nowy.tablica[1, 0] = nowy.tablica[1, 1] = nowy.tablica[1, 2] = nowy.tablica[0, 2] = true; break; case 90: nowy.tablica[0, 0] = nowy.tablica[0, 1] = nowy.tablica[1, 1] = nowy.tablica[2, 1] = true; break; case 180: nowy.tablica[0, 0] = nowy.tablica[0, 1] = nowy.tablica[1, 0] = nowy.tablica[0, 2] = true; break; case 270: nowy.tablica[0, 0] = nowy.tablica[1, 0] = nowy.tablica[2, 0] = nowy.tablica[2, 1] = true; break; } break; case klocek.Z: switch (alfa) { case 0: nowy.tablica[0, 0] = nowy.tablica[0, 1] = nowy.tablica[1, 1] = nowy.tablica[1, 2] = true; break; case 180: nowy.tablica[0, 0] = nowy.tablica[0, 1] = nowy.tablica[1, 1] = nowy.tablica[1, 2] = true; break; case 90: nowy.tablica[1, 0] = nowy.tablica[0, 1] = nowy.tablica[2, 0] = nowy.tablica[1, 1] = true; break; case 270: nowy.tablica[1, 0] = nowy.tablica[0, 1] = nowy.tablica[2, 0] = nowy.tablica[1, 1] = true; break; } break; case klocek.Z_revers: switch (alfa) { case 0: nowy.tablica[1, 0] = nowy.tablica[1, 1] = nowy.tablica[0, 1] = nowy.tablica[0, 2] = true; break; case 180: nowy.tablica[1, 0] = nowy.tablica[1, 1] = nowy.tablica[0, 1] = nowy.tablica[0, 2] = true; break; case 90: nowy.tablica[0, 0] = nowy.tablica[1, 0] = nowy.tablica[1, 1] = nowy.tablica[2, 1] = true; break; case 270: nowy.tablica[0, 0] = nowy.tablica[1, 0] = nowy.tablica[1, 1] = nowy.tablica[2, 1] = true; break; } break; } return nowy; }
public bool rysujklocek(int x, int y, element_big f) { if (!sprawdz(x, y)) return false; int i, j; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) if (f.tablica[i, j]) { if (!sprawdz(x + i, y + j)) return false; if (tablica[x + i, y + j].spr()) return false; } polozenie_x = x; polozenie_y = y; if (klocek != f) klocek = f; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) if (f.tablica[i, j]) { tablica[x + i, y + j].setkolor(f.kolor); rysuj(x + i, y + j); } return true; }