“This is the 19th day of my participation in the First Challenge 2022. For details: First Challenge 2022”

❤️ Author’s home page: Xiao Xu Zhu

❤️ About the author: Hello everyone, I am Xiao Xu Zhu. Java field quality creator 🏆, CSDN blog expert 🏆, Huawei cloud enjoy expert 🏆, Nuggets of the year popular author 🏆, Ali Cloud expert blogger 🏆

❤️ technology live, the appreciation

❤️ like 👍 collect ⭐ look again, form a habit

preface

“The Emperor of Boxing mistake adventure island” is the emperor of boxing and adventure island material based on JavaSwing action games, original adaptation.

The main requirements

The e King of Boxing wakes up in an abandoned factory with monsters crawling on the ground. Such a lovely monster, a punch down, should be crying for a long time ~ the king of boxing heart ridicule under, rushed to the monster’s arms ~~

The main design

1. Game panel generation and display

2. The background is adventure Island material map

3. Design heroes, including health value, spell value, hero action change processing, hero skill special effects

4, design monster, including monster health, attack, position, step length, etc

5. Keyboard monitoring:

Press space: Jump

Press the A key or the left arrow key <- : left

Press D or the right arrow key -> : To go right

Press S key or down arrow key +K key to release skills

Press J to attack

Screenshot function

The game start

The king of fighters to attack

The king of fighters uses his skills

Code implementation

Game main interface


public class MainFrame extends JFrame {
	
	/ * * * * /
	private static final long serialVersionUID = 7492509868810783126L;
	private static KeyWork key;
	
	// Double buffering method to solve flicker problem
	Image ImageBuffer=null;	
	Graphics img;

	* SRI :stand_right_index: character standing still (right) 

* SLI :stand_left_index: character standing still (left)

* Jri :jump_right_index: jump-action (right)

* Jli :jump_left_index: jump-action (left)

* Wli :walk_left_index: jump-action (left)

* Wri :walk_right_index: Character walking (right) * ARI :attack_right_index: character attacking (right)

* Ali: attach_LEFt_index: character attacking (left)

* S0i :skill0_index: a skill attack */
public static int sri=0,sli=0,jri=0,jli=0,wli=0,wri=0, ari=0,ali=0,s0i=0; / * * * / scene int bgindex=0; public static List<Monster> monsters=new ArrayList<Monster>(); public MainFrame(a) { this.setTitle("The King of Fighters goes to Adventure Island by mistake."); this.setBounds((int)(GameValue.WIDTH-GameValue.Width)/2, (int)(GameValue.HEIGHT-GameValue.Hight)/2,GameValue.Width,GameValue.Hight); this.setLayout(null); this.setResizable(false); key=new KeyWork(); this.addKeyListener(key); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // TODO Auto-generated method stubisclose(); }}); initMonster();new ActionThread(); } private void initMonster(a) { new Thread(new Runnable() { @Override public void run(a) { // TODO Auto-generated method stub while(true) { try { Monster m=new Monster(); monsters.add(m); /** ** Spawn interval */ Thread.sleep(10000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }).start(); } public void isclose(a) { System.exit(0); int choose=JOptionPane.showConfirmDialog(this."Quit or not?"."Quit",JOptionPane.YES_NO_OPTION); if(choose==0){ System.exit(0); } else setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); } public void display(boolean show) { this.setVisible(show); } @Override public void paint(Graphics g) { if(ImageBuffer==null){ ImageBuffer=createImage(this.getWidth(),this.getHeight()); } img=ImageBuffer.getGraphics(); super.paint(img); img.drawImage(GameValue.bgimgs[bgindex],0.0,GameValue.Width,GameValue.Hight,this); /** * build the main character information */ img.setColor(Color.WHITE); img.setFont(GameValue.display_font); int x0=30,y0=70,yh=20+8; img.drawString("Health", x0,y0); img.drawString("Spell value", x0,y0+yh); /** * is health and spell value respectively */ img.drawRect(x0*3+8-1, y0-15-1.150+1.15+1); img.drawRect(x0*3+8-1, y0+yh-15-1.150+1.15+1); img.setColor(Color.GREEN); int hp_width=(int) (((double)(Hero.HP_NOW)/Hero.HP_ALL)*150); img.fillRect(x0*3+8, y0-15, hp_width, 15); img.setColor(Color.BLUE); int mp_width=(int) (((double)(Hero.MP_NOW)/Hero.MP_ALL)*150); img.fillRect(x0*3+8, y0+yh-15, mp_width, 15); img.setColor(Color.WHITE); img.drawString(Hero.HP_NOW+"/"+Hero.HP_ALL,x0*3+8-1+45, y0); img.drawString(Hero.MP_NOW+"/"+Hero.MP_ALL,x0*3+8-1+45, y0+yh); for(int i=0; i<monsters.size(); i++) { Monster m=monsters.get(i);if(m.islive) { if(m.left) { img.drawImage(m.imgs_left[m.index],m.mX,m.Y,70.70.this); } else if(m.right) { img.drawImage(m.imgs_right[m.index],m.mX,m.Y,70.70.this); }}}/** * If the protagonist is under attack */ if(Hero.ishurted) { } /** ** The protagonist is in a coma */ else if(Hero.isfall) { } else { /** * Build the main actor static action */ if(Hero.left && ! Hero.jump && ! Hero.walk && ! Hero.attack && ! Hero.skill0_attack) { img.drawImage(Hero.stand_left[sli],Hero.X,Hero.Y,this); } if(Hero.right && ! Hero.jump && ! Hero.walk && ! Hero.attack && ! Hero.skill0_attack) { img.drawImage(Hero.stand_right[sri],Hero.X,Hero.Y,this); } /** ** The main character jumps, including jumps */ if(Hero.jump) { if(Hero.attack) { if(Hero.left) { img.drawImage(Hero.jump_attack_left[jli],Hero.X,Hero.jumpY,this); } if(Hero.right) { img.drawImage(Hero.jump_attack_right[jri],Hero.X,Hero.jumpY,this); }}else { if(Hero.left) { img.drawImage(Hero.jump_left[jli],Hero.X-7,Hero.jumpY,this); } if(Hero.right) { img.drawImage(Hero.jump_right[jri],Hero.X+7,Hero.jumpY,this); }}}/** * The main character does not jump, including walking and normal attack */ else { if(Hero.attack) { if(Hero.left) { img.drawImage(Hero.attack_left[ali],Hero.X-50,Hero.Y,this); } if(Hero.right) { img.drawImage(Hero.attack_right[ari],Hero.X+50,Hero.Y,this); }}else { if(Hero.walk) { if(Hero.left) { img.drawImage(Hero.walk_left[wli],Hero.X,Hero.Y,this); } if(Hero.right) { img.drawImage(Hero.walk_right[wri],Hero.X,Hero.Y,this); }}/** Skill release has the lowest priority */ else { if(Hero.skill0_attack) { if(Hero.left) { img.drawImage(Hero.skill0_attack_left[s0i],Hero.X-40,Hero.Y-75.this); } if(Hero.right) { img.drawImage(Hero.skill0_attack_right[s0i],Hero.X-10,Hero.Y-80.this); } } } } } } img.dispose(); g.drawImage(ImageBuffer,0.0.this); //super.paint(g); } class ActionThread implements Runnable{ public ActionThread(a) { // TODO Auto-generated constructor stub new Thread(this).start(); } @Override public void run(a) { // TODO Auto-generated method stub while(Hero.HP_NOW>0) { if(! Hero.ishurted) {/** * non-jump state */ if(! Hero.jump) {/** * Priority attack>walk> Skill >stand*/ if(Hero.attack) { for(int i=0; i<Hero.attack_right.length; i++) {if(Hero.left) { ali=i; } else if(Hero.right) { ari=i; } repaintUI(80); } ali=0; ari=0; Hero.attack=false; } else { /** * Running status */ if(Hero.walk) { for(int i=0; i<Hero.walk_right.length; i++) {/** If the AD key is released in advance or the space bar is pressed, it stops immediately */ if(! Hero.walk || Hero.jump) {break; } if(Hero.left) { wli=i; Hero.X-=Hero.step; if(Hero.X<=0) { /******** Replacement scenario ********/ if(bgindex! =0) { bgindex--; Hero.X=GameValue.Width-105; AllClear(); repaint(); } else{ Hero.X=0; }}}else if(Hero.right) { wri=i; Hero.X+=Hero.step; if(Hero.X>=(GameValue.Width-80)) { /******** Replacement scenario ********/ if(bgindex! =GameValue.bgimgs.length-1) { bgindex++; Hero.X=0; AllClear(); repaint(); } else{ Hero.X=GameValue.Width-80; } } } repaintUI(100); }}/** * static state */ else { /** Skill attack */ if(Hero.skill0_attack) { /** First check if MP is sufficient, otherwise you cannot release skill */ if(Hero.MP_NOW>=Hero.skill0_mp) { Hero.MP_NOW-=Hero.skill0_mp; for(int i=0; i<Hero.skill0_attack_right.length; i++) { s0i=i; repaintUI(80); }}else if(Hero.MP_NOW<=0) { Hero.MP_NOW=0; repaint(); } s0i=0; Hero.skill0_attack=false; } else { for(int i=0; i<Hero.stand_right.length; i++) {/** If the AD key is pressed or the space bar is pressed, immediately stop */ if(Hero.walk || Hero.jump) { break; } if(Hero.left) { sli=i; } else if(Hero.right) { sri=i; } if(Hero.X>=(GameValue.Width-101)) { Hero.X=GameValue.Width-101; } repaintUI(100); } } } } } /** * Jump state */ else if(Hero.jump) { for(int i=0; i<Hero.jump_right.length; i++) {if(Hero.left) { jli=i; } else if(Hero.right) { jri=i; } if(KeyWork.pressA) { Hero.X-=Hero.step+5; if(Hero.X<=0) { Hero.X=0; }}else if(KeyWork.pressD) { Hero.X+=Hero.step+5; if(Hero.X>=(GameValue.Width-103)) { Hero.X=GameValue.Width-103; }}if(i>=2 && i<=7) { Hero.jumpY-=12; } if(i>=9 && i<=14) { Hero.jumpY+=12; } repaintUI(80); } jli=0; jri=0; Hero.jump=false; Hero.attack=false; repaint(); } //System.out.print(""); } else { try { Thread.sleep(200); Hero.ishurted=false; } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } } /** Refresh the interface */ public void repaintUI(int times) { this.repaint(); try { Thread.sleep(times); } catch (InterruptedException e) { // TODO Auto-generated catch blocke.printStackTrace(); }}/** * Destroy all monsters

* Regenerate monsters */
public static void AllClear(a) { for(Monster m:monsters) { m.islive=false; } monsters.clear(); }}Copy the code

hero


public class Hero {
	/** * Basic attributes of the character: Health, spell value */
	public static int HP_NOW=100,HP_ALL=100,MP_NOW=120,MP_ALL=120;
	
	/** * the current position of the character X and Y, jump using Y*/
	public static int X=50,Y=400,jumpY=Y-52;

	/** * Whether the character is attacked, whether the character is stunned, whether the character faces left or right, whether the character jumps, whether the character walks, whether the character attacks, skill attacks (one skill) */
	public static boolean ishurted=false,isfall=false,left=false,right=true,jump=false,walk=false,
			attack=false,skill0_attack=false;
	
	/** * Defines normal attack damage, jump hit damage, and a skill's MP and damage
	public static int attack_hp=10,jump_attack_hp=15,skill0_mp=15,skill0_hp=20;
	
	/** * Role step */
	public static int step=15;
	
	/** ** character image material - left station */
	public static Image[] stand_left= {
			Toolkit.getDefaultToolkit().getImage("img/role/stand-left/stand01.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/stand-left/stand02.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/stand-left/stand03.png")};/** * character image material - left jump */
	public static Image[] jump_left= {
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/0.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/1.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/2.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/3.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/4.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/5.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/6.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/7.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/8.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/9.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/10.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/11.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/12.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/13.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/14.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/15.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/16.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/17.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/18.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-left/19.png")};/** ** character image material - go left */
	public static Image[] walk_left= {
			Toolkit.getDefaultToolkit().getImage("img/role/walk-left/0.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/walk-left/1.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/walk-left/2.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/walk-left/3.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/walk-left/4.png")};/** * Character image material - left attack */
	public static Image[] attack_left= {
			Toolkit.getDefaultToolkit().getImage("img/role/attack-left/0.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/attack-left/1.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/attack-left/2.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/attack-left/3.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/attack-left/4.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/attack-left/5.png")};/** * Character image material - left jump */
	public static Image[] jump_attack_left= {
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/0.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/1.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/2.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/3.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/4.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/5.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/6.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/7.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/8.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/9.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/10.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/11.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/12.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/13.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/14.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/15.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/16.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/17.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/18.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-left/19.png")};/** ** Character image material - a skill animation - left */
	public static Image[] skill0_attack_left= {
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/0.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/1.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/2.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/3.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/4.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/5.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/6.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/7.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/8.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/9.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/10.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/11.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/12.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/13.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/14.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/15.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/16.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/17.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/18.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/19.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/left/20.png")};/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
	
	/** ** character image material - right station */
	public static Image[] stand_right= {
			Toolkit.getDefaultToolkit().getImage("img/role/stand-right/stand01.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/stand-right/stand02.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/stand-right/stand03.png")};/** ** Character picture material - right jump */
	public static Image[] jump_right= {
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/0.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/1.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/2.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/3.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/4.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/5.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/6.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/7.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/8.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/9.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/10.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/11.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/12.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/13.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/14.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/15.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/16.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/17.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/18.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-right/19.png")};/** ** Character image material - go right */
	public static Image[] walk_right= {
			Toolkit.getDefaultToolkit().getImage("img/role/walk-right/0.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/walk-right/1.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/walk-right/2.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/walk-right/3.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/walk-right/4.png")};/** * Character image material - right attack */
	public static Image[] attack_right= {
			Toolkit.getDefaultToolkit().getImage("img/role/attack-right/0.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/attack-right/1.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/attack-right/2.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/attack-right/3.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/attack-right/4.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/attack-right/5.png")};/** * Character image material - right jump */
	public static Image[] jump_attack_right= {
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/0.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/1.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/2.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/3.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/4.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/5.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/6.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/7.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/8.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/9.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/10.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/11.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/12.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/13.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/14.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/15.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/16.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/17.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/18.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/jump-attack-right/19.png")};/** ** Character image material - a skill animation - right */
	public static Image[] skill0_attack_right= {
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/0.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/1.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/2.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/3.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/4.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/5.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/6.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/7.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/8.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/9.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/10.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/11.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/12.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/13.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/14.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/15.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/16.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/17.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/18.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/19.png"),
			Toolkit.getDefaultToolkit().getImage("img/role/skills/0/right/20.png")};public static void attacked(int atk) {
		ishurted=true;
		HP_NOW-=atk;
		
		if(HP_NOW<0) {
			HP_NOW=0;
			FightGameLaunch.getMainFrame().repaint();
			int choose=JOptionPane.showConfirmDialog(null."Game over. Do you want to quit?"."Quit",JOptionPane.YES_NO_OPTION);
			if(choose==0){
				System.exit(0);
			}
			else
				System.out.println("Resume"); }}}Copy the code

conclusion

Through the “Emperor of Boxer Mistake adventure Island” game implementation, let me have a further understanding of swing related knowledge, the Language of Java has a deeper understanding than before.

Basic Java syntax, such as data types, operators, program flow control, and arrays, is better understood. Java is the core of the core object oriented thought, for this concept, finally realized some.

The source code for

After clicking “like” and following the blogger, the private blogger will get it for free