Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int x = 0;
- int y = 0;
- int z = 0;
- color RED = color(255, 0, 0);
- color WHITE = color(255, 255, 255);
- color BLACK = color(0, 0, 0);
- int wr = 100;
- circle[] r1 = {new circle (wr/2 + wr, wr/2, wr, RED, BLACK),
- new circle (wr/2 + wr*3, wr/2, wr, RED, BLACK),
- new circle (wr/2 + wr*5, wr/2, wr, RED, BLACK),
- new circle (wr/2 + wr*7, wr/2, wr, RED, BLACK)};
- circle[] r2 = {new circle (wr/2, wr*1.5, wr, RED, BLACK),
- new circle (wr/2 + wr*2, wr*1.5, wr, RED, BLACK),
- new circle (wr/2 + wr*4, wr*1.5, wr, RED, BLACK),
- new circle (wr/2 + wr*6, wr*1.5, wr, RED, BLACK)};
- circle[] r3 = {new circle (wr/2 + wr, wr*2.5, wr, RED, BLACK),
- new circle (wr/2 + wr*3, wr*2.5, wr, RED, BLACK),
- new circle (wr/2 + wr*5, wr*2.5, wr, RED, BLACK),
- new circle (wr/2 + wr*7, wr*2.5, wr, RED, BLACK)};
- circle[] b1 = {new circle (wr/2, wr*5.5, wr, BLACK, WHITE),
- new circle (wr/2 + wr*2, wr*5.5, wr, BLACK, WHITE),
- new circle (wr/2 + wr*4, wr*5.5, wr, BLACK, WHITE),
- new circle (wr/2 + wr*6, wr*5.5, wr, BLACK, WHITE)};
- circle[] b2 = {new circle (wr/2 + wr, wr*6.5, wr, BLACK, WHITE),
- new circle (wr/2 + wr*3, wr*6.5, wr, BLACK, WHITE),
- new circle (wr/2 + wr*5, wr*6.5, wr, BLACK, WHITE),
- new circle (wr/2 + wr*7, wr*6.5, wr, BLACK, WHITE)};
- circle[] b3 = {new circle (wr/2, wr*7.5, wr, BLACK, WHITE),
- new circle (wr/2 + wr*2, wr*7.5, wr, BLACK, WHITE),
- new circle (wr/2 + wr*4, wr*7.5, wr, BLACK, WHITE),
- new circle (wr/2 + wr*6, wr*7.5, wr, BLACK, WHITE)};
- void setup() {
- background(WHITE);
- size(800, 800);
- starting_table();
- }
- void draw () {
- if (keyPressed && key == 'r') {
- starting_table();
- }
- }
- void mousePressed() {
- for (int i = 0; i <=3; i++) {
- r3[i].move_cherveni();
- }
- }
- class circle {
- float coorX;
- float coorY;
- float radius;
- color c;
- color b;
- circle (float tempCoorX, float tempCoorY, float tempRadius, color tempC, color tempB ) {
- coorX = tempCoorX;
- coorY = tempCoorY;
- radius = tempRadius;
- c = tempC;
- b = tempB;
- }
- void draw_ellipse () {
- fill(c);
- stroke(b);
- ellipse(coorX, coorY, radius, radius);
- }
- void move_cherveni() {
- //can_move();
- nadolu_lqvo();
- nadolu_dqsno();
- if (coorY == height - radius/2) {
- fill(255, 255, 255);
- ellipse(coorX, coorY, radius/2, radius/2);
- nagore_dqsno();
- nagore_lqvo();
- }
- }
- void move_cherni() {
- nagore_lqvo();
- nagore_dqsno();
- if (coorY == 0 + radius/2) {
- fill(255, 255, 255);
- ellipse(coorX, coorY, radius/2, radius/2);
- nagore_dqsno();
- nagore_lqvo();
- }
- }
- void nadolu_dqsno() {
- if ( mouseX>coorX-radius/2+100 && mouseX<coorX+radius/2+100 && mouseY>coorY-radius/2+100 && mouseY<coorY+radius/2+100)
- {
- noStroke();
- fill(0, 0, 0);
- ellipse(coorX, coorY, radius, radius);
- println(" raboti");
- coorX +=100;
- coorY+=100;
- draw_ellipse();
- }
- }
- void nadolu_lqvo() {
- if ( mouseX>coorX-radius/2-100 && mouseX<coorX+radius/2-100 && mouseY>coorY-radius/2+100 && mouseY<coorY+radius/2+100)
- {
- noStroke();
- fill(0, 0, 0);
- ellipse(coorX, coorY, radius, radius);
- println(" raboti");
- coorX -=100;
- coorY+=100;
- draw_ellipse();
- }
- }
- void nagore_dqsno() {
- if (mouseX>coorX+radius/2 && mouseX<coorX +radius/2 + 100 && mouseY>coorY-radius/2 -100 && mouseY<coorY-radius/2) {
- noStroke();
- fill(0, 0, 0);
- ellipse(coorX, coorY, radius, radius);
- println(" raboti");
- coorX +=100;
- coorY-=100;
- draw_ellipse();
- }
- }
- void nagore_lqvo() {
- if (mouseX>coorX-radius/2-100 && mouseX<coorX -radius/2 && mouseY>coorY-radius/2 -100 && mouseY<coorY-radius/2) {
- noStroke();
- fill(0, 0, 0);
- ellipse(coorX, coorY, radius, radius);
- println(" raboti");
- coorX -=100;
- coorY-=100;
- draw_ellipse();
- }
- }
- }
- void can_move() {
- /* for (int j =0; j <=2; j++) {
- for (int i = 0; i <=3; i++){
- float [] red_coorsX = {r1[i].coorX,
- r2[i].coorX,
- r3[i].coorX};
- float [] red_coorsY = {r1[i].coorY,
- r2[i].coorY,
- r3[i].coorY};
- if (//dist(coorX, coorY, red_coorsX[j], red_coorsY[j] ) > 142)
- red_coorsX[j] == coorX - 100 && red_coorsY[j] == coorY -100 ||
- red_coorsX[j] == coorX - 100 && red_coorsY[j] == coorY +100 ||
- red_coorsX[j] == coorX - 100 && red_coorsY[j] == coorY +100 ||
- red_coorsX[j] == coorX + 100 && red_coorsY[j] == coorY +100)
- {
- println(red_coorsX);
- println(red_coorsY);
- nadolu_dqsno();
- }
- }
- }*/
- }
- void starting_table() {
- int wr=width/8;
- background(WHITE);
- for ( x = 0; x<width; x+=wr) {
- for (y = 0; y< height; y+= wr) {
- if ((z) % 2 != 0) {
- fill(BLACK);
- } else {
- fill(WHITE);
- }
- z++;
- rect(x, y, wr, wr);
- }
- z++;
- }
- for (int i = 0; i<=3; i++) {
- r1[i].draw_ellipse();
- r2[i].draw_ellipse();
- r3[i].draw_ellipse();
- b1[i].draw_ellipse();
- b2[i].draw_ellipse();
- b3[i].draw_ellipse();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement