资源描述:
《java小游戏代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、java小游戏代码www.u2588.comimportjava.applet.Applet;www.u2588.comimportjava.applet.AudioClip;importjava.awt.Dimension;importjava.awt.Font;importjava.awt.Toolkit;importjavax.sound.sampled.AudioFileFormat;importjavax.sound.sampled.AudioSystem;www.u2588.comimportjavax.swing.JFrame;importjavax.swing.JPan
2、el;importjava.awt.Rectangle;importjavax.swing.BorderFactory;importjavax.swing.JButton;www.u2588.comimportjavax.swing.JOptionPane;importjavax.swing.JSlider;importjavax.swing.JLabel;importjavax.swing.SwingUtilities;importjavax.swing.UIManager;importjavax.swing.event.ChangeEvent;www.u2588.comimport
3、javax.swing.event.ChangeListener;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.KeyAdapter;importjava.awt.event.KeyEvent;www.u2588.comimportjava.io.File;importjava.util.Vector;publicclassFrameextendsJFrameimplementsRunnable{JPanelcontentPane;JPaneljPane
4、l1=newJPanel();JButtonjButton1=newJButton();www.u2588.comJSliderjSlider1=newJSlider();JLabeljLabel1=newJLabel();JButtonjButton2=newJButton();JLabeljLabel2=newJLabel();intcount=1,rapidity=80;//count当前进行的个数,rapidity游标的位置www.u2588.comintzhengque=0,cuowu=0;//www.u2588.comintrush[]={10,20,30};//游戏每关的
5、个数可以自由添加.列{10,20,30,40,50}intrush_count=0;//记录关数charlist[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9'};//随机出现的数字可以自由添加www.u2588.comVectornumber=newVector();Stringpaiduan="true";www.u2588.comAudioCli
6、pMusci_anjian,Music_shibai,Music_chenggong;publicFrame(){try{www.u2588.comsetDefaultCloseOperation(EXIT_ON_CLOSE);//-----------------声音文件---------------------Musci_anjian=Applet.newAudioClip(newFile("sounds//anjian.wav").toURL());Music_shibai=Applet.newAudioClip(newFile("sounds//shibai.wav")www.
7、u2588.com.toURL());Music_chenggong=Applet.newAudioClip(newFile("sounds//chenggong.wav").toURL());//---------------------------------------www.u2588.comjbInit();//www.u2588.com}catch(Exceptionexception){exception.printStackTr