Advertisement
Guest User

Untitled

a guest
Apr 27th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.72 KB | None | 0 0
  1. import java.util.Random;
  2. import java.awt.*;
  3. public class MovingChecker extends MovingRectangle {
  4.     Random xvalue = new Random();
  5.     int XRandom = 2 + xvalue.nextInt(11);
  6.  
  7.     //Random yvalue = new Random();
  8.     int YRandom = 2 + xvalue.nextInt(11);
  9.  
  10.  
  11.     public MovingChecker(){
  12.         super();
  13.     }
  14.  
  15.       public MovingChecker(int x, int y, int w, int h, int mw, int mh,Color fillColor, Color borderColor, int pathType) {
  16.       super(x ,y ,w ,h ,mw ,mh , fillColor,  borderColor, pathType);
  17.   }
  18.  
  19.  
  20.   public void draw(Graphics g){
  21.     //boolean FirstFilled = true;
  22.     //boolean SecondSquare = false;
  23.       int row;
  24.       int col;
  25.      
  26.  
  27.       for ( row = 0;  row < YRandom;  row++ ){
  28.          for ( col = 0;  col < XRandom;  col++){
  29.              if ( (row % 2) == (col % 2) ){
  30.                g.setColor(borderColor);
  31.              
  32.              }
  33.             else{
  34.  
  35.                g.setColor(fillColor);
  36.              }
  37.             g.fillRect(topLeft.x + col * width/ XRandom, topLeft.y + row * height / YRandom, width/XRandom, height/YRandom); //x,y
  38.             g.drawRect(topLeft.x + col * width/ XRandom, topLeft.y + row * height / YRandom, width/XRandom, height/YRandom);
  39.           }
  40.         }
  41.       }
  42.     }
  43.  
  44.      
  45.     /*boolean FirstFilled = true;
  46.     boolean SecondSquare = false;
  47.  
  48.     int row, col, numRow, numCol, leftSide, yDown, size;
  49.  
  50.  
  51.     numRow = xrandom;
  52.     numCol = yrandom;
  53.  
  54.     leftSide = 20;
  55.     yDown = 30;
  56.     size = 40;
  57.  
  58.  
  59.     for (row  = 0; row < 8; row ++){
  60.       int xLeft = leftSide;
  61.       boolean isFilled  = FirstFilled;
  62.       for (col = 0; col < 6; col ++){
  63.         if (isFilled == true){
  64.           g.fillRect(xLeft, yDown, xLeft + size, yDown + size);
  65.           g.setColor(fillColor);
  66.  
  67.         }
  68.         else{
  69.           g.fillRect(xLeft, yDown, xLeft + size, yDown + size);
  70.  
  71.         }
  72.  
  73.         xLeft = xLeft + size;
  74.         isFilled = false;
  75.        
  76.       }
  77.       yDown = yDown + size;
  78.       FirstFilled = false;
  79.     }*/
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.         //int tileSize1 = xrandom / width;
  106.     //int tileSize2 = yrandom / height;
  107.  
  108.     /*g.setColor(defaultFillColor);
  109.     g.fillRect(topLeft.x, topLeft.y, width, height);
  110.     g.setColor(defaultBorderColor);
  111.     g.drawRect(topLeft.x, topLeft.y, width, height);
  112.     drawHandles(g);
  113.  
  114.     g.setColor(defaultFillColor);
  115.     g.fillRect(topLeft.y, topLeft.y, width, height);
  116.     g.setColor(defaultBorderColor);
  117.     g.drawRect(topLeft.x, topLeft.x, width, height);
  118.     drawHandles(g);*/
  119.  
  120.     /**g.setColor(fillColor);
  121.     g.fillRect(topLeft.x, topLeft.y, width, height);
  122.  
  123.     g.setColor(borderColor);//second colour
  124.     for( row = 0;  row < 8;  row ++){
  125.       for( col = 0;  col <6;  row ++){
  126.  
  127.       }
  128.       if (row % 2 == col % 2) {
  129.             g.fillRect(row * tileSize1, col * tileSize2, tileSize1, tileSize2);\\\\\\\\\\\\\\\\\\\\\
  130.         }
  131.       drawHandles(g);
  132.  
  133.  
  134.     }*/
  135.  
  136.     /*g.setColor(Color.black);
  137.     g.fillRect(topLeft.x, topLeft.y, width, height);
  138.     g.setColor(defaultBorderColor);
  139.     g.drawRect(topLeft.x, topLeft.y, width, height);
  140.     drawHandles(g);
  141.  
  142.     g.setColor(Color.red);
  143.     g.fillRect(topLeft.x, topLeft.y+width, width, height);
  144.     g.setColor(defaultBorderColor);
  145.     g.drawRect(topLeft.x, topLeft.y+width, width, height);
  146.     drawHandles(g);*/
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.     /*for (row = 0; row < 8; row ++){
  180.         for (col  = 0; col < 6; col ++){
  181.             if (FirstFilled == true){
  182.                 g.setColor(borderColor);//not editing anything
  183.  
  184.             }else if (SecondSquare == false){
  185.                 g.setColor(fillColor);
  186.                
  187.             }
  188.             g.fillRect(topLeft.x, topLeft.y, width, height); //first two parameters  not changed
  189.         }
  190.     }
  191.     drawHandles(g);*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement