PieceSet::PieceSet() { for (int i = 0; i < NUM_PIECES; i++) for (int j = 0; j < NUM_ROTATIONS; j++) pieces[i][j] = 0; POINT apt[NUM_ROTATIONS]; // 0, I piece, red apt[0].x = 0; apt[0].y = 0; apt[1].x = 0; apt[1].y = 1; apt[2].x = 0; apt[2].y = 2; apt[3].x = 0; apt[3].y = 3; pieces[0][0] = new Piece(0, 0, RGB(255,0,0), apt); // 1, L piece, orange apt[0].x = 0; apt[0].y = 0; apt[1].x = 1; apt[1].y = 0; apt[2].x = 0; apt[2].y = 1; apt[3].x = 0; apt[3].y = 2; pieces[1][0] = new Piece(1, 0, RGB(230,130,24), apt); // 2, counter-L piece, yellow apt[0].x = 0; apt[0].y = 0; apt[1].x = 1; apt[1].y = 0; apt[2].x = 1; apt[2].y = 1; apt[3].x = 1; apt[3].y = 2; pieces[2][0] = new Piece(2, 0, RGB(255,255,0), apt); // 3, S piece, green apt[0].x = 0; apt[0].y = 0; apt[1].x = 1; apt[1].y = 0; apt[2].x = 1; apt[2].y = 1; apt[3].x = 2; apt[3].y = 1; pieces[3][0] = new Piece(3, 0, RGB(120,200,80), apt); // 4, Z piece, blue apt[0].x = 1; apt[0].y = 0; apt[1].x = 2; apt[1].y = 0; apt[2].x = 0; apt[2].y = 1; apt[3].x = 1; apt[3].y = 1; pieces[4][0] = new Piece(4, 0, RGB(100,180,255), apt); // 5, Square piece, dark blue apt[0].x = 0; apt[0].y = 0; apt[1].x = 1; apt[1].y = 0; apt[2].x = 0; apt[2].y = 1; apt[3].x = 1; apt[3].y = 1; pieces[5][0] = new Piece(5, 0, RGB(20,100,200), apt); // 6, T piece, purple apt[0].x = 0; apt[0].y = 0; apt[1].x = 1; apt[1].y = 0; apt[2].x = 2; apt[2].y = 0; apt[3].x = 1; apt[3].y = 1; pieces[6][0] = new Piece(6, 0, RGB(220,180,255), apt); // Create piece rotations rotateAll(); }
int main() { /* request autodetection */ int gdriver = DETECT, gmode; /* initialize graphics mode */ initgraph(&gdriver, &gmode, ""); drawAxis(WHITE); Point o = {0,0}; Circle c = {o,130}; c.bressenPlot(RED); Point p[NUM_VERTICES]= { Point{129,10}, Point{28,10}, Point{-28,10}, Point{-129,10}, Point{129,-10}, Point{28,-10}, Point{-28,-10}, Point{-129,-10}, Point{10,129}, Point{10,28}, Point{10,-129}, Point{10, -28}, Point{-10,129}, Point{-10,28}, Point{-10,-129}, Point{-10, -28} }; Circle inCircle = {o, 30}; inCircle.bressenPlot(RED); seedFill4(o, RED, RED); double theta = -(3.142857*10)/180.0; do { for(int i = 0; i<16; i+=2) { Line l = Line {p[i], p[i+1]}; l.plotLineDDA(YELLOW); } delay(15); for(int i = 0; i<16; i+=2) { Line l = Line {p[i], p[i+1]}; l.plotLineDDA(BLACK); } rotateAll(p, theta); c.bressenPlot(RED); } while(1); getch(); closegraph(); return 0; }