Advertisement
stolerg

CH 3G Project 3 (Checkers)

Apr 27th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import java.awt.*;
  2. import java.applet.*;
  3. public class Checker extends Applet
  4. {
  5. public void paint(Graphics g)
  6. {
  7. setBackground(Color.CYAN);
  8. Check(g, 0, 0, 100, 5, 1);
  9. Check(g, 20, 150, 40, 3, 10);
  10. Check(g, 475, 40, 70, 4, 5);
  11. }
  12. public static void Check(Graphics g, int x, int y, int size, int b, int c)
  13. {
  14. for (int i=0; i<c; i++)
  15. {
  16. for (int j=0; j<c; j++)
  17. {
  18. drawBoard(g, x+j*size, y+i*size, size, b);
  19. }
  20. }
  21. }
  22. public static void drawBoard(Graphics g, int x, int y, int size, int b)
  23. {
  24. int n = 0;
  25. g.setColor(Color.DARK_GRAY);
  26. g.fillRect(x, y, size, size);
  27. g.setColor(Color.WHITE);
  28. for (int i=0; i<b/2; i++)
  29. {
  30. for (int a=0; a<(b/2)+(b%2); a++)
  31. {
  32. g.fillRect(x+((size/b)*a*2), y+(size/b)*i*2+(size/b), size/b, size/b);
  33. }
  34. }
  35. for (int i=0; i<(b/2)+(b%2); i++)
  36. {
  37. for (int a=0; a<(b/2); a++)
  38. {
  39. g.fillRect(x+((size/b)*a*2)+(size/b), y+(size/b)*i*2, size/b, size/b);
  40. }
  41. }
  42. g.setColor(Color.BLACK);
  43. g.drawRect(x, y, size, size);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement