import java.io.IOException;
import javax.microedition.lcdui.*;
class MainCanvas extends Canvas implements Runnable
{
int i;
int j;
int k;
int l;
int seed;
int state;
long nextTime;
long now;
Image maze;
Image buf;
Image mazebuf;
Image imgs[];
Graphics bg;
Graphics mg;
Command startCommand;
Command pauseCommand;
int pX;
int pY;
int pDir;
int pLook;
int pCount;
int pState;
int mX;
int mY;
int wantDir;
int dots;
int lives;
int level;
int eatCount;
int gX[];
int gY[];
int gDir[];
int gState[];
int gCount[];
int gLook[];
int sLook[];
int sX[];
int sY[];
int sCount[];
int w;
int h;
int counter;
int oldState;
int speed;
int targetX;
int targetY;
int bestVal;
int bestDir;
int randomness;
Font f;
char scoreChars[];
char levelChars[];
int fH;
int fW;
int lW;
String various[] = {
"E-BEAR presents", "The Develop Men:", "Bryan", "Tony", "Libeia"
};
String dummyScore;
String dummyLevel;
final int dx[] = {
0, 0, 0, -1, 1
};
final int dy[] = {
0, -1, 1, 0, 0
};
final int offsX[] = {
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -5, -6, -6, -6, -7, -7, -7,
-7
};
final int offsY[] = {
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2, 0, -2, -2, -2, 0, 0, 0,
0
};
final int bonuses[] = {
8, 1, 2, 4
};
final int dPos[] = {
0, -31, 31, -1, 1
};
int map[] = {
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 8, 8, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 8,
8, 8, 8, 8, 1, 8, 8, 8, 8, 1,
8, 8, 8, 8, 8, 1, 8, 8, 1, 8,
8, 8, 8, 8, 1, 8, 8, 8, 8, 1,
8, 8, 8, 8, 8, 2, 8, 8, 8, 8,
1, 8, 8, 8, 8, 8, 1, 8, 8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8, 8, 8, 1, 8, 8, 1, 8, 8,
1, 8, 8, 8, 8, 8, 8, 8, 1, 1,
1, 1, 1, 1, 8, 8, 1, 1, 1, 1,
8, 8, 1, 1, 1, 1, 8, 8, 1, 1,
1, 1, 1, 1, 8, 8, 8, 8, 8, 1,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
1, 8, 8, 1, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 1, 8, 8, 8, 8, 8,
1, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 1, 8, 8, 1, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 1, 8, 8, 8, 8,
8, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8
};
Thread runner;
int x0;
int y0;
public MainCanvas(Command command, Command command1)
{
seed = 1;
state = 0;
imgs = new Image[27];
gX = new int[3];
gY = new int[3];
gDir = new int[3];
gState = new int[3];
gCount = new int[3];
gLook = new int[3];
sLook = new int[4];
sX = new int[4];
sY = new int[4];
sCount = new int[4];
counter = 0;
f = Font.getFont(0, 0, 0);
scoreChars = new char[6];
levelChars = new char[2];
dummyScore = "00000";
dummyLevel = "00";
startCommand = command;
pauseCommand = command1;
try
{
maze = Image.createImage("/res/pacmaze.png");
for(i = 0; i < 27; i++)
imgs[i] = Image.createImage("/res/img" + i + ".png");
} catch(IOException ioexception) { }
w = getWidth();
h = getHeight();
if(w > 112)
{
x0 = (w - 112) / 2;
w = 112;
}
if(h > 133)
{
y0 = (h - 133) / 2;
h = 133;
}
buf = Image.createImage(w, h);
mazebuf = Image.createImage(112, 124);
bg = buf.getGraphics();
mg = mazebuf.getGraphics();
bg.setColor(0, 0, 0);
bg.fillRect(0, 0, w, h);
f = Font.getFont(0, 0, 0);
fH = f.getHeight() - 1;
if(fH > 10)
{
f = Font.getFont(0, 0, 8);
fH = f.getHeight() - 1;
if(fH > 11)
fH = 11;
}
bg.setFont(f);
mg.setFont(f);
fW = f.stringWidth(dummyScore);
lW = f.stringWidth(dummyLevel);
prepareIntro();
runner = new Thread(this);
runner.start();
}
public void prepareIntro()
{
mg.setColor(0, 0, 0);
mg.fillRect(0, 0, w, h - 9);
mg.setColor(255, 255, 255);
mg.drawString(various[0], (w - f.stringWidth(various[0])) / 2, 0, 0x10 | 0x4);
mg.drawString(various[1], (w - f.stringWidth(various[1])) / 2, 35, 0x10 | 0x4);
bg.setClip(0, 0, w, h - 9);
state = 10;
oldState = 10;
counter = 0;
remov
没有合适的资源?快使用搜索试试~ 我知道了~
j2me 吃豆豆小游戏代码
共69个文件
png:56个
class:4个
db:2个
4星 · 超过85%的资源 需积分: 9 183 下载量 68 浏览量
2010-09-01
19:47:19
上传
评论 6
收藏 74KB RAR 举报
温馨提示
这是一个基于j2me开发的经典小游戏《吃豆豆》,包括源代码,图片资源等。可供参考。
资源推荐
资源详情
资源评论
收起资源包目录
j2me 吃豆豆小游戏.rar (69个子文件)
6_29
.project 536B
Eatdot.java 1KB
.settings
org.eclipse.jdt.core.prefs 166B
mianMidlet.java 26KB
6_29.jad 221B
Eatdot.class 2KB
verified
libs
classes
Eatdot.class 2KB
res
img4.png 130B
img10.png 169B
img11.png 173B
img21.png 175B
img3.png 136B
img23.png 173B
img15.png 129B
img13.png 165B
img9.png 171B
img7.png 136B
img22.png 179B
img24.png 171B
img16.png 129B
img0.png 132B
img8.png 175B
img20.png 128B
img14.png 125B
img6.png 130B
img25.png 428B
img5.png 136B
pacmaze.png 1KB
img17.png 128B
img12.png 127B
img1.png 136B
img26.png 181B
Thumbs.db 47KB
img18.png 128B
img2.png 133B
img19.png 128B
MainCanvas.class 19KB
.eclipseme 239B
res
img4.png 130B
img10.png 169B
img11.png 173B
img21.png 175B
img3.png 136B
img23.png 173B
img15.png 129B
img13.png 165B
img9.png 171B
img7.png 136B
img22.png 179B
img24.png 171B
img16.png 129B
img0.png 132B
img8.png 175B
img20.png 128B
img14.png 125B
img6.png 130B
img25.png 428B
img5.png 136B
pacmaze.png 1KB
img17.png 128B
img12.png 127B
img1.png 136B
img26.png 181B
Thumbs.db 47KB
img18.png 128B
img2.png 133B
img19.png 128B
.classpath 226B
MainCanvas.class 18KB
共 69 条
- 1
资源评论
- yichunshao2013-06-09代码挺好的,就是有点小错误
- 画眼线的猪2013-06-20有点小错误 需要自己改下
- lizhengcctv2013-04-27运行的时候有错误,不会调
- j10854858262011-12-12出现了***.jar出错,打不开,但是代码是好的
yingying_yy
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功