}
if (j==10) {return tmpX;}
}
}
public void update(Graphics g)
{if (bgImage==null)
{bgImage=createImage(this.getSize().width,this.getSize().height);
bg=bgImage.getGraphics();
}
bg.setColor(getBackground());
bg.fillRect(0,0,this.getSize().width,this.getSize().height);
//bg.setColor(getForeground());
paint(bg);
g.drawImage(bgImage,0,0,this);
}
public void run() //用线程循环更改Y值,并根据新的坐标在屏幕上重画pd[I];
{
while(true)
{fk();
panduan();
repaint();
try{ myThread.sleep(50);}catch(Exception e) {}
}
}
public static void main(String args[])
{paodan m=new paodan();
md=new JFrame("打字训练室");
md.setSize(800,600);
md.addKeyListener(m);
md.getContentPane().add(m);
m.cushi();
md.setVisible(true);
md.setResizable(false);
myThread=new Thread(m);
myThread.start();
}
}
注:源代码取自编程中国
本人一点建议:其实打字母游戏java代码你这样学Java是没用的打字母游戏java代码,你应该知道你做的项目思想,先做什么后做什么 , 然后在亲自动手去敲代码打字母游戏java代码!一点建议!
java拼字游戏(1组10个字母中至少2个原音字母,可重复字母)拼对得分 拼错换人..可能不符合要求 , 自己看吧
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class Words {
private static char[] consonant={'B','C','D','F','G','H','J','K','L','M','N','P','Q',
'R','S','T','V','W','X','Y','Z'};
private static char[] vowel={'A','E','I','O','U'};
private static ArrayListString dict = new ArrayListString();
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
getResource();
int score1 = 0;
int score2 = 0;
Scanner userInput = new Scanner(System.in);
String A= null;
int count = 0;
boolean flag = false;//true 为Player1, FALSE为Player2
do{
String random = randomString();
System.out.println(random);
if(flag)
{
System.out.println("Player1 input a word: (or ‘@’ to pass or ‘!’ to quit)");
A=userInput.nextLine();
if(A.equals("@") )
{
flag =!flag;
System.out.println("Player2 input a word: (or ‘@’ to pass or ‘!’ to quit)");
A =userInput.nextLine();
}
}
else
{
System.out.println("Player2 input a word: (or ‘@’ to pass or ‘!’ to quit)");
A=userInput.nextLine();
if(A.equals("@") )
{
flag = !flag;
System.out.println("Player1 input a word: (or ‘@’ to pass or ‘!’ to quit)");
A =userInput.nextLine();
}
}
if(A.equals("@"))
{
System.out.println("反复切换,系统退出");
return;
}
else
{
String temp = null;
if(flag)
{
//String random = randomString();
temp = match(random,A);
if(find(temp,dict))
score1+=2;
System.out.println(" Player1 get "+score1+" points");
}
else
{
//String random = randomString();
temp = match(random,A);
if(find(temp,dict))
score2+=2;;
System.out.println(" Player2 get "+score2+" points");
}
}
count++;
}while(count 10(!A.equals("!")));
System.out.println("游戏结束!");
System.out.println("Player1 get"+score1+"points");
System.out.println("Player2 get"+score2+"points");
if(A.equals("!") )
System.out.println("exit");
}
public static String randomString()//产生随机字符串
{
推荐阅读
- 桌面拼图游戏幼儿,桌面拼图游戏幼儿教案
- 现代战舰战术核显卡怎么得的简单介绍
- postgresql判断中文的简单介绍
- mongodb数据转到oracle,mongodb数据导入mysql
- c语言函数可变长数组 c语言可变参数函数定义
- 显卡雷达怎么关闭电源,如何关闭显卡驱动程序
- 视频号账号交易微信群,微信视频号出售转让
- python画函数图形 用python画函数图
- 小米电视怎么屏蔽软件更新,小米电视如何屏蔽软件