Post code directly, because of copy right, beginning some Spaces don't care about
Package fighting;
Import the Java. The awt. Graphics;
Import the Java. The awt. Graphics2D;
Import the Java. The awt. Event. KeyEvent;
Import the Java. The awt. Event. KeyListener;
Import the Java. The awt. Image. BufferedImage;
import java.io.File; import java.io.IOException;
The import javax.mail. Imageio. Imageio;
The import javax.mail. Swing. JFrame;
The import javax.mail. Swing. JPanel;
Public class Game extends JFrame implements Runnable {
BufferedImage mob=null;
BufferedImage bju international=null;
Static int x=736, y=436;
The static JPanel iconpanel=new JPanel ();
Public static void main (String [] args) {
Game Game=new Game ();
New Game (). SetVisible (true);
Thread t=new Thread (game);
T.s tart ();
}
@ Override
Public void the run () {
Enclosing addKeyListener (new KeyListener () {
@ Override
Public void keyTyped KeyEvent (e) {
Game g=new Game ();
Int key=um participant etKeyCode ();
The switch (key) {
Case KeyEvent. VK_W:
X=1;
G.r epaint ();
Case KeyEvent. VK_S:
X +=1;
G.r epaint ();
Case KeyEvent. VK_A:
Y -=1;
G.r epaint ();
Case KeyEvent. VK_D:
Y +=1;
G.r epaint ();
}
}
Public void keyReleased KeyEvent (e) {}
Public void keyPressed KeyEvent (e) {}
}); }
Public Game () {
Try {
Bju international=ImageIO. Read (new File (
"E: \ \ JAVA resource bundles \ \ JAVA from entry to master (fifth edition) \ \ 2. TM (instance) of the source program \ \ TM (instance) of the source program \ \ \ \ sl shenshenxiaoshe2021 \ \ SRC \ \ fighting \ \ bju international PNG"));
Mob=ImageIO. Read (new File (" E: \ \ JAVA resource bundles \ \ JAVA from entry to master (fifth edition) \ \ 2. TM (instance) of the source program \ \ TM (instance) of the source program \ \ \ \ sl shenshenxiaoshe2021 \ \ SRC \ \ fighting \ \ monster PNG "));
} the catch (IOException e) {
e.printStackTrace();
}
SetTitle (" have ");
SetBounds (0, 0, 800, 500);
SetDefaultCloseOperation (JFrame. EXIT_ON_CLOSE);
}
@ Override
Public void paint (Graphics g) {
Graphics2D g2=g (Graphics2D);
G2. DrawImage (bju international, x, y, this);
G2. DrawImage (mob, 50, 50, this);
}
}
I am the primary and middle school students you thank the great god do me a favor