📄 bnb_game.java
字号:
pausepage--;
if (pausepage < 1)
{
pausepage = 4;
}
break;
case DOWN:
pausepage++;
if (pausepage > 4)
{
pausepage = 1;
}
break;
}
if (key == -6)
{
switch (pausepage)
{
case 1:
isOK = true;
isPause = false;
Tools.releaseGame();
stage = UI_MENU;
break;
case 2:
isPause = false;
stage = UI_GAME;
pausepage = 2;
pausetime = 0;
break;
case 3:
isMusic = !isMusic;
break;
case 4:
isOK = true;
isPause = false;
Tools.releaseGame();
BnB_MIDlet.midlet.notifyDestroyed();
break;
}
}
break;
case UI_GAME:
// TODO 游戏中的按键处理!
player.keyPressed(key);
if (key == -6)
{
stage = UI_PUASE;
isPause = true;
}
break;
case UI_PASS:
if (key == -6)
{
if (!isOK)
{
if (pass < 4)
{
pass++;
isOK = true;
Tools.releasePass();
stage = UI_GAME;
}
else
{
isOK = true;
Tools.releasePass();
stage = UI_ENDING;
}
}
}
break;
case UI_ENDING:
if (key == -6)
{
if (!isOK)
{
isOK = true;
Tools.releaseEnding();
stage = UI_MENU;
}
}
break;
case UI_OVER:
if (key == -6)
{
if (!isOK)
{
isOK = true;
Tools.releaseOver();
stage = UI_MENU;
}
}
break;
}
}
protected void keyReleased(int key)
{
if (stage == UI_GAME)
{
if (player != null)
{
player.keyReleased(key);
}
}
}
protected void mypaint()
{
switch (stage)
{
case UI_LOGO:
paintLogo(g);
break;
case UI_MENU:
paintMenu(g);
break;
case UI_SETNAME:
paintSetName(g);
break;
case UI_SETUP:
break;
case UI_HELP:
paintHelp(g);
break;
case UI_SCORE:
paintScore(g);
break;
case UI_EXIT:
paintExit(g);
break;
case UI_PUASE:
paintPause(g);
break;
case UI_GAME:
paintGame(g);
break;
case UI_PASS:
paintPass(g);
break;
case UI_ENDING:
paintEnding(g);
break;
case UI_OVER:
paintOver(g);
break;
}
}
public static final void paintLogo(Graphics g)
{
if (isOK)
{
isOK = false;
Tools.loadLogo();
}
clear(g);
g.drawImage(Tools.logo, (W >>> 1), (H >>> 1), Graphics.HCENTER
| Graphics.VCENTER);
rms.addDefaultRecord();
try
{
Thread.sleep(2000);
}
catch (Exception e)
{
e.printStackTrace();
}
if (!isOK)
{
stage = UI_MENU;
isOK = true;
Tools.releaseLogo();
}
}
public static final void paintMenu(Graphics g)
{
if (isOK)
{
isOK = false;
Tools.loadMenu();
}
clear(g);
g.drawImage(Tools.menu, 0, 0, GRAPHICS_TL); // 15 135
g.setColor(234, 177, 18);
g.setFont(FONT1);
switch (menupage)
{
case 1:
Tools.paintString(g, "< 开始游戏 >", 15, 135, GRAPHICS_TL);
break;
case 2:
Tools.paintString(g, "< 游戏帮助 >", 15, 135, GRAPHICS_TL);
break;
case 3:
if (isMusic)
{
Tools.paintString(g, "< 音乐:开 >", 15, 135, GRAPHICS_TL);
}
else
{
Tools.paintString(g, "< 音乐:关 >", 15, 135, GRAPHICS_TL);
}
break;
case 4:
Tools.paintString(g, "< 游戏排行 >", 15, 135, GRAPHICS_TL);
break;
case 5:
Tools.paintString(g, "< 退出游戏 >", 15, 135, GRAPHICS_TL);
break;
}
}
public static final void paintSetName(Graphics g)
{
if (isOK)
{
isOK = false;
Tools.loadSetName();
}
clear(g);
g.drawImage(Tools.bg, 0, 0, GRAPHICS_TL);
g.setColor(0, 0, 0);
g.setFont(FONT1);
Tools.paintString(g, "设置名字:", 20, 40, GRAPHICS_TL);
g.drawRect(28, 70, 65, 20);
Tools.paintClip(g, Tools.arrowhead, cols * 15 + 33, 60, 0, 0, 11, 7);
Tools.paintClip(g, Tools.arrowhead, cols * 15 + 33, 94, 11, 0, 11, 7);
Tools.paintClip(g, Tools.font, 35, 74, rows[0] * 10, 0, 10, 13);
Tools.paintClip(g, Tools.font, 50, 74, rows[1] * 10, 0, 10, 13);
Tools.paintClip(g, Tools.font, 65, 74, rows[2] * 10, 0, 10, 13);
Tools.paintClip(g, Tools.font, 80, 74, rows[3] * 10, 0, 10, 13);
g.setFont(FONT2);
Tools.paintString(g, "确定", 20, 135, GRAPHICS_TL);
Tools.paintString(g, "返回", 88, 135, GRAPHICS_TL);
}
public static final void paintHelp(Graphics g)
{
if (isOK)
{
Tools.loadBackGround();
isOK = false;
}
g.drawImage(Tools.bg, 0, 0, GRAPHICS_TL);
g.setColor(0, 0, 0);
g.setFont(FONT1);
Tools.paintString(g, "按键:", 3, 0, GRAPHICS_TL);
g.setFont(FONT2);
Tools.paintString(g, "上下移动:2/8", 20, 40, GRAPHICS_TL);
Tools.paintString(g, "左右移动:4/6", 20, 70, GRAPHICS_TL);
Tools.paintString(g, "放泡泡:5", 20, 100, GRAPHICS_TL);
g.setFont(FONT2);
Tools.paintString(g, "返回", 88, 135, GRAPHICS_TL);
}
public static final void paintScore(Graphics g)
{
if (isOK)
{
Tools.loadBackGround();
try
{
rms.openRecordStore(false);
}
catch (Exception e)
{
e.printStackTrace();
}
isOK = false;
}
g.drawImage(Tools.bg, 0, 0, GRAPHICS_TL);
g.setColor(0, 0, 0);
g.setFont(FONT1);
Tools.paintString(g, "排行榜", 3, 0, GRAPHICS_TL);
g.setFont(FONT2);
for (int i = 1; i <= rms.MAXSIZE; i++)
{
rms.loadScore(i);
Tools.paintString(g, rms.name, 20, i * 25 + 5, GRAPHICS_TL);
Tools.paintString(g, "" + rms.score, 110, i * 25 + 5, GRAPHICS_TR);
}
}
public static final void paintExit(Graphics g)
{
if (isOK)
{
Tools.loadBackGround();
isOK = false;
}
g.drawImage(Tools.bg, 0, 0, GRAPHICS_TL);
g.setColor(0, 0, 0);
g.setFont(FONT1);
Tools.paintString(g, "是否退出?", (W >>> 1) - 40, H >>> 1, GRAPHICS_TL);
g.setFont(FONT2);
Tools.paintString(g, "确定", 20, 135, GRAPHICS_TL);
Tools.paintString(g, "返回", 88, 135, GRAPHICS_TL);
}
public static final void paintPass(Graphics g)
{
if (isOK)
{
Tools.loadPass();
isOK = false;
}
g.drawImage(Tools.pass, 0, 0, GRAPHICS_TL);
g.setColor(0, 0, 0);
g.setFont(FONT1);
switch (pass)
{
case 1:
Tools.paintString(g, "第一关", 42, 37, GRAPHICS_TL);
break;
case 2:
Tools.paintString(g, "第二关", 42, 37, GRAPHICS_TL);
break;
case 3:
Tools.paintString(g, "第三关", 42, 37, GRAPHICS_TL);
break;
case 4:
Tools.paintString(g, "第四关", 42, 37, GRAPHICS_TL);
break;
}
g.setColor(0, 255, 0);
g.setFont(FONT3);
Tools.paintString(g, "" + BnB_Player.score, 99, 70, GRAPHICS_TR);
Tools.paintString(g, timeToString(time), 99, 84, GRAPHICS_TR);
g.setColor(0, 255, 0);
g.setFont(FONT1);
Tools.paintString(g, "" + totalizescore, 96, 120, GRAPHICS_TR);
}
public static final void paintPause(Graphics g)
{
if (Tools.bg != null)
g.drawImage(Tools.bg, 0, 0, GRAPHICS_TL);
if (pausetime >= Integer.MAX_VALUE)
{
pausetime = 0;
}
switch (pausepage)
{
case 1:
g.setColor(255, 0, 0);
if (pausetime++ % 6 != 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -