/********************** "Flying Bird" Tested by DOS Environment command for javac Main.java java Main*************************/import Java.awt.*; import java.util.*;import java.awt.event.*;import java.util.list; import javax.swing.jpanel; class wzpoint {int x;int y1;int y2;wzpoint (int &NBSP;XX,&NBSP;INT&NBSP;Y,&NBSP;INT&NBSP;YY) {x = xx;y1 = y;y2 = yy;} public void setx (int x) {this.x = this.x-x;}} public class main extends jpanel {/* global variable explanation a used time p link lines wzy flying height frame panel */static int a = 1;static int wzy = 100;static point p = null; static list<wzpoint> list = new ArrayList<wzpoint> ();p ublic static frame frame = new frame ( );p Ublic static void main (String[] args) {list.add (New wzpoint (480, 50, 220)); List.add (New wzpoint (240, 100, 220)); List.add (New wzpoint (100, 100, List.add (New wzpoint (360, 60, 360)); List.add (New wzpoint (280, 150, 300)); Main m = new main (); M.setsize (New dimension (800, 666)); M.setVisible (true); Frame.add (m); Frame.setsize (800, 666); Frame.addwindowlistener (New windowadapter () {public Void windowclosing (windowevent e) {system.exit (0);}}); M.action (); Frame.addmouselistener (New mouseadapter () {public void mouseclicked (MouseEvent e) {int x = e.getx (); Int y =&nbsP;e.gety (); wzy=y;p = new point (x, y); frame.repaint ();}}); Frame.setvisible (TRUE);} Private timer timer;private void action () {timer = new timer (); Timer.schedule (New timertask () {public void run () { int n=5;//speed value for (int i=0;i<5;i++) { list.get (i). SetX (n*5);//Change X value Move } if (List.size ( ) <6) { int x= (int) (math.random () *100) +50; int y= (int) (math.random () *400) +50; list.add (new Wzpoint (X+300,x,y)); } &nbsP; wzpoint wz=list.get (0); if (wz.x<50) list.remove (0); if (wzy>wz.y1&&wzy<wz.y2) | | (wzy>wz.y2&&wzy<wz.y1)) { p =new point (1000,1000); Frame.repaint ();} Else{frame.repaint ();}}}, new date (), 1000);} @Overridepublic void paint (graphics g) {if (a == 1) g.drawstring ("WZ", 60, 200) g.drawstring ("Welcome to The Flying Machine" ", 550, 100); g.DrawString (" Click on the upper and lower screen to change the position of the aircraft ", 520, g.DrawString ("The screen constantly refreshes the new page when not clicked", 520, 140); G.drawline (50, 50, 500, 50); G.drawline ( 50, 50, 50, 500); G.drawline (500, 50, 500, 500); G.drawline (50, 500, 500 , 500);for (int i = 0; i <5; i++) {wzpoint wz=list.get (i) ;if (wz.x> 50) {g.drawline (Wz.x, wz.y1, wz.x, wz.y2);}} if (p != null) {if (P.getx () ==1000) g.drawstring ("You had fail onCE ", 300,300);if (50 < p.getx () && p.getx () < 500 & & 50 < p.gety () && p.gety () < 500) {g.drawString ("wz", 60, (int) p.gety ());} else { g.DrawString ("Error", " 44, 510"), g.DrawString ("x = " + p.getx (), 44, 520); g.DrawString ("y = " + p.gety (), 44, 530);}} g.DrawString ("I will always print time " + a + "s", 100, 40); a++;}}
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/83/A5/wKioL1d5y9fjlBP7AAATqwxxk-4980.gif "title=" QQ picture 20160705104002.gif "alt=" Wkiol1d5y9fjlbp7aaatqwxxk-4980.gif "/>
Little code Flying Bird