📄 wzqdisplayable.java~4~
字号:
package wzq;
import javax.microedition.lcdui.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class WzqDisplayable extends Canvas implements CommandListener {
int nWhiteWidth; //width of the white space
int nCanvasW, nCanvasH; //the width and height of the canvas
int nChessWidth; //the width of chesses
int nChessMapLength, nMapGrid, nGridWidth; //the length of chessmap,number of mapgrid and width of grid
int nMapX, nMapY; //the x,y value of the map origin position
int nSelectX, nSelectY; //the x,y value of the position box
boolean bIsPlayer1; //is player1 or not
Chesses chess[][];
boolean bNewGame; //start a new game or not
public WzqDisplayable() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
bNewGame = true;
nWhiteWidth=10;
nCanvasW=getWidth()-nWhiteWidth;
nCanvasH=getHeight()-nWhiteWidth;
nMapGrid=15;
chess=new Chesses[nMapGrid+1][nMapGrid+1];
if(nCanvasW>nCanvasH){
nChessMapLength=nCanvasH-nCanvasH%nMapGrid;
nMapX=(nCanvasW-nChessMapLength)/2+nWhiteWidth/2;
nMapY=(nCanvasH%nMapGrid)/2+nWhiteWidth/2;
}
else{
nChessMapLength=nCanvasW-nCanvasW%nMapGrid;
nMapX=(nCanvasW%nMapGrid)/2+nWhiteWidth/2;
nMapY=(nCanvasH-nChessMapLength)/2+nWhiteWidth/2;
}
nGridWidth=nChessMapLength/nMapGrid;
nChessWidth=nGridWidth-1;
nSelectX=nSelectY=nMapGrid/2;
bIsPlayer1=true;
}
private void jbInit() throws Exception {
// Set up this Displayable to listen to command events
setCommandListener(this);
// add the Exit command
addCommand(new Command("Exit", Command.EXIT, 1));
}
public void commandAction(Command command, Displayable displayable) {
/** @todo Add command handling code */
if (command.getCommandType() == Command.EXIT) {
// stop the MIDlet
WzqMIDlet.quitApp();
}
}
protected void paint(Graphics g) {
/** @todo Add paint codes */
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -