import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
import java.net.MalformedURLException;
import java.util.Scanner;

public class KingOfFighters {
    public static void main(String[] args) throws MalformedURLException, InterruptedException {
        //初始化招式表
        String[] zhaoShiTable1={"百式·鬼燃烧","二百十二式·琴月阴","百二十七式·葵花","百八式·暗勾手","里百八式·八酒杯","禁千二百十一式·八稚女"};
        String[] zhaoShiTable2={"黑粒子","神指(对地)","神指(对空)","灵气柱(近程)","灵气柱(远程)","阳光普照","灵光柱","魂之归宿","地狱千手"};
        //播放音乐
        File sound=new File("music\\kaichang.wav");
        AudioClip audio= Applet.newAudioClip(sound.toURL());
        audio.play();
        //选人环节
        Scanner input=new Scanner(System.in);
        System.out.print("请输入玩家1的名字:");
        String player1=input.next();
        System.out.print("请输入玩家2的名字:");
        String player2=input.next();
        audio.stop();

        //初始化hp 攻击
        int hp1=100,hp2=100;
        int attack1=0,attack2=0;
        //播放比赛开始音乐
        sound=new File("D:\\play\\music\\readygo.wav");
        audio=Applet.newAudioClip(sound.toURL());
        audio.play();
        System.out.println(player1+" VS "+player2);
        Thread.sleep(2000);
        audio.stop();
        //比赛细节
        while(true){
            if(hp1<0||hp2<0){
                break;
            }
            int r1=(int)(Math.random()*6);
            int r2=(int)(Math.random()*9);
            attack1=(int)(Math.random()*100000%11+5);
            attack2=(int)(Math.random()*100000%11+5);
            if(attack1%3==0){
                attack1=0;
                System.out.println(player1+"闷逼了,被"+player2+"躲避了");
            }else if(attack2%3==0){
                attack2=0;
                System.out.println(player2+"闷逼了,被"+player1+"躲避了");
            }
            if(attack1%3==0||attack2%3==0){
                attack1=(int)(Math.random()*100000%11+5);
                attack2=(int)(Math.random()*100000%11+5);
                sound=new File("D:\\play\\music\\xiaosheng.wav");
                audio=Applet.newAudioClip(sound.toURL());
                audio.play();
                Thread.sleep(3000);
                audio.stop();
            }
            sound=new File("D:\\play\\music\\tank.wav");
            audio=Applet.newAudioClip(sound.toURL());
            audio.play();
            hp2-=attack1;
            String miaoShu=player1+"发出了一招"+zhaoShiTable1[r1]+",\n"+player2+"被干掉"+attack1+"滴血";
            System.out.println(miaoShu);
            Thread.sleep(2000);
            audio.stop();

            hp1-=attack2;
            sound=new File("D:\\play\\music\\long.wav");
            audio=Applet.newAudioClip(sound.toURL());
            audio.play();
            miaoShu=player2+"发出了一招"+zhaoShiTable2[r2]+",\n"+player1+"被干掉"+attack2+"滴血";
            System.out.println(miaoShu);
            Thread.sleep(2000);
            audio.stop();
        }
        sound=new File("D:\\play\\music\\ko.wav");
        audio=Applet.newAudioClip(sound.toURL());
        audio.play();
        if(hp1<0){
            System.out.println("WINNER IS "+player2);
        }else{
            System.out.println("WINNER IS "+player1);
        }
        System.out.println(player1+"血量: "+hp1);
        System.out.println(player2+"血量: "+hp2);
        Thread.sleep(2000);
        audio.stop();
    }
}

 里面的音效自己找网站下载

 

11-22 18:37