fork download
  1. package demoflappybird;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.image.BufferedImage;
  6. import java.io.File;
  7. import java.io.IOException;
  8. import java.util.Random;
  9. import java.util.logging.Level;
  10. import java.util.logging.Logger;
  11. import javax.imageio.ImageIO;
  12. import javax.swing.JPanel;
  13.  
  14. public class PaintPipe extends JPanel {
  15.  
  16. private static int x1 = 500;
  17. private static int x2 = x1 + 140;
  18. private static int x3 = x1 + 140;
  19. private static int x4 = x2 + 140;
  20.  
  21. private static boolean status1 = false;
  22. private static boolean status2 = false;
  23. private static boolean status3 = false;
  24. private static boolean status4 = false;
  25.  
  26. private static int h1, h2, h3, h4;
  27.  
  28. private BufferedImage OngNuocTren, OngNuocDuoi;
  29.  
  30. public int getH1() {
  31. return h1;
  32. }
  33.  
  34. public int getH2() {
  35. return h2;
  36. }
  37.  
  38. public int getH3() {
  39. return h3;
  40. }
  41.  
  42. public int getH4() {
  43. return h4;
  44. }
  45.  
  46. public static int getX1() {
  47. return x1;
  48. }
  49.  
  50. public static int getX2() {
  51. return x2;
  52. }
  53.  
  54. public static int getX3() {
  55. return x3;
  56. }
  57.  
  58. public static int getX4() {
  59. return x4;
  60. }
  61.  
  62. public void Random() {
  63. Random random = new Random();
  64.  
  65. if (status1 == false) {
  66. h1 = random.nextInt(200);
  67. status1 = true;
  68. }
  69. if (status2 == false) {
  70. h2 = random.nextInt(200);
  71. status2 = true;
  72. }
  73. if (status3 == false) {
  74. h3 = random.nextInt(200);
  75. status3 = true;
  76. }
  77. if (status4 == false) {
  78. h4 = random.nextInt(200);
  79. status4 = true;
  80. }
  81. }
  82.  
  83. public void paintPipe(Graphics g) {
  84.  
  85. try {
  86. OngNuocTren = ImageIO.read(new File("D:\\Downloads\\FlappyBird\\res\\OngnuocTren.png"));
  87. OngNuocDuoi = ImageIO.read(new File("D:\\Downloads\\FlappyBird\\res\\OngnuocDuoi.png"));
  88.  
  89. g.drawImage(OngNuocTren, x1, 0, 60, h1, null);
  90. g.drawImage(OngNuocDuoi, x1, h1 + 100, 60, 500, null);
  91.  
  92. g.drawImage(OngNuocTren, x2, 0, 60, h2, null);
  93. g.drawImage(OngNuocDuoi, x2, h2 + 100, 60, 500, null);
  94.  
  95. g.drawImage(OngNuocTren, x3, 0, 60, h3, null);
  96. g.drawImage(OngNuocDuoi, x3, h3 + 100, 60, 500, null);
  97.  
  98. g.drawImage(OngNuocTren, x4, 0, 60, h4, null);
  99. g.drawImage(OngNuocDuoi, x4, h4 + 100, 60, 500, null);
  100.  
  101. } catch (IOException ex) {
  102. Logger.getLogger(PaintPipe.class.getName()).log(Level.SEVERE, null, ex);
  103. }
  104. }
  105.  
  106. public void MovePipe() {
  107. x1--;
  108. x2--;
  109. x3--;
  110. x4--;
  111. }
  112.  
  113. public void Recurrence() {
  114. if (x1 == -40) {
  115. x1 = 500;
  116. status1 = false;
  117. }
  118. if (x2 == -40) {
  119. x2 = 500;
  120. status2 = false;
  121. }
  122. if (x3 == -40) {
  123. x3 = 500;
  124. status3 = false;
  125. }
  126. if (x4 == -40) {
  127. x4 = 500;
  128. status4 = false;
  129. }
  130. }
  131. }
  132.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:14: error: class PaintPipe is public, should be declared in a file named PaintPipe.java
public class PaintPipe extends JPanel {
       ^
1 error
stdout
Standard output is empty