Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.awt.*;
- public class MovingChecker extends MovingRectangle {
- Random xvalue = new Random();
- int XRandom = 2 + xvalue.nextInt(11);
- //Random yvalue = new Random();
- int YRandom = 2 + xvalue.nextInt(11);
- public MovingChecker(){
- super();
- }
- public MovingChecker(int x, int y, int w, int h, int mw, int mh,Color fillColor, Color borderColor, int pathType) {
- super(x ,y ,w ,h ,mw ,mh , fillColor, borderColor, pathType);
- }
- public void draw(Graphics g){
- //boolean FirstFilled = true;
- //boolean SecondSquare = false;
- int row;
- int col;
- for ( row = 0; row < YRandom; row++ ){
- for ( col = 0; col < XRandom; col++){
- if ( (row % 2) == (col % 2) ){
- g.setColor(borderColor);
- }
- else{
- g.setColor(fillColor);
- }
- g.fillRect(topLeft.x + col * width/ XRandom, topLeft.y + row * height / YRandom, width/XRandom, height/YRandom); //x,y
- g.drawRect(topLeft.x + col * width/ XRandom, topLeft.y + row * height / YRandom, width/XRandom, height/YRandom);
- }
- }
- }
- }
- /*boolean FirstFilled = true;
- boolean SecondSquare = false;
- int row, col, numRow, numCol, leftSide, yDown, size;
- numRow = xrandom;
- numCol = yrandom;
- leftSide = 20;
- yDown = 30;
- size = 40;
- for (row = 0; row < 8; row ++){
- int xLeft = leftSide;
- boolean isFilled = FirstFilled;
- for (col = 0; col < 6; col ++){
- if (isFilled == true){
- g.fillRect(xLeft, yDown, xLeft + size, yDown + size);
- g.setColor(fillColor);
- }
- else{
- g.fillRect(xLeft, yDown, xLeft + size, yDown + size);
- }
- xLeft = xLeft + size;
- isFilled = false;
- }
- yDown = yDown + size;
- FirstFilled = false;
- }*/
- //int tileSize1 = xrandom / width;
- //int tileSize2 = yrandom / height;
- /*g.setColor(defaultFillColor);
- g.fillRect(topLeft.x, topLeft.y, width, height);
- g.setColor(defaultBorderColor);
- g.drawRect(topLeft.x, topLeft.y, width, height);
- drawHandles(g);
- g.setColor(defaultFillColor);
- g.fillRect(topLeft.y, topLeft.y, width, height);
- g.setColor(defaultBorderColor);
- g.drawRect(topLeft.x, topLeft.x, width, height);
- drawHandles(g);*/
- /**g.setColor(fillColor);
- g.fillRect(topLeft.x, topLeft.y, width, height);
- g.setColor(borderColor);//second colour
- for( row = 0; row < 8; row ++){
- for( col = 0; col <6; row ++){
- }
- if (row % 2 == col % 2) {
- g.fillRect(row * tileSize1, col * tileSize2, tileSize1, tileSize2);\\\\\\\\\\\\\\\\\\\\\
- }
- drawHandles(g);
- }*/
- /*g.setColor(Color.black);
- g.fillRect(topLeft.x, topLeft.y, width, height);
- g.setColor(defaultBorderColor);
- g.drawRect(topLeft.x, topLeft.y, width, height);
- drawHandles(g);
- g.setColor(Color.red);
- g.fillRect(topLeft.x, topLeft.y+width, width, height);
- g.setColor(defaultBorderColor);
- g.drawRect(topLeft.x, topLeft.y+width, width, height);
- drawHandles(g);*/
- /*for (row = 0; row < 8; row ++){
- for (col = 0; col < 6; col ++){
- if (FirstFilled == true){
- g.setColor(borderColor);//not editing anything
- }else if (SecondSquare == false){
- g.setColor(fillColor);
- }
- g.fillRect(topLeft.x, topLeft.y, width, height); //first two parameters not changed
- }
- }
- drawHandles(g);*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement