快捷搜索:  as  test  1111  test aNd 8=8  test++aNd+8=8  as++aNd+8=8  as aNd 8=8

乐虎电子游戏手机版下载:偶自己做的一个英文打字游戏,希望大家给点意见。。



//编译:javac MyPanel.java

//运行:appletviewer MyPanel.html

//必要大年夜家自写一个MyPanel.html

/*

*/

//下面是MyPanel.java的源代码。MyQQ:18345277

import java.awt.*;

import java.awt.event.*;

import java.util.*;

import java.applet.*;

import javax.swing.*;

public class MyPanel extends Applet implements Runnable

{

public int FPS;

public Thread newthread;

public static boolean swit;

public Image img;

Graphics off;

int width,height;

MouseListener ml=new A();

KeyListener kl=new B();

JPopupMenu jmp;

JMenuItem jmi;

letter myletter;

AudioClip A1,A2,A3;

Random r;

int isTypedSum;

int isOmittedSum;

int isWrongTypedSum;

float percent;

public voi乐虎电子游戏手机版下载d init()

{

this.setBackground(Color.pink);

this.setLayout(new Flo乐虎电子游戏手机版下载wLayout());

FPS=100;

isTypedSum=isOmittedSum=isWrongTypedSum=0;

percent=0f;

width=this.getSize().width;

height=this.getHeight();

img=this.createImage(width,height);

off=img.getGraphics();

r=new Random();

addComponents();

A1=this.getAudioClip(this.getDocumentBase(),"Audio/AUDIO1.au");

A2=this.getAudioClip(this.getDocumentBase(),"Audio/AUDIO2.au");

A3=this.getAudioClip(this.getDocumentBase(),"Audio/AUDIO3.au");

}

publ乐虎电子游戏手机版下载ic void addComponents()

{

this.addKeyListener(kl);

jmp=new JPopupMenu();

jmi=new JMenuItem("开始游戏");

jmi.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

isTypedSum=isOmittedSum=isWrongTypedSum=0;

swit=true;

start();

A3.loop();

}

});

jmp.add(jmi);

jmi=new JMenuItem("停止游戏");

jmi.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

stop();

swit=false;

A3.stop();

}

});

jmp.add(jmi);

jmp.addSeparator();

jmi=new JMenuItem("增添字母数字");

jmi.addActionListener(new ActionListener()

{

public voi乐虎电子游戏手机版下载d actionPerformed(ActionEvent e)

{

if(myletter.exist_letter_num==9);

else

myletter.exist_letter_num++;

myletter.randomLetters();

}

});

jmp.add(jmi);

jmi=new JMenuItem("加快着落速率");

jmi.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

for(int i=0;i1)

myletter.speed[i]--;

}

}

});

jmp.add(jmi);

this.addMouseListener(ml);

}

class A extends MouseAdapter

{

public void mousePressed(MouseEvent e)

{

showPopup(e);

}

public void mouseReleased(MouseEvent e)

{

showPopup(e);

}

public void showPopup(MouseEvent e)

{

if(e.isPopupTrigger())

jmp.show(e.getComponent(),e.getX(),e.getY());

}

}

class B extends KeyAdapter

{

public void keyPressed(KeyEvent e)

{

char key=e.getKeyChar();

if(isTyped(key))

{

A1.play();

}

else

{

A2.play();

}

}

public boolean isTyped(char key)

{

for(int i=0;igame.height)//当字母消掉后,从新给初始位置和速率。

{

game.isOmittedSum++;

reStart(temp);

}

}

}

public void reStart(int temp)

{

Y[temp]=ran.nextInt(11)-10;

speed[temp]=ran.nextInt(8)+1;

reStartX(temp);

reStartStr(temp);

}

public void reStartX(int temp)

{

int cause;

Label:while(true)

{

cause=乐虎电子游戏手机版下载ran.nextInt(9);

for(int i=0;(i

{

if(cause==aa[i])

continue Label;

}

break;

}

X[temp]=XY[cause];

aa[temp]=cause;

}

public void reStartStr(int temp)

{

StringBuffer sb;

String s;

Label2:while(true)

{

sb=new StringBuffer();

sb.setLength(1);

s="";

sb.setCharAt(0,(char)(ran.nextInt(26)+65));

s+=sb;

for(int i=0;i

{

if(s.equals(cc[i]))

continue Label2;

}

break;

}

cc[temp]=s;

}

}

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

您可能还会对下面的文章感兴趣: