1.如何加入音乐
File f=new File("音乐文件路径");
URL ur=f.toURL();//将文件转换成URL
AudioClip a=new Applet.newAudioClip(ur);
a.play();//播放一次
a.loop();//循环播放
a.stop();//调用时结束音乐播放
例如:File file999=new File("D:\\eclise\\2Dgame\\44.wav");
URL url999=file999.toURL();
bj=Applet.newAudioClip(url999);
bj.play();
2.如何把图片画上去(很好的方法)
其中用到BufferedImage画纸
BufferedImage bu=BufferedImage(int width,int height,BufferedImage.TYPE_INT_RGB);
然后创建需要的图片对象
ImageIcon im=new ImageIcon("图片路径");
然后获取画纸上的画布
Graphics g=bu.getGraphics();
然后在将图片画上去
g.drawImage(im,int beginx,int beginy,int width,int height,null);
然后再将自己的画纸在画到面板上去就是了方法同上。。
然后就是可以利用线程死循环while(true){
//方法中写入上述代码,这样就可以一直切换你创建的图片了}
这样就可以让你的图片动起来了
就可以做拳皇之类的游戏了
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
话不多说,先上图
再看代码,这是前期的作品,代码风格不是很好,注释不全,不懂之处,可以留言
package hf20130722first2D; import java.applet.Applet; import java.applet.AudioClip; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.io.File; import java.net.MalformedURLException; import java.net.URL; public class Key implements KeyListener{ public Ren t; public AudioClip bj; public Key(Ren t){ this.t=t; } @Override public void keyTyped(KeyEvent e) { // TODO Auto-generated method stub } @Override public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub int key = e.getKeyCode(); switch(key){ case KeyEvent.VK_O: t.s=11; break; case KeyEvent.VK_L: t.s=12; break; case KeyEvent.VK_Y: t.ss=11; break; case KeyEvent.VK_H: t.ss=12; break; case KeyEvent.VK_DOWN://向下 t.s=1; // t.dun(); System.out.println("u"); ; break; case KeyEvent.VK_S: t.ss=1; ; break; case KeyEvent.VK_LEFT: //向左 t.d=2; t.s=2; // t.qj() ; System.out.println("l"); break; case KeyEvent.VK_A: //向左 t.dd=2; t.ss=2; // t.qj() ; System.out.println("l"); break; case KeyEvent.VK_D: //向左 t.dd=3; t.ss=2; // t.qj() ; System.out.println("l"); break; case KeyEvent.VK_RIGHT: //向右 t.d=3; t.s=7; // t.qj() ; System.out.println("r"); break; case KeyEvent.VK_R: //向左 File file999=new File("D:\\eclise\\2Dgame\\拳.wav"); URL url999; try { url999 = file999.toURL(); bj=Applet.newAudioClip(url999); bj.play(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } t.ss=3; if(t.ren1x+40>=t.ren2x){ t.bd=1; } // t.qj() ; System.out.println("l"); break; case KeyEvent.VK_U: //重脚 File file=new File("D:\\eclise\\2Dgame\\拳.wav"); URL url; try { url = file.toURL(); bj=Applet.newAudioClip(url); bj.play(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // t.b=1; t.s=3; if(t.ren1x+40>=t.ren2x){ t.bd1=1; } // t.zj(); ; break; case KeyEvent.VK_I: //轻脚 // t.b=1; File fil=new File("D:\\eclise\\2Dgame\\脚.wav"); URL ur; try { ur = fil.toURL(); bj=Applet.newAudioClip(ur); bj.play(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } t.s=4; if(t.ren1x+40>=t.ren2x){ t.bd1=2; } // t.qij(); ; break; case KeyEvent.VK_T: //轻脚 // t.b=1; File fi=new File("D:\\eclise\\2Dgame\\脚.wav"); URL u; try { u = fi.toURL(); bj=Applet.newAudioClip(u); bj.play(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } t.ss=4; if(t.ren1x+40>=t.ren2x){ t.bd=2; } // t.qij(); ; break; case KeyEvent.VK_J: //重脚 // t.b=1; File file99=new File("D:\\eclise\\2Dgame\\拳.wav"); URL url99; try { url99 = file99.toURL(); bj=Applet.newAudioClip(url99); bj.play(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } t.s=5; if(t.ren1x+30>=t.ren2x){ t.bd1=1; } // t.zq(); ; break; case KeyEvent.VK_F: //重脚 // t.b=1; File file9=new File("D:\\eclise\\2Dgame\\拳.wav"); URL url9; try { url9 = file9.toURL(); bj=Applet.newAudioClip(url9); bj.play(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } t.ss=5; if(t.ren1x+30>=t.ren2x){ t.bd=1; } // t.zq(); ; break; case KeyEvent.VK_K: //轻拳 // t.b=1; File f=new File("D:\\eclise\\2Dgame\\脚.wav"); URL u1; try { u1 = f.toURL(); bj=Applet.newAudioClip(u1); bj.play(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } t.s=6; if(t.ren1x+30>=t.ren2x){ t.bd1=2; } // t.qiq(); ; break; case KeyEvent.VK_G: //轻拳 // t.b=1; File f2=new File("D:\\eclise\\2Dgame\\脚.wav"); URL u2; try { u2 = f2.toURL(); bj=Applet.newAudioClip(u2); bj.play(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } t.ss=6; if(t.ren1x+30>=t.ren2x){ t.bd=2; } // t.qiq(); ; break; } } @Override public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub int key = e.getKeyCode(); switch(key){ case KeyEvent.VK_RIGHT: //向右 t.s=0; break; case KeyEvent.VK_LEFT: //向右 t.s=0; break; case KeyEvent.VK_DOWN: //向右 t.s=0; break; // case KeyEvent.VK_U: //向右 // t.s=0; // break; // case KeyEvent.VK_I: //向右 // t.s=0; // break; // case KeyEvent.VK_J: //向右 // t.s=0; // break; // case KeyEvent.VK_K: //向右 // t.s=0; // break; case KeyEvent.VK_D: //向右 t.ss=0; break; case KeyEvent.VK_A: //向右 t.ss=0; break; case KeyEvent.VK_S: //向右 t.ss=0; break; // case KeyEvent.VK_R: //向右 // t.ss=0; // break; // case KeyEvent.VK_T: //向右 // t.ss=0; // break; // case KeyEvent.VK_F: //向右 // t.ss=0; // break; // case KeyEvent.VK_G: //向右 // t.ss=0; // break; } // t.z=new zl(new Te()); //t.z.start(); System.out.println(t.s); } }
package hf20130722first2D; import java.applet.Applet; import java.applet.AudioClip; import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import javax.swing.ImageIcon; public class Ren extends Thread{ public AudioClip bj; public int tt=0; public int k=0; public int k1=0; public int bd1=0; public int bd=0; public int ren1x; public int ren2x; //攻击状态 public int q=0; public int z=0; public int q1=0; public int z1=0; //计数图片 public int sk=0; public int sk1=0; public int kc=0; public int kc1=0; public int dx=0; public int dx1=0; public int jn=0; public int jn1=0; public int qg=0; public int zg=0; public int qg1=0; public int zg1=0; public int zq=0; public int zq1=0; public int zj=0; public int zj1=0; public int qij=0; public int qij1=0; public int qiq=0; public int qiq1=0; public Graphics g1; public Graphics g2; public BufferedImage im; final int Up=0; final int Down=1; final int Left=2; final int Right=3; public int x=130,y=340; public int xx=630,yy=340; public int s=100; public int kk=0; public int ss=0; public int d,dd; public int i=0,ii=0; public int j=1,jj=1; public Te t; public Ren(Te t){ this.t=t; } public void tie(){ t.getGraphics().drawImage(im,0,0,null); } public void hua(){ im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); } public void beijing(){ ImageIcon be=new ImageIcon("77.png"); Graphics g=im.getGraphics(); g.drawImage(be.getImage(),0,0,null); } public void zl1(){ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); //while(true){ // if(s==0&&b==0){ if(ii>=8){ ii=0; } ImageIcon i1=new ImageIcon("站立1/_000"+ii+"_"+"-----"+(8-ii)+".png"); Graphics g=im.getGraphics(); // try{ // Thread.sleep(50); // }catch(Exception e){ // e.printStackTrace(); // } g.drawImage(i1.getImage(),xx+10,yy+10,i1.getIconWidth()+20,i1.getIconHeight()+20,null); //t.getGraphics().drawImage(im,0,0,null); ren2x=xx+10; ii++;} public void zl(){ if(i>=8){ i=0; } ImageIcon i1=new ImageIcon("站立/_000"+i+"_"+"-----"+(8-i)+".png"); Graphics g=im.getGraphics(); g.drawImage(i1.getImage(),x+10,y+10,i1.getIconWidth()+20,i1.getIconHeight()+20,null); ren1x=x+10+i1.getIconWidth()+20; i++;} //} //} public void qj(){ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); //ImageIcon be=new ImageIcon("77.png"); //while(true){ if(i>=10){ i=0; } ImageIcon i1=new ImageIcon("前进/_000"+i+"_"+"-----"+(10-i)+".png"); //ImageIcon i1=new ImageIcon("前进1/前进_"+f+".png"); Graphics g=im.getGraphics(); //g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),x+10,y+10,i1.getIconWidth()+20,i1.getIconHeight()+20,null); x=130+j*12; ren1x=x+10+i1.getIconWidth()+20; //t.getGraphics().drawImage(im,0,0,null); System.out.println(i); i++; if(d==Right){j++;} else if(d==Left) {j--;} //} }public void qj1(){ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); //ImageIcon be=new ImageIcon("77.png"); //while(true){ if(ii>=10){ ii=0; } ImageIcon i1=new ImageIcon("前进1/_000"+ii+"_"+"-----"+(10-ii)+".png"); //ImageIcon i1=new ImageIcon("前进1/前进_"+f+".png"); Graphics g=im.getGraphics(); //g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),xx+10,yy+10,i1.getIconWidth()+20,i1.getIconHeight()+20,null); xx=630+jj*12; ren2x=xx+10; //t.getGraphics().drawImage(im,0,0,null); System.out.println(i); ii++; if(dd==Right){jj++;} else if(dd==Left) {jj--;} //} } public void dun(){ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); // ImageIcon be=new ImageIcon("77.png"); //while(true){ if(i>=6){ i=0; } ImageIcon i1=new ImageIcon("下蹲/"+i+".png"); Graphics g=im.getGraphics(); // g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),x,y,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); System.out.println(i); i++; System.out.println("正在下蹲"); } public void dun1(){ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); // ImageIcon be=new ImageIcon("77.png"); //while(true){ if(ii>=6){ ii=0; } ImageIcon i1=new ImageIcon("下蹲1/"+ii+".png"); Graphics g=im.getGraphics(); // g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),xx,yy,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); System.out.println(i); ii++; System.out.println("正在下蹲"); } public void qg(){ if(qg>=7){ qg=0;s=0;q=0;bd=0; } ImageIcon i1=new ImageIcon("被拳打/_000"+qg+"_"+"-----"+(8-qg)+".png"); Graphics g=im.getGraphics(); //g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),x,y+10,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); qg++; } public void qg1(){ if(qg1>=7){ qg1=0;ss=0;q=0;bd1=0; } ImageIcon i1=new ImageIcon("被拳打1/_000"+qg1+"_"+"-----"+(8-qg1)+".png"); Graphics g=im.getGraphics(); //g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),xx,yy+10,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); qg1++; } public void zg(){ if(zg>=7){ zg=0;s=0;bd=0; } ImageIcon i1=new ImageIcon("被脚打/_000"+zg+"_"+"-----"+(8-zg)+".png"); Graphics g=im.getGraphics(); //g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),x,y,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); zg++; } public void zg1(){ if(zg1>=7){ zg1=0;ss=0;bd1=0; } ImageIcon i1=new ImageIcon("被脚打1/_000"+zg1+"_"+"-----"+(8-zg1)+".png"); Graphics g=im.getGraphics(); //g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),xx,yy,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); System.out.println("zehnzgaichuquan"); zg1++; } public void zj(){ if(zj>=9){ zj=0;s=0; } ImageIcon i1=new ImageIcon("重脚/"+zj+".png"); Graphics g=im.getGraphics(); g.drawImage(i1.getImage(),x,y,i1.getIconWidth()+26,i1.getIconHeight()+26,null); System.out.println("zehnzgaichuquan"); zj++; } public void kc() throws Exception{ try{ Thread.sleep(50); }catch(Exception e){} ImageIcon i1=new ImageIcon("狂笑/_00"+(36-kc)+"_"+"-----"+(kc+1)+".png"); Graphics g=im.getGraphics(); g.drawImage(i1.getImage(),x+10,y,i1.getIconWidth()+20,i1.getIconHeight()+20,null); if(kc==0){ File file999=new File("E:\\eclipsworks\\2Dgame"); URL url999=file999.toURL(); bj=Applet.newAudioClip(url999); bj.play();} kc++; if(kc>=36){ kc=0;s=0;tt=1; } } public void kc1() throws Exception{ ss=100; if(kc1==0){ File file999=new File("D:\\eclise\\2Dgame\\骂人.wav"); URL url999=file999.toURL(); bj=Applet.newAudioClip(url999); bj.play(); System.out.print("fffffffffffffwwwwwwwwwwwwww");} try{Thread.sleep(80);}catch(Exception e){} ImageIcon i1=new ImageIcon("嘲讽/"+(kc1+1)+".png"); Graphics g=im.getGraphics(); g.drawImage(i1.getImage(),xx+10,yy,i1.getIconWidth()+20,i1.getIconHeight()+20,null); kc1++; if(kc1>7){ kc1=0;ss=0;tt=0; }} public void dx(){ ImageIcon i1=new ImageIcon("倒下/_000"+(25-dx)+"_"+"-----"+(dx+1)+".png"); Graphics g=im.getGraphics(); if(0<dx&&dx<=6){y=y-10;} if(dx>6&&dx<=12){y=y+10;} g.drawImage(i1.getImage(),x,y+40,i1.getIconWidth()+26,i1.getIconHeight()+26,null); System.out.println("zehnzgaichuquan"); dx++; if(dx>=25){ dx=0;s=0;bd=0; } } public void dx1(){ ImageIcon i1=new ImageIcon("倒下1/_000"+(25-dx1)+"_"+"-----"+(dx1+1)+".png"); Graphics g=im.getGraphics(); if(0<dx1&&dx1<=6){yy=yy-10;} if(dx1>6&&dx1<=12){yy=yy+10;} g.drawImage(i1.getImage(),xx,yy+40,i1.getIconWidth()+26,i1.getIconHeight()+26,null); System.out.println("zehnzgaichuquan"); dx1++; if(dx1>=25){ dx1=0;ss=0;bd1=0; } } public void jn(){ ImageIcon i1=new ImageIcon("技能/_000"+(15-jn)+"_"+"-----"+(jn+1)+".png"); Graphics g=im.getGraphics(); g.drawImage(i1.getImage(),x,y,i1.getIconWidth()+26,i1.getIconHeight()+26,null); jn++; if(jn>=15){ jn=0;s=0;k1=0; } if(ren1x+i1.getIconWidth()-46>=ren2x){ if(k1==0){ bd1=1;k1++;} } } public void jn1(){ if(jn1>=15){ jn1=0;ss=0;k=0; } ImageIcon i1=new ImageIcon("技能1/_000"+(15-jn1)+"_"+"-----"+(jn1+1)+".png"); Graphics g=im.getGraphics(); g.drawImage(i1.getImage(),xx-i1.getIconWidth()+55,yy,i1.getIconWidth()+26,i1.getIconHeight()+26,null); jn1++; if(ren1x+i1.getIconWidth()-46>=ren2x){ if(k==0){ bd=1; k++;} } } public void sk(){ ImageIcon i1=new ImageIcon("技/_00"+(59-sk)+"_"+"-----"+(sk+1)+".png"); Graphics g=im.getGraphics(); g.drawImage(i1.getImage(),x,470-i1.getIconHeight()-26,i1.getIconWidth()+26,i1.getIconHeight()+26,null); sk++; if(ren1x+i1.getIconWidth()-46>=ren2x){ if(k1==0){ bd1=3;k1++;} }if(sk>=59){ sk=0;s=0;k1=0; }} public void sk1(){ ImageIcon i1=new ImageIcon("技2/_00"+(59-sk1)+"_"+"-----"+(sk1+1)+".png"); Graphics g=im.getGraphics(); g.drawImage(i1.getImage(),xx+80-i1.getIconWidth(),470-i1.getIconHeight()-26,i1.getIconWidth()+26,i1.getIconHeight()+26,null); sk1++; if(ren1x+i1.getIconWidth()-46>=ren2x){ if(k1==0){ bd=3;k1++;} } if(sk1>=59){ sk1=0;ss=0;k1=0; } } public void zj1(){ ImageIcon i1=new ImageIcon("重脚1/"+zj1+".png"); Graphics g=im.getGraphics(); g.drawImage(i1.getImage(),xx-50,yy,i1.getIconWidth()+26,i1.getIconHeight()+26,null); System.out.println(i); System.out.println("zehnzgaichuquan"); zj1++; if(zj1>=9){ zj1=0;ss=0; } } public void qij(){ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); //ImageIcon be=new ImageIcon("77.png"); ImageIcon i1=new ImageIcon("轻脚/"+qij+".png"); Graphics g=im.getGraphics(); //g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),x,y,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); System.out.println(i); qij++; if(qij>=5){ qij=0;s=0; } } public void qij1(){ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); //ImageIcon be=new ImageIcon("77.png"); ImageIcon i1=new ImageIcon("轻脚1/"+qij1+".png"); Graphics g=im.getGraphics(); //g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),xx-50,yy,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); System.out.println(i); qij1++; if(qij1>=5){ qij1=0;ss=0; } } public void zq() throws Exception{ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); //ImageIcon be=new ImageIcon("77.png"); ImageIcon i1=new ImageIcon("重拳/"+(8-zq)+".png"); Graphics g=im.getGraphics(); // g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),x,y,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); zq++; if(zq>=9){ zq=0;s=0; } } public void zq1(){ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); //ImageIcon be=new ImageIcon("77.png"); ImageIcon i1=new ImageIcon("重拳1/"+(8-zq1)+".png"); Graphics g=im.getGraphics(); // g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),xx-50,yy,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); System.out.println(i); zq1++; if(zq1>=9){ zq1=0; ss=0; } } public void qiq(){ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); //ImageIcon be=new ImageIcon("77.png"); ImageIcon i1=new ImageIcon("轻拳/"+qiq+".png"); Graphics g=im.getGraphics(); //g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),x,y,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); System.out.println(i); qiq++; if(qiq>=5){ qiq=0;s=0; } } public void qiq1(){ // im=new BufferedImage(t.getWidth(),t.getHeight(),BufferedImage.TYPE_INT_RGB); //ImageIcon be=new ImageIcon("77.png"); ImageIcon i1=new ImageIcon("轻拳1/"+qiq1+".png"); Graphics g=im.getGraphics(); //g.drawImage(be.getImage(),0,0,null); g.drawImage(i1.getImage(),xx-50,yy,i1.getIconWidth()+26,i1.getIconHeight()+26,null); //t.getGraphics().drawImage(im,0,0,null); System.out.println(i); qiq1++; if(qiq1>=5){ qiq1=0;ss=0; } } public void music(){ File file999=new File("D:\\eclise\\2Dgame\\1.wav"); try { URL url999=file999.toURL(); bj=Applet.newAudioClip(url999); } catch (Exception e) { } } public void run(){ // music();bj.play(); while(true){ this.hua(); this.beijing(); if(bd1==1){ ss=8; this.zg1(); } if(bd==1){ s=8; this.zg(); } if(bd1==3){ ss=8; this.dx1(); } if(bd==3){ s=8; this.dx(); } if(bd1==2){ ss=8; this.qg1(); } if(bd==2){ s=8; this.qg(); } if(s==100){ try { this.kc(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(tt==1){ try { this.kc1(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(s==0){ this.zl(); } if(ss==0){ this.zl1(); } if(ss==1){ this.dun1();} if(s==1){ this.dun(); }if(s==2){ this.qj() ; } if(ss==2){ this.qj1() ; }if(s==3){ this.zj(); } if(ss==3){ this.zj1(); }if(s==4){ this.qij(); } if(ss==4){ this.qij1(); } if(s==5){ try { this.zq(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(ss==5){ this.zq1(); } if(s==6){ this.qiq(); } if(ss==6){ this.qiq1(); } if(s==7){ this.qj() ; } if(ss==7){ this.qj1() ; } if(s==11){ this.jn(); } if(ss==11){ this.jn1(); } if(s==12){ this.sk(); } if(ss==12){ this.sk1(); } //if(z1==0){ // this.zg1(); //} this.tie(); try { Thread.sleep(50); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }}
package hf20130722first2D; import java.applet.Applet; import java.applet.AudioClip; import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import javax.swing.*; public class Te extends JFrame { public AudioClip bj; public void UI() throws Exception{ this.setTitle("2DGame"); this.setSize(1000,550); this.setLocation(200,100); this.setResizable(false); this.setDefaultCloseOperation(3); this.setVisible(true); Ren z=new Ren(this); Key k=new Key(z); this.addKeyListener(k); File file999=new File("E:\\eclipsworks\\2Dgame\\44.wav"); URL url999=file999.toURL(); bj=Applet.newAudioClip(url999); bj.play(); kaichang("八神/1.jpg"); kaichang("八神/2.jpg"); kaichang("八神/3.jpg"); //kaichang("八神/4.jpg"); kaichang("八神/5.jpg"); kaichang("八神/6.jpg"); kaichang("八神/7.jpg"); kaichang("八神/8.jpg"); kaichang("八神/9.jpg"); kaichang("八神/10.jpg"); kaichang("八神/11.jpg"); Thread.sleep(100); kaichang("八神/12.jpg"); bj.stop(); File file99=new File("E:\\eclipsworks\\2Dgame\\2.wav"); URL url99=file99.toURL(); AudioClip b=Applet.newAudioClip(url99); z.start(); Thread.sleep(6000); b.loop(); //kaishi=Applet.newAudioClip(url000); } //Applet a=new Applet(); //AudioClip au=a.getAudioClip(null, "D:\\eclise\\2Dgame\\1.wav"); //au.play(); public void kaichang(String name){ BufferedImage bd=new BufferedImage(this.getWidth(),this.getHeight(),BufferedImage.TYPE_INT_RGB); ImageIcon im=new ImageIcon(name); Graphics g=bd.getGraphics(); g.drawImage(im.getImage(),0,20,bd.getWidth(),bd.getHeight(),null); this.getGraphics().drawImage(bd, 0, 0,null); try{Thread.sleep(3500);}catch(Exception e){} } /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { // TODO Auto-generated method stub new Te().UI(); } }
猛戳下面网址下载源程序和游戏要用到的资源 http://pan.baidu.com/disk/home#dir/path=%2F%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99
相关推荐
【Java_KOF_SRC.rar_KOF_java拳皇_java拳皇源码_拳皇游戏JAVA】这个压缩包文件包含的是一个基于Java编程语言实现的KOF(King of Fighters,拳皇)游戏的源代码。这个项目是Java爱好者或者游戏开发者的宝贵资源,因为...
java课程设计大作业,java、算法练手项目,适合初学java、数据结构的同学拿来学习研究,基于java、GUI开发的小游戏,程序都经过测试,可以直接运行,资源含程序运行所需的源码、资源文件等全部数据,有需要的可放心...
Unity3d 拳皇类大型3D格斗游戏源码 街机对战游戏项目 整个项目的完整压缩包 , 直接打开就行 , 无需其他操作 适合二次开发和学习使用 , 如果有问题请切换编译器 或者下载最新编译器 Unity街机游戏源码 Unity3d 拳皇...
【标题】"拳皇KOF游戏Java版源码"揭示了这是一个基于Java编程语言开发的手机游戏项目,其核心是《拳皇》(The King of Fighters)系列的经典格斗游戏。Java作为跨平台的编程语言,常用于移动应用开发,尤其是早期的...
用了一天做了个简单的拳皇游戏。目前只加入方向控制。A键能量。Ctrl攻击。源码等游戏完全做好后发布!高手误喷!!!
对于游戏开发者来说,这些音效资源是制作《拳皇》同人作品或者类似风格游戏的重要素材。他们可以利用这些音效来创建出更贴近原作的游戏体验,或者进行创新,打造出独一无二的音效设计。同时,对于音效设计师而言,...
【作品名称】:基于Java语言的休闲类格斗游戏,支持双人联机对战,类似拳皇游戏【课程设计】 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目...
《KOF.zip_KOF_kof_java_拳皇java_格斗_格斗游戏》这个压缩包文件中的核心内容是一款基于Java开发的格斗小游戏——KOF。Java是一种广泛使用的编程语言,尤其在开发跨平台应用方面具有显著优势,这使得KOF游戏能够...
用51单片机做的拳皇游戏proteus仿真 游戏的大致框架已经做好,效果还行。 仿真所用到的硬件: AT89C52 12864液晶显示屏 1602液晶显示屏 数码管 按键 资源文件包含: Keil工程源码 proteus仿真 【KEY1】 向左移动 ...
【作品名称】:基于Cocos引擎实现的拳皇游戏【课程设计】 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【项目介绍】:基于Cocos...
这些素材来源于经典的街机格斗游戏《拳皇13》,是游戏制作人和开发者们的宝贵财富。在这里,我们将深入探讨这份素材库中的关键知识点,以及如何利用它们来提升游戏的视觉效果。 首先,我们要知道PNG去底图片帧是一...
Java以其跨平台性、面向对象的特性以及丰富的类库,成为了制作桌面游戏和移动游戏的热门选择。在本项目中,开发者可能利用了Java的Swing或JavaFX库来构建用户界面,这些库提供了丰富的组件和功能,使得创建图形化...
一次课外作业: 程序是个动画演示程序,动画设计为一开始屏幕上有两个人物,一个是koy, 一个是buzhi, 两个人对面相站, 分别在屏幕的最左边和最右边,koy在左, buzhi在右, 两个人一开始处于站立待命状态, 当玩家按下fire...
《文字游戏:拳皇的C源代码》是一个以经典街机游戏"拳皇"为灵感的文字游戏项目,其源代码是用C语言编写的。C语言是一种基础且强大的编程语言,广泛应用于系统软件、嵌入式系统以及各种类型的游戏开发。这个项目为...
这对于想要制作手机游戏的开发者来说,是提高用户体验的重要环节。 在压缩包中的"kf"文件,可能是游戏的主程序或者特定的代码模块,例如游戏框架、数据结构、配置文件等。进一步研究这个文件,可以深入理解游戏的...
Java KOF游戏源码是一个对经典格斗游戏《拳皇》(KOF)进行编程实现的项目,其源代码经过了反编译处理。反编译是将已编译的二进制代码转换回源代码的过程,这通常用于学习、调试或逆向工程目的。在本例中,开发者或...
在游戏开发过程中,这些特效gif素材的运用不仅能够节省制作时间,而且能确保游戏质量的一致性和专业性。开发者可以通过调整gif的速度、颜色、透明度等参数,使其更好地融入游戏环境,同时也可以进一步通过组合和编辑...