norains的专栏
只专注于WINCE开发
登录
注册
全站
当前博客
空间
博客
好友
相册
留言
雨仔
ID:norains
共
125040
次访问,排名
659
好友
0
人,关注者
15
人
代码其实是一种乐趣
norains的文章
原创 185 篇
翻译 0 篇
转载 10 篇
评论 252 篇
norains的公告
联系方式请看置顶文章
最近评论
xumercury:
= =|||||我汗。。。ps看的很囧。。
night_legend:
china-pub上一搜就有三本,有进口本,有影印本。
vaney.li#samsung.com:
看了你写的关于LIB与DLL 的文章,感觉写的很不错,你的思路很清晰的:)
希望能回我邮件一起讨论vaney.li#samsung.com
ABC:
PT035TN01 V.6液晶控制器是哪种,地址才6位如何寻址到整个屏的,谢谢!
zdhsoft:
谢谢justnetbobo!
文章分类
HARDWARE
(RSS)
J2ME
(RSS)
Qt
(RSS)
WinCE
(RSS)
痴人梦呓
(RSS)
电脑应用
(RSS)
自说自话
(RSS)
收藏
相册
动漫
文章图片
程序交流
xumercury的BLOG
狗友们的博客
清蒸石斑鱼
美女如刀锋
茁茁的BLOG
魅力老姐的窝
存档
2008年09月(1)
2008年08月(3)
2008年07月(6)
2008年06月(5)
2008年05月(10)
2008年04月(10)
2008年03月(5)
2008年02月(5)
2008年01月(17)
2007年12月(11)
2007年11月(5)
2007年10月(6)
2007年09月(3)
2007年08月(4)
2007年07月(2)
2007年06月(4)
2007年05月(7)
2007年04月(11)
2007年03月(8)
2007年02月(2)
2007年01月(13)
2006年12月(4)
2006年11月(4)
2006年10月(6)
2006年09月(4)
2006年07月(6)
2006年06月(5)
2006年05月(4)
2006年04月(12)
2006年03月(3)
2006年02月(5)
2005年11月(2)
2005年09月(2)
软件项目交易
订阅我的博客
TestLatency反应测试游戏完整源代码
收藏
新一篇: 漫谈WinCE的手写识别技术(三)
|
旧一篇: NotePad完整源代码
一个非常简单的测试个人反应的游戏源代码
//
-----------------------------
//
GameScreen.java
//
-----------------------------
package
src;
import
javax.microedition.lcdui.
*
;
import
java.util.
*
;
public
class
GameScreen
extends
Canvas
implements
CommandListener
...
{
Display display;
private
long
startTime;
private
long
endTime;
private
long
resultTime;
private
boolean
changed;
private
boolean
paintFlag;
private
Font font;
private
int
left;
private
int
top;
private
Timer timer;
private
Random rand;
private
TestLatencyMIDlet MIDlet;
public
void
paint(Graphics g)
...
{
font
=
font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_LARGE);
left
=
(getWidth()
-
font.stringWidth(
"
准备..
"
))
/
2
;
top
=
(getHeight()
-
font.getHeight())
/
2
;
if
(paintFlag
==
true
)
...
{
g.setColor(
0
,
0
,
0
);
g.fillRect(
0
,
0
,
this
.getWidth(),
this
.getHeight());
g.setColor(
0
,
255
,
255
);
g.drawString(
"
准备..
"
,left,top,Graphics.LEFT
|
Graphics.TOP);
paintFlag
=
false
;
changed
=
false
;
}
else
...
{
g.setColor(
0
,
0
,
255
);
g.fillRect(
0
,
0
,
this
.getWidth(),
this
.getHeight());
g.setColor(
0
,
255
,
0
);
g.drawString(
"
按!!
"
,left,top,Graphics.LEFT
|
Graphics.TOP);
paintFlag
=
true
;
changed
=
true
;
startTime
=
System.currentTimeMillis();
}
}
public
GameScreen(Display display,TestLatencyMIDlet m)
...
{
MIDlet
=
m;
paintFlag
=
true
;
changed
=
false
;
this
.display
=
display;
this
.setFullScreenMode(
true
);
startGame();
}
public
void
startGame()
...
{
rand
=
new
Random();
timer
=
new
Timer();
changeTask st
=
new
changeTask();
long
t
=
rand.nextInt();
if
(t
<
0
)
...
{ t
=-
1L
*
t;}
timer.schedule(st,(t
*
2000L
)
/
1000000000L
);
}
public
class
changeTask
extends
TimerTask
...
{
public
void
run()
...
{
repaint();
cancel();
}
}
protected
void
keyPressed(
int
keycode)
...
{
ResultScreen resultScreen;
endTime
=
System.currentTimeMillis();
resultTime
=
endTime
-
startTime;
if
(changed
==
true
)
...
{
resultScreen
=
new
ResultScreen(display,
true
,resultTime,MIDlet);
display.setCurrent(resultScreen);
}
else
...
{
resultScreen
=
new
ResultScreen(display,
false
,resultTime,MIDlet);
display.setCurrent(resultScreen);
}
}
public
void
commandAction(Command c ,Displayable disp)
...
{}
}
//
-----------------------------
//
InfoScreen.java
//
-----------------------------
package
src;
import
javax.microedition.lcdui.
*
;
public
class
InfoScreen
extends
Form
implements
CommandListener
...
{
Displayable nextDisp;
Display display;
public
InfoScreen(Display display, Displayable nextDisp)
...
{
super
(
""
);
this
.nextDisp
=
nextDisp;
this
.display
=
display;
this
.append(
"
版本:1.0
"
+
"
作者:norains
"
+
"
联系:norains@163.com
"
+
"
说明:游戏玩法相当简单,当画面变化的时候,请你以最快的速度按键
"
);
this
.addCommand(
new
Command(
"
返回
"
,Command.BACK,
0
));
this
.setCommandListener(
this
);
}
public
void
commandAction(Command c,Displayable s)
...
{
String cmd
=
c.getLabel();
if
(cmd.equalsIgnoreCase(
"
返回
"
))
...
{
display.setCurrent(nextDisp);
}
}
}
//
-----------------------------
//
ListScreen.java
//
-----------------------------
package
src;
import
javax.microedition.lcdui.
*
;
public
class
ListScreen
extends
List
implements
CommandListener
...
{
private
Display display;
private
TestLatencyMIDlet MIDlet;
//
传入TestLatencyMIDlet主要是为了能进行退出程序的操作.
public
ListScreen(Display display,TestLatencyMIDlet m)
...
{
super
(
""
,Choice.IMPLICIT);
MIDlet
=
m;
this
.display
=
display;
Image img1,img2,img3,img4;
img1
=
img2
=
img3
=
img4
=
null
;
try
...
{
img1
=
Image.createImage(
"
/res/1.PNG
"
);
img2
=
Image.createImage(
"
/res/2.PNG
"
);
img3
=
Image.createImage(
"
/res/3.PNG
"
);
img4
=
Image.createImage(
"
/res/4.PNG
"
);
}
catch
(Exception erro)
...
{}
this
.append(
"
开始游戏
"
,img1);
this
.append(
"
高手排行
"
,img2);
this
.append(
"
游戏说明
"
,img3);
this
.append(
"
退出游戏
"
,img4);
this
.setCommandListener(
this
);
}
public
void
commandAction(Command c,Displayable s)
...
{
if
(c
==
List.SELECT_COMMAND)
...
{
List tmp
=
(List) s;
int
selected
=
tmp.getSelectedIndex();
String list
=
tmp.getString(selected);
if
(list.equals(
"
开始游戏
"
))
...
{
GameScreen gameScreen
=
new
GameScreen(display,MIDlet);
display.setCurrent(gameScreen);
}
else
if
(list.equals(
"
高手排行
"
))
...
{
RecordScreen recordScreen
=
new
RecordScreen(display,
this
);
display.setCurrent(recordScreen);
}
else
if
(list.equals(
"
游戏说明
"
))
...
{
InfoScreen infoScreen
=
new
InfoScreen(display,
this
);
display.setCurrent(infoScreen);
}
else
if
(list.equals(
"
退出游戏
"
))
...
{
MIDlet.notifyDestroyed();
}
}
}
}
//
-----------------------------
//
RecordScreen.java
//
-----------------------------
package
src;
import
javax.microedition.lcdui.
*
;
import
javax.microedition.rms.
*
;
public
class
RecordScreen
extends
Form
implements
CommandListener
...
{
private
Display display;
private
Displayable nextDisp;
private
String appraiseText;
public
RecordScreen(Display display, Displayable nextDisp)
...
{
super
(
"
高手排行
"
);
this
.display
=
display;
this
.nextDisp
=
nextDisp;
this
.addCommand(
new
Command(
"
返回
"
,Command.BACK,
0
));
this
.setCommandListener(
this
);
String dbname
=
"
resultDataBase
"
;
RecordStore rs
=
RMSUtil.openRSAnyway(dbname);
if
(rs
==
null
)
...
{
this
.append(
"
打开数据库失败!可能尚未储存数据,请进行游戏后再尝试.如果依然出现错误,请与我联系:norains@163.com
"
);
}
else
...
{
int
id;
try
...
{
//
测试开始
//
ResultDataEntity test1=new ResultDataEntity("norains",1000);
//
byte[]tmp=test1.encode();
//
int id1=rs.addRecord(tmp,0,tmp.length);
//
rs.deleteRecord(id1);
//
id=rs.addRecord(tmp,0,tmp.length);
//
测试结束
ResultDataEntity resultRecord
=
new
ResultDataEntity();
RecordEnumeration re
=
rs.enumerateRecords(
null
,
null
,
false
);
id
=
re.nextRecordId();
resultRecord.decode(rs.getRecord(id));
buildAppraise(resultRecord.name,resultRecord.resultTime);
this
.append(
"
榜上有名的高手是:
"
+
resultRecord.name
+
"
!他的反应时间是
"
+
resultRecord.resultTime
+
"
毫秒!
"
+
appraiseText);
rs.closeRecordStore();
//
RMSUtil.deletRS(dbname);
}
catch
(Exception erro)
...
{}
}
}
public
void
buildAppraise(String name,
long
time)
...
{
if
(time
<
200
)
appraiseText
=
"
这完全是一个不可思议的记录!
"
+
name
+
"
居然做到了!
"
;
else
if
(time
<
250
)
appraiseText
=
"
非常高兴
"
+
name
+
"
能创造出一个如此完美的成绩,估计这记录已经很难打破了吧?!
"
;
else
if
(time
<
300
)
appraiseText
=
"
很高兴
"
+
name
+
"
能打出一个很不错的记录!不知道还有没有人可以更上一层楼呢?
"
;
else
if
(time
<
400
)
appraiseText
=
name
+
"
的这个记录还不赖嘛!
"
;
else
if
(time
<
500
)
appraiseText
=
name
+
"
的这个记录嘛,一般般啦~
"
;
else
appraiseText
=
"
不是吧?这都能打进高手榜啊?我的天啊~!难道后继无人了么?
"
;
}
public
void
commandAction(Command c, Displayable disp)
...
{
//
TODO 自动生成方法存根
String cmd
=
c.getLabel();
if
(cmd.equalsIgnoreCase(
"
返回
"
))