Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. super.paintComponent(g);
  2. int currentX = x;
  3. int currentY = y;
  4.  
  5.  
  6. double currentWidth = width;
  7. double currentHeight = height;
  8.  
  9.  
  10. =========================================================================
  11.  
  12. Also die breite und länge soll je nach Größe des Spielfeldes halt etwas verkleinert oder vergrößert werden, z.B. wenns 3 Felder
  13. sind soll breite und länge 200 sein, aber bei 9 felder nur noch ein drittel wenn du verstehst was ich meine, mir fällt einfach
  14. nicht wirklich eine methode ein wie ich das propotional machen kann, habs jetzt erstmal so gemacht was "RELATIV" geht aber trotzdem
  15. halt nicht Pefekt ist.
  16.  
  17. if(size <= 6) {
  18. currentWidth = (double)width - ((double)width * ((double)size/10));
  19. currentHeight = (double)height - ((double)height * ((double)size/10));
  20. System.out.println(currentWidth);
  21. } else if (size > 6 && size < 10) {
  22. currentWidth = (double)width - ((double)width * ((double)size/10));
  23. currentHeight = (double)height - ((double)height * ((double)size/10));
  24. currentWidth = currentWidth*2;
  25. currentHeight = currentHeight*2;
  26. } else if(size > 10 && size < 13) {
  27. currentWidth = (double)width - ((double)width * ((double)size/15));
  28. currentHeight = (double)height - ((double)height * ((double)size/15));
  29. currentWidth = currentWidth*1.2;
  30. currentHeight = currentHeight*1.2;
  31. } else {
  32. System.out.println("mistake");
  33. }
  34. System.out.println(currentWidth);
  35. ================================================================================
  36.  
  37. ((Graphics2D) g).setStroke(new BasicStroke(10));
  38. g.setColor(Color.BLACK);
  39. for(int i = 0; i < size; i++) {
  40. for(int j = 0; j < size; j++) {
  41. g.drawRect(currentX, currentY, (int)currentWidth, (int)currentHeight);
  42.  
  43. currentX +=currentWidth;
  44. }
  45. currentX = x;
  46. currentY +=currentHeight;
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement