📄 maincanvas.java
字号:
import com.nokia.mid.ui.FullCanvas;
import java.io.*;
import java.util.Random;
import javax.microedition.lcdui.*;
import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.rms.RecordStore;
final class MainCanvas extends FullCanvas
{
public MainCanvas(Display display, VARPG_p3 varpg_p3)
{
mainRun = 0;
mainPause = 1;
mainExit = 2;
mainSpalsh = 3;
ProgStaue = 0;
pauseFlag = false;
count = 0;
imgO = null;
bySKey = 0;
nowKey = 0;
Sound = true;
hand = new Image[5];
img_nodraw = false;
gameOverFlag = false;
outMidlet = false;
outEvent = true;
Disp = display;
App = varpg_p3;
Disp.setCurrent(this);
Run = Runtime.getRuntime();
Rand = new Random();
lMill = 0L;
nGame_Screen_W = 128;
nGame_Screen_H = 128;
byDraw_Zero_X = 4;
byDraw_Zero_Y = 8;
byDrawObj_Zero_X = (byte)(byDraw_Zero_X - 120);
byDrawObj_Zero_Y = (byte)(byDraw_Zero_Y - 120);
defF = Font.getFont(32, 0, 8);
chH = defF.getHeight();
chW = defF.charWidth('\u597D');
OffImg = Image.createImage(176, 208);
offGfx = OffImg.getGraphics();
ProgStaue = mainSpalsh;
readSound();
initplay();
nGame_Flag |= 0x480;
}
public void paint(Graphics g)
{
offGfx.setFont(FONT_SMALL);
switch(ProgStaue)
{
case 1: // '\001'
default:
break;
case 0: // '\0'
if(byGame_Chap[0] >= 4 && byGame_Chap[0] <= 7)
playSound();
else
try
{
if(player.getState() == 400)
player.stop();
}
catch(Exception exception) { }
offGfx.setFont(FONT_SMALL);
UpDate();
if(bySKey > 0)
{
if(pauseFlag)
pauseFlag = false;
offGfx.setColor(0, 0, 0);
offGfx.setClip(0, 0, getWidth(), getHeight());
offGfx.setColor(255, 255, 255);
switch(bySKey)
{
case 1: // '\001'
offGfx.setColor(192, 168, 0);
offGfx.fillRect(5, 189, chW + chW + 6, chH + 2);
offGfx.setColor(255, 255, 255);
offGfx.drawString("\u786E\u5B9A", 8, 190, 0);
break;
case 2: // '\002'
offGfx.setColor(192, 168, 0);
offGfx.fillRect(5, 189, chW + chW + 6, chH + 2);
offGfx.setColor(255, 255, 255);
offGfx.drawString("\u786E\u5B9A", 8, 190, 0);
offGfx.setColor(192, 168, 0);
offGfx.fillRect(141, 189, chW + chW + 6, chH + 2);
offGfx.setColor(255, 255, 255);
offGfx.drawString("\u8FD4\u56DE", 144, 190, 0);
break;
case 3: // '\003'
offGfx.setColor(192, 168, 0);
offGfx.fillRect(141, 189, chW + chW + 6, chH + 2);
offGfx.setColor(255, 255, 255);
offGfx.drawString("\u83DC\u5355", 144, 190, 0);
break;
case 4: // '\004'
offGfx.setColor(192, 168, 0);
offGfx.fillRect(141, 189, chW + chW + 6, chH + 2);
offGfx.setColor(255, 255, 255);
offGfx.drawString("\u8FD4\u56DE", 144, 190, 0);
break;
case 5: // '\005'
offGfx.setColor(192, 168, 0);
offGfx.fillRect(5, 189, chW + chW + 6, chH + 2);
offGfx.setColor(255, 255, 255);
offGfx.drawString("\u786E\u5B9A", 8, 190, 0);
offGfx.setColor(192, 168, 0);
offGfx.fillRect(141, 189, chW + chW + 6, chH + 2);
offGfx.setColor(255, 255, 255);
offGfx.drawString("\u83DC\u5355", 144, 190, 0);
break;
}
nowKey = bySKey;
}
g.drawImage(OffImg, 0, 0, 0);
break;
case 2: // '\002'
count++;
if(count == 1)
{
g.setColor(0);
g.fillRect(0, 0, 176, 208);
try
{
imgCp = Image.createImage("/cp.png");
}
catch(IOException ioexception) { }
g.drawImage(imgCp, 176 - imgCp.getWidth() >> 1, 208 - imgCp.getHeight() >> 1, 20);
break;
}
if(count != 10)
break;
gameOverFlag = true;
try
{
saveSound();
App.destroyApp(false);
}
catch(Exception exception1) { }
break;
case 3: // '\003'
count++;
g.setColor(255, 255, 255);
g.fillRect(0, 0, 176, 208);
if(count < 4)
{
try
{
imgCp = Image.createImage("/logo.png");
}
catch(IOException ioexception1) { }
g.drawImage(imgCp, 176 - imgCp.getWidth() >> 1, 208 - imgCp.getHeight() >> 1, 20);
imgCp = null;
break;
}
if(count < 8)
{
try
{
imgCp = Image.createImage("/cp.png");
}
catch(IOException ioexception2) { }
g.drawImage(imgCp, 176 - imgCp.getWidth() >> 1, 208 - imgCp.getHeight() >> 1, 20);
imgCp = null;
break;
}
if(imgCp != null)
imgCp = null;
ProgStaue = mainRun;
count = 0;
break;
}
}
public void keyPressed(int i)
{
boolean flag = false;
outEvent = true;
if(i == -7)
if(ProgStaue == mainPause)
{
ProgStaue = mainRun;
nIK = 0;
} else
{
nIK |= 0x100;
}
if(i == -6)
nIK |= 0x40000;
if(i - 35 >= 0 && i - 57 <= 0)
{
nIK |= 1 << i - 35;
nRK |= 1 << i - 35;
} else
if(i != 0)
{
int j = getGameAction(i);
if(j - 1 >= 0 && j - 8 <= 0)
{
nIK |= 1 << j + 22;
nRK |= 1 << j + 22;
}
}
}
public void keyReleased(int i)
{
boolean flag = false;
if(i == -7)
nRK = 0;
if(i == -6)
nRK = 0;
if(i - 35 >= 0 && i - 57 <= 0)
nRK &= ~(1 << i - 35);
else
if(i != 0)
{
int j = getGameAction(i);
if(j - 1 >= 0 && j - 8 <= 0)
nRK &= ~(1 << j + 22);
}
}
public void UpDate()
{
switch(byGame_Chap[0])
{
case 4: // '\004'
CBInit();
break;
case 5: // '\005'
CBattle();
break;
case 7: // '\007'
CD();
break;
case 15: // '\017'
if(menuHelpDis)
{
draw_help(false);
if(menuHelpDis);
} else
if(menuSetDis)
draw_set(false);
else
CMe();
break;
case 11: // '\013'
CC();
break;
case 16: // '\020'
CHo();
break;
case 17: // '\021'
CSh();
break;
case 13: // '\r'
CM();
break;
case 14: // '\016'
CMeInit();
break;
case 6: // '\006'
CDInit();
break;
case 8: // '\b'
CDLoad();
break;
case 12: // '\f'
CMInit();
break;
case 10: // '\n'
CCInit();
break;
case 9: // '\t'
offGfx.setColor(0, 0, 0);
offGfx.fillRect(0, 0, getWidth(), getHeight());
CCLoad(byGame_Chap[1]);
break;
case 0: // '\0'
offGfx.setColor(0, 0, 0);
offGfx.fillRect(0, 0, getWidth(), getHeight());
CLFix();
break;
case 2: // '\002'
CTInit();
break;
case 3: // '\003'
if(menuflag == 3 && menuHelpDis)
draw_help(true);
else
if(menuflag == 2 && menuSetDis)
draw_set(true);
else
CTitle();
break;
case 18: // '\022'
CEn();
break;
}
if((nGame_Flag & 8) != 0 || img_nodraw)
{
img_nodraw = false;
nGame_Flag &= -9;
SColor(85, 63, 0);
FRect(24 + byDraw_Zero_X, 96 + byDraw_Zero_Y + 6, 32, 16);
SColor(85, 63, 0);
FRect(80 + byDraw_Zero_X, 96 + byDraw_Zero_Y + 6, 32, 16);
for(int i = 1; i >= 0; i--)
{
int j = 96 + byDraw_Zero_Y;
DImage(Img_No[10], 25 + 56 * i + byDraw_Zero_X, j + 1 + 6, 0);
if(nMy_HP[i][0] - 10 >= 0)
{
DImage(Img_No[(nMy_HP[i][0] / 10) % 10], 43 + 56 * i + byDraw_Zero_X, j + 2 + 6, 0);
if(nMy_HP[i][0] - 100 >= 0)
DImage(Img_No[(nMy_HP[i][0] / 100) % 10], 37 + 56 * i + byDraw_Zero_X, j + 2 + 6, 0);
}
DImage(Img_No[nMy_HP[i][0] % 10], 49 + 56 * i + byDraw_Zero_X, j + 2 + 6, 0);
DImage(Img_No[11], 25 + 56 * i + byDraw_Zero_X, j + 8 + 6, 0);
if(byMy_SP[i][0] - 10 >= 0)
DImage(Img_No[(byMy_SP[i][0] / 10) % 10], 43 + 56 * i + byDraw_Zero_X, j + 9 + 6, 0);
DImage(Img_No[byMy_SP[i][0] % 10], 49 + 56 * i + byDraw_Zero_X, j + 9 + 6, 0);
}
DImage(Img_No[12], byDraw_Zero_X, 90 + byDraw_Zero_Y + 6, 0);
DImage(Img_No[13], 56 + byDraw_Zero_X, 90 + byDraw_Zero_Y + 6, 0);
offGfx.setClip(0, 0, getWidth(), getHeight());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -