Import the Java. The awt. *;
Import the Java. The awt. Event. *;
The import javax.mail. Swing. *;
Public class Game {//set the desktop width
Private int table_width=300;
Private int table_height=400;
//set the racket of width and length
Private int pai_width=60;
Private int pai_heitht=20;
//set the size of the ball
Private int table_size=16;
//initialize the ball the coordinates of the
Private int hallx=30;
Private int hally=40;
//record the movement of the ball speed
Private int speedx=10;
Private int speedy=5;
//the racket speed of movement of the
Private int relex=120;
Private static int reley=340; A Boolean flag=false; The Timer time; Public class my extends Canvas {@ Override public void paint (Graphics g) {//TODO Auto - generated method stub the if (flag) {g.s etColor (Color. BLUE); G.d rawString (" game over ", 100, 200); } else {g.s etColor (Color RED); G.f illOval (30, 40, table_size table_size);//set the following baffle g.s etColor (Color. GREEN); G.f illRect (relex, reley pai_width, pai_heitht); }}
}
Public void f () {Game. My m=new Game (). The new my (); Frame f=new Frame (" pinball game ");//the change of the racket coordinates KeyListener listener=new KeyAdapter () {@ Override public void keyPressed KeyEvent (e) {//TODO Auto - generated method stub int a=um participant etKeyCode (); If (a==KeyEvent. VK_LEFT) {if (relex> 0 {relex -=10; }} the if (a==KeyEvent. VK_RIGHT) {if (relex
}
Public static void main (String [] args) {new Game () f ();
}
}