📄 blackbomb.java
字号:
if(bomb.cursorX < bomb.width-1) bomb.cursorX++;
break;
case 't':case 'y':case 'T':case 'Y':
if(bomb.cursorY > 0) bomb.cursorY--;
break;
case 'b':case'n':case'B':case'N':
if(bomb.cursorY < bomb.height-1) bomb.cursorY++;
break;
case 'q':case'Q':case'w':case'W':
if(bomb.getProgress() != Bomb._ONGOING)
{
break;
}
bomb.uncoverone(bomb.cursorX,bomb.cursorY);
break;
case 'o':case'O':case'p':case'P':
if(bomb.getProgress() != Bomb._ONGOING)
{
break;
}
if(Bomb._SETREDFLAGRIGHT == bomb.setAsRedFlag(bomb.cursorX,bomb.cursorY))
{
if(bomb.getProgress()==Bomb._SUCCESSFUL) //update the score list
{
for(int i=0;i<5;i++)
{
if(top5.score[i]>timeLen)
{
for(int j=4;j>i;j--)
{
top5.score[j] = top5.score[j-1];
}
top5.score[i]=timeLen;
//top5.score[i].name=tmpName;
recordBroken = 1;
break;
}
}
}
}
break;
default:
break;
}
invalidate();
return super.keyChar(key, status, time);
}
protected boolean navigationMovement(int dx, int dy, int status, int time)
{
if(dx<0)
{
if(bomb.cursorX > 0) bomb.cursorX--;
}
else if(dx>0)
{
if(bomb.cursorX < bomb.width-1) bomb.cursorX++;
}
if(dy<0)
{
if(bomb.cursorY > 0) bomb.cursorY--;
}
else if(dy>0)
{
if(bomb.cursorY < bomb.height-1) bomb.cursorY++;
}
invalidate();
return true;
}
protected boolean trackwheelClick(int status, int time)
{
if(bomb.getProgress() != Bomb._ONGOING)
{
return true;
}
int ret = bomb.uncoverone(bomb.cursorX,bomb.cursorY);
if(ret == Bomb._FAILED)
{
invalidate();
}
else if(ret == Bomb._SUCCESSFUL)
{
if(bomb.getProgress()==Bomb._SUCCESSFUL) //update the score list
{
for(int i=0;i<5;i++)
{
if(top5.score[i]>timeLen)
{
for(int j=4;j>i;j--)
{
top5.score[j] = top5.score[j-1];
}
top5.score[i]=timeLen;
//top5.score[i].name=tmpName;
recordBroken = 1;
break;
}
}
}
}
else
{
//do nothing
}
invalidate();
return true;
}
private class CustomField1 extends Field implements DrawStyle
{
private int fieldWidth, fieldHeight, xCoord, yCoord;
public CustomField1(int xVal, int yVal)
{
super(Field.NON_FOCUSABLE);
xCoord = xVal;
yCoord = yVal;
fieldHeight = Graphics.getScreenHeight();
fieldWidth = Graphics.getScreenWidth();
}
public void setXCoord(int xVal)
{
if (xVal != xCoord)
{
xCoord = xVal;
invalidate();
}
}
public int getXCoord(){return xCoord;}
public void setYCorrd(int yVal)
{
if (yVal != yCoord)
{
yCoord = yVal;
invalidate();
}
return;
}
public int getYCoord() { return yCoord; }
public int getPreferredWidth(){ return fieldWidth; }
public int getPreferredHeight() { return fieldHeight; }
public void layout(int width, int height)
{
setExtent(getPreferredWidth(),
getPreferredHeight());
}
public void paint(Graphics graphics)
{
//Draw a circle the size of the field.
int edgeHeight = 20;
int edgeWidth = 0;
int h = Graphics.getScreenHeight()-edgeHeight;
int w = Graphics.getScreenWidth();
int theSize = (h/bomb.height)<(w/bomb.width)?(h/bomb.height):(w/bomb.width);
// Dialog.alert("h=="+h+", w=="+w+", theSize="+theSize+", bomb.height="+bomb.height+",bomb.width="+bomb.width);
graphics.drawBitmap(0,0,240,20,startBitmap,0,240);//
if(timeLen>9999)
{
graphics.drawBitmap(240-60,0,12,20,timeBitmap,12*(timeLen/10000),0);//
}
graphics.drawBitmap(240-48,0,12,20,timeBitmap,12*(timeLen%10000/1000),0);//
graphics.drawBitmap(240-36,0,12,20,timeBitmap,12*(timeLen%10000%1000/100),0);//
graphics.drawBitmap(240-24,0,12,20,timeBitmap,12*(timeLen%10000%1000%100/10),0);//
graphics.drawBitmap(240-12,0,12,20,timeBitmap,12*(timeLen%10000%1000%100%10),0);//
graphics.setColor(0xffffff);
String statusStr = new String();
statusStr = " "+(bomb.bnum-bomb.getBombMarked())+" ";
graphics.drawText(statusStr,0,0);
//draw the progress of the game: ongoing, success, failed
switch(bomb.getProgress())
{
case Bomb._ONGOING:
graphics.drawBitmap(240/2-10,0,20,20,handBitmap,2*20,0);
break;
case Bomb._SUCCESSFUL:
graphics.drawBitmap(240/2-10,0,20,20,handBitmap,1*20,0);
break;
case Bomb._FAILED:
graphics.drawBitmap(240/2-10,0,20,20,handBitmap,0*20,0);
break;
default:
break;
}
for(int i=0;i<bomb.height;i++)
{
for(int j=0;j<bomb.width;j++)
{
if(bomb.area[i][j][1]==Bomb._COVERED)
{
graphics.drawBitmap(i*theSize+edgeWidth,j*theSize+edgeHeight,theSize-1,theSize-1,signBitmap,0,_SIDELENOFBMP*0);
//graphics.fillRect(i*theSize+edge,j*theSize+edge,theSize-1,theSize-1);
}
else if(bomb.area[i][j][1]==Bomb._REDFLAG)
{
graphics.drawBitmap(i*theSize+edgeWidth,j*theSize+edgeHeight,theSize-1,theSize-1,signBitmap,0,_SIDELENOFBMP*1);
}
else if(bomb.area[i][j][1]==Bomb._QUESMARK)
{
graphics.drawBitmap(i*theSize+edgeWidth,j*theSize+edgeHeight,theSize-1,theSize-1,signBitmap,0,_SIDELENOFBMP*2);
}
else if(bomb.area[i][j][1]==Bomb._REDBOMB)
{
graphics.drawBitmap(i*theSize+edgeWidth,j*theSize+edgeHeight,theSize-1,theSize-1,signBitmap,0,_SIDELENOFBMP*3);
}
else if(bomb.area[i][j][1]==Bomb._XBOMB)
{
graphics.drawBitmap(i*theSize+edgeWidth,j*theSize+edgeHeight,theSize-1,theSize-1,signBitmap,0,_SIDELENOFBMP*4);
}
else if(bomb.area[i][j][1]==Bomb._BBOMB)
{
graphics.drawBitmap(i*theSize+edgeWidth,j*theSize+edgeHeight,theSize-1,theSize-1,signBitmap,0,_SIDELENOFBMP*5);
}
else if((bomb.area[i][j][1]>=Bomb._BOMBAROUND_0)&&(bomb.area[i][j][1]<=Bomb._BOMBAROUND_8))
{
graphics.drawBitmap(i*theSize+edgeWidth,j*theSize+edgeHeight,theSize-1,theSize-1,signBitmap,0,(_SIDELENOFBMP*(_BMPICONNUM-bomb.area[i][j][1]-1)));
}
else
{
//do nothing??
}
}
}
graphics.setColor(0xdc143c);
graphics.drawRect(bomb.cursorX*theSize+edgeWidth,bomb.cursorY*theSize+edgeHeight,theSize-1,theSize-1);
//graphics.drawText("A",5,10,15,15);
}
}
/*
public class WinnerNameScreen extends MainScreen
{
private BasicEditField name;
public String getName = new String("Noname");
//private myButtonField confirmBtn;
public WinnerNameScreen()
{
super();
LabelField title = new LabelField("You are in the top 5 now\nPlease enter your name:",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
name = new EditField("Name","Noname");
add(name);
}
public void close()
{
getName = name.getText();
super.close();
}
}
*/
}
/*
public class SettingScreen extends MainScreen
{
private BasicEditField setWidth,setHeight,setBombNum;
//private ButtonField confirmBtn;
public SettingScreen()
{
super();
LabelField title = new LabelField("Setting the parameter",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
//setWidth = new EditField("Enter the Width: ","14");
//setHeight = new EditField("Enter the Height: ","14");
setBombNum = new BasicEditField("Enter the Bomb Number[30-99]: ","30",2,BasicEditField.FILTER_NUMERIC);
//add(setWidth);
//add(setHeight);
add(setBombNum);
//confirmBtn = new ButtonField("Confirm");
//add(confirmBtn);
}
public void close()// when close the screen, we need to save the score to file.
{
if(Dialog.SAVE == Dialog.ask(Dialog.D_SAVE,"Save?"))
{
bp.enterBombNum = Integer.parseInt(setBombNum.getText());
if(bp.enterBombNum<30) bp.enterBombNum = 30;
if(bp.enterBombNum>99) bp.enterBombNum = 99;
}
//super.close();
}
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -