📄 galaxywarcanvas.java
字号:
break;
}
}
//use for socreUpload
if (mode != MODE_NONE) return;
if (c == setCommand) {
setForm.start();
//showMainMenu();
if (isFromOption)
optionBack();
else {
isReaded = false;
isUploaded = false;
autoUpload();
showUpload();
}
display.setCurrent(this);
} else if (c == backCommand) {
isReaded = false;
isUploaded = false;
rankInfo = "";
initCommand();
mode = MODE_REPORT;
isRepaint = false;
display.setCurrent(this);
}if (c == exitCommand){
showMainMenu();
display.setCurrent(this);
}
}
protected void paint(Graphics g) {
g.setFont(font);
g.setColor(0x00000000);
g.fillRect(0, 0, width, height);
switch (mode) {
case MODE_INIT:
drawInit(g);
break;
case MODE_MENU:
drawMenu(g);
break;
case MODE_PAUSE:
drawPauseMenu(g);
break;
case MODE_LOADING:
drawLoading(g);
break;
case MODE_SCORE:
drawScore(g);
break;
case MODE_UPLOAD:
case MODE_INTERNET_RANK:
drawInternetRank(g);
break;
case MODE_BATTLE:
drawMap(g);
drawItem(g);
drawPlayer(g);
drawShot(g);
drawPanel(g);
drawInfo(g);
break;
case MODE_WRITING_SCORE:
drawWritingScore(g);
break;
case MODE_REPORT:
drawReport(g);
break;
case MODE_OPTION:
drawOption(g);
break;
case MODE_HELP:
drawHelp(g);
break;
case MODE_ABOUT:
drawAbout(g);
break;
case MODE_GAMEOVER:
drawGameOver(g);
break;
}
} //end of paint;
private void flowInit() {
totalLoad = 9;
//load all images
try {
if (loadedCounter == -1) {
img = Image.createImage("/title.png");
playSound("/start.mid", "audio/midi", 1);
}
if (loadedCounter == 0) {
panel = Image.createImage("/panel.png");
panel_up = Image.createImage("/panel_up.png");
viewWidth = width;
viewHeight = height - panel.getHeight();
}
if (loadedCounter == 1){
mapImg = Image.createImage("/map.png");
}
if (loadedCounter == 2){
tank = Image.createImage("/tank.png");
}
if (loadedCounter == 3){
boss = Image.createImage("/boss.png");
bossWidth = boss.getWidth() >> 2;
bossHeight = boss.getHeight();
}
if (loadedCounter == 4){
for (int i = 0;i<4;i++) {
shot[i] = Image.createImage("/shot" + i + ".png");
}
}
if (loadedCounter == 5){
for (int i= 0;i< SMOKE;i++) {
smoke[i] = Image.createImage("/smoke" + i + ".png");
}
}
if (loadedCounter == 6){
cheese = Image.createImage("/cheese.png");
}
if (loadedCounter == 7){
digit = Image.createImage("/digit.png");
ranking = Image.createImage("/ranking.png");
}
if (loadedCounter == 8){
hint = Image.createImage("/direction.png");
}
if (loadedCounter == 13) {
//initMap(round);//addround
}
if (loadedCounter == totalLoad) {
try {
Thread.sleep(1500);
} catch (Exception ex) {
System.out.println("sleep: " + ex);
}
img = null;
showMainMenu();
}
if (loadedCounter <= totalLoad -1)
loadedCounter++;
} catch (Exception e) {
System.out.println("loading error: " + e);
}
}
private void flowMenu() {
switch(gameAction) {
case UP:
if (currentMenu -1 >= startMenu) {
currentMenu--;
updateMenu(1);
}
break;
case DOWN:
if (currentMenu + 1 <= MENU_NUM - 1) {
currentMenu++;
updateMenu(1);
}
break;
case FIRE:
processMenu();
break;
}
}
private void flowPause() {
switch(gameAction) {
case UP:
if (currentMenu -1 >= 0) {
currentMenu--;
updateMenu(1);
}
break;
case DOWN:
if (currentMenu + 1 <= PAUSE_MENU_NUM - 1) {
currentMenu++;
updateMenu(1);
}
break;
case FIRE:
processPause();
break;
}
}
private void flowOption() {
switch(gameAction) {
case UP:
if (currentMenu - 2 >= 1) {
currentMenu -= 2;
updateMenu(2);
}
break;
case DOWN:
if (currentMenu + 2 <= OPTION_NUM - 1) {
currentMenu += 2;
updateMenu(2);
}
break;
}
}
private void flowHelp() {
switch(gameAction) {
case UP:
if (currentMenu - 1 >= 0) {
currentMenu--;
for (int i = 0; i < showedNum; i++) {
menu[i] --;
}
}
break;
case DOWN:
if (currentMenu + 1 <= HELP_NUM - showedNum) {
currentMenu++;
for (int i = 0; i < showedNum; i++) {
menu[i] ++;
}
}
break;
}
}
private void flowGameOver() {
if (key!=KEY_NONE || gameAction != KEY_NONE)
gameOverNext();
}
private void flowAbout() {
switch(gameAction) {
case UP:
if (currentMenu - 1 >= 0) {
currentMenu--;
for (int i = 0; i < showedNum; i++) {
menu[i] --;
}
}
break;
case DOWN:
if (currentMenu + 1 <= ABOUT_NUM - showedNum) {
currentMenu++;
for (int i = 0; i < showedNum; i++) {
menu[i] ++;
}
}
break;
}
}
private void flowLoading() {
totalLoad = 4;
switch(loadedCounter) {
case 0:
initMap();
setMapOffset();
break;
case 1:
initRound();
break;
case 2:
initItem();
break;
case 3:
//updateRound();
break;
case 4:
mode = MODE_BATTLE;
player[0].score += lastScore;
initCommand();
isRepaint = false;
break;
}
if (loadedCounter < totalLoad)
loadedCounter++;
}
private void flowBattle() {
if (isWin()) {
if (round == 5)
gameState = 1;
else
gameState = 2;
}
switch (gameState) {
case 0: //game over
playSound("/end.mid", "audio/midi", 1);
showGameOver();
return;
case 1: //win all
playSound("/win.mid", "audio/midi", 1);
showedNum = (height - panel_up.getHeight() - (SPACING2 << 1))
/ (font.getHeight() + SPACING);
mode = MODE_WRITING_SCORE;
initCommand();
isRepaint = false;
isInit = true;
return;
case 2: //win
playSound("/win.mid", "audio/midi", 1);
mode = MODE_REPORT;
initCommand();
isRepaint = false;
return;
}
setMapArea();
processBattle();
move(); //处理我方的移动问题
ai();
checkImpact();
moveShot(); //处理炮弹的移动问题
eatCheese();
}
private void flowScore() {
switch(gameAction) {
case UP:
if (currentScore -1 >= 0) {
currentScore--;
}
break;
case DOWN:
if (currentScore + 1 <= getScoreNum(scoreInfo) - showedNum) {
currentScore++;
}
break;
}
}
private void flowInternetRank() {
if (mode == MODE_UPLOAD && isUploaded) {
isReaded = false;
isUploaded = false;
rankInfo = "";
initCommand();
mode = MODE_REPORT;
isRepaint = false;
}
switch(gameAction) {
case UP:
if (currentRank - 1 >= 0) {
currentRank--;
}
break;
case DOWN:
if (currentRank + 1 <= rankNum - showedNum) {
currentRank ++;
}
break;
}
}
private void flowWritingScore() {
Tank p = player[0];
String currentChar, currentInfo;
if (frameCounter >= MIDDLE && !isStartWait
&& typedInfo.length() < SCORELEN) {
currentChar = "|";
} else {
currentChar = "";
}
currentInfo = p.score + " : " + typedInfo + currentChar;
if (isInit) {
scoreInfo = readScore();
try{
scoreInfoInsert(currentInfo);
}catch(Exception e) {
System.out.println("insert:" + e);
}
isInit = false;
showedNum = (height - panel_up.getHeight() - (SPACING2 << 1))
/ (font.getHeight() + SPACING);
}
scoreInfoUpdate(currentInfo);
if (isStartWait) {
if (charWaitCounter < CHARWAIT)
charWaitCounter ++;
else {
charWaitCounter = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -