Advertisement
Panqueca

O negosso

Jul 5th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. package pacote;
  2. import java.awt.Toolkit;
  3.  
  4. import javax.swing.JFrame;
  5. public class Classinha {
  6. public static void main(String[] args) {
  7. JFrame j = new JFrame("janelinhaaaa");
  8. j.setSize(300,300); j.setVisible(true); j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);j.setResizable(false);
  9. double d = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
  10. double d2 = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
  11. int up = 0;int right = 0;int rb = 0;int ub = 0;
  12. while (true) {
  13. //System.out.println(j.getLocation()+" "+d+" "+d2+ " "+up+" "+right);
  14.  
  15. int x = j.getLocation().x;
  16. int y = j.getLocation().y;
  17. if (x == 0 && y == 0) {
  18. up = 1;right = 1;ub = 1;rb = 1;
  19. while (cdt(x,y,up,right)) {
  20. j.setLocation(x + right, y + up);
  21. x = j.getLocation().x;
  22. y = j.getLocation().y;
  23. try {
  24. Thread.sleep(5);
  25. } catch (InterruptedException e) {
  26. // TODO Auto-generated catch block
  27. e.printStackTrace();
  28. }
  29. System.out.println(1+" "+j.getLocation()+" "+d+" "+d2+" "+up+" "+right);
  30. }
  31. } else if (y == 468 && x != 1066) {
  32. up = -ub;
  33. while (cdt(x,y,up,right)) {
  34. j.setLocation(x + right, y + up);
  35. x = j.getLocation().x;
  36. y = j.getLocation().y;
  37. try {
  38. Thread.sleep(5);
  39. } catch (InterruptedException e) {
  40. // TODO Auto-generated catch block
  41. e.printStackTrace();
  42. }
  43. System.out.println(2+" "+j.getLocation()+" "+d+" "+d2+" "+up+" "+right);
  44. }
  45.  
  46. } else if (y == 0) {
  47. up = -ub;
  48. while (cdt(x,y,up,right)) {
  49. j.setLocation(x + right, y + up);
  50. x = j.getLocation().x;
  51. y = j.getLocation().y;
  52. try {
  53. Thread.sleep(5);
  54. } catch (InterruptedException e) {
  55. // TODO Auto-generated catch block
  56. e.printStackTrace();
  57. }
  58. System.out.println(3+" "+j.getLocation()+" "+d+" "+d2+" "+up+" "+right);
  59. }
  60. } else if (x == 1066) {
  61. right = - rb;
  62. while (cdt(x,y,up,right)) {
  63. j.setLocation(x + right, y + up);
  64. x = j.getLocation().x;
  65. y = j.getLocation().y;
  66. try {
  67. Thread.sleep(5);
  68. } catch (InterruptedException e) {
  69. // TODO Auto-generated catch block
  70. e.printStackTrace();
  71. }
  72. System.out.println(4+" "+j.getLocation()+" "+d+" "+d2+" "+up+" "+right);
  73. }
  74. } else if (x == 0) {
  75. right = - rb;
  76. while (cdt(x,y,up,right)) {
  77. j.setLocation(x + right, y + up);
  78. x = j.getLocation().x;
  79. y = j.getLocation().y;
  80. try {
  81. Thread.sleep(5);
  82. } catch (InterruptedException e) {
  83. // TODO Auto-generated catch block
  84. e.printStackTrace();
  85. }
  86. System.out.println(4+" "+j.getLocation()+" "+d+" "+d2+" "+up+" "+right);
  87. }
  88. }
  89. rb = right;ub = up;
  90. }
  91.  
  92. }
  93. public static boolean cdt(int x,int y,int uu,int rr) {
  94. if (x == 0 && y == 0) {
  95. return true;
  96. }
  97. if (rr == 1 && uu == 1) {
  98. return x<1066 && y<468;
  99. } else if (rr == -1 && uu == 1) {
  100. return x > 0 && y < 468;
  101. } else if (rr == 1 && uu == -1) {
  102. return x<1066 && y>0;
  103. } else if (rr == -1 && uu == -1) {
  104. return x > 0 && y>0;
  105. }
  106. return false;
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement