📄 mapcanvas.java
字号:
import java.io.InputStream;
import java.io.PrintStream;
import javax.microedition.lcdui.*;
class MapCanvas extends Canvas
{
public static int mode = 0;
public static int CanvasWidth;
public static int CanvasHeight;
public static int GameWidth;
public static int GameHeight;
public static Graphics G = null;
public static Image offimage = null;
public static Graphics offscreen = null;
public static boolean still;
public static int OFFX;
public static int OFFY;
public static int lightflag = 0;
Font E3;
String E4;
String E5;
String E6;
Image E7;
Image E8;
Image E9;
Image EA;
Image EB;
Image EC;
Image ED;
MatrixImage EE;
MatrixImage EF;
MatrixImage F0;
MatrixImage F1;
MatrixImage F2;
int F3;
MatrixImage F4;
MatrixImage F5;
MatrixImage F6;
MatrixImage F8;
MatrixImage F9;
int FA;
MatrixImage FB;
boolean FC;
int FD;
int FE;
Role_Ryu FF;
Role_Lee _fld0100;
int _fld0101;
int _fld0102;
MapCanvas()
{
E3 = null;
E4 = "M.S.F. 1.0";
E5 = "JShape Software";
E6 = "2001 (C)";
FD = 0;
FE = 0;
}
public void init()
{
mode = 0;
CanvasWidth = getWidth();
CanvasHeight = getHeight();
offimage = Image.createImage(CanvasWidth, CanvasHeight);
offscreen = offimage.getGraphics();
OFFX = (CanvasWidth - 120) / 2;
OFFY = (CanvasHeight - 80) / 2;
try
{
Image image = Image.createImage("/intro1.png");
E7 = Image.createImage(60, 55);
G = E7.getGraphics();
G.drawImage(image, 0, 0, 20);
E8 = Image.createImage(60, 55);
G = E8.getGraphics();
G.drawImage(image, 0, -55, 20);
E9 = Image.createImage(60, 55);
G = E9.getGraphics();
G.drawImage(image, 0, -110, 20);
EA = Image.createImage(60, 55);
G = EA.getGraphics();
G.drawImage(image, 0, -165, 20);
EB = Image.createImage(60, 55);
G = EB.getGraphics();
G.drawImage(image, 0, -220, 20);
EC = Image.createImage(60, 55);
G = EC.getGraphics();
G.drawImage(image, 0, -275, 20);
G = null;
image = null;
}
catch(Exception exception)
{
System.out.println(exception);
}
MatrixImage matriximage = CreateGifMatrixImage("/msf.gif");
EE = matriximage.crop(0, 0, 18, 40);
EF = matriximage.crop(18, 0, 22, 39);
F0 = matriximage.crop(40, 0, 29, 39);
F1 = matriximage.crop(70, 0, 30, 33);
F2 = matriximage.crop(70, 34, 22, 12);
F4 = matriximage.crop(0, 41, 15, 34);
F5 = matriximage.crop(16, 41, 19, 34);
F6 = matriximage.crop(37, 41, 33, 34);
F8 = matriximage.crop(0, 77, 21, 19);
F9 = matriximage.crop(22, 77, 38, 19);
FB = matriximage.crop(76, 50, 13, 13);
matriximage = null;
still = false;
F3 = 0;
FA = 0;
FC = false;
_fld0100 = new Role_Lee();
FF = new Role_Ryu();
_fld0101 = 100;
_fld0102 = 100;
}
public MatrixImage CreateGifMatrixImage(String s)
{
try
{
InputStream inputstream = getClass().getResourceAsStream(s);
GifDecoder gifdecoder = new GifDecoder(inputstream);
MatrixImage matriximage = gifdecoder.decodeMatrix();
inputstream.close();
gifdecoder.clear();
gifdecoder = null;
return matriximage;
}
catch(Exception exception)
{
return null;
}
}
public void paint(Graphics g)
{
if(G == null)
{
G = g;
E3 = g.getFont();
}
if(Intro.flag)
{
switch(Intro.seq)
{
case 1: // '\001'
int i = (CanvasWidth - 60) / 2;
int l = (CanvasHeight - 55) / 2;
Image image = null;
switch(Intro.count)
{
case 1: // '\001'
image = E7;
break;
case 2: // '\002'
image = E8;
break;
case 3: // '\003'
image = E9;
break;
case 4: // '\004'
image = EA;
break;
case 5: // '\005'
image = EB;
break;
case 6: // '\006'
image = EC;
break;
}
if(Intro.count >= 6)
offscreen.setColor(0xffffff);
else
if(Intro.count >= 4)
offscreen.setColor(0x808080);
else
offscreen.setColor(0);
offscreen.fillRect(0, 0, CanvasWidth, CanvasHeight);
if(image != null)
offscreen.drawImage(image, i, l, 20);
break;
}
g.drawImage(offimage, 0, 0, 20);
return;
}
if(mode == 0)
{
g.setColor(0xffffff);
g.fillRect(0, 0, CanvasWidth, CanvasHeight);
g.setColor(0);
int j = CanvasWidth / 2;
int i1 = CanvasHeight / 2 - E3.getHeight();
g.drawString(E4, j, i1, 33);
i1 += E3.getHeight() + 2;
g.drawString(E5, j, i1, 33);
i1 += E3.getHeight() + 2;
g.drawString(E6, j, i1, 33);
return;
}
if(E7 != null)
{
E7 = null;
E8 = null;
E9 = null;
EA = null;
EB = null;
EC = null;
try
{
ED = Image.createImage("/back.png");
}
catch(Exception exception) { }
(new Game()).start();
}
offscreen.setClip(0, 0, CanvasWidth, CanvasHeight);
offscreen.setColor(0xffffff);
offscreen.fillRect(0, 0, CanvasWidth, CanvasHeight);
offscreen.drawImage(ED, OFFX, OFFY, 20);
if(lightflag == 0)
offscreen.setColor(0xffff00);
else
offscreen.setColor(0xff0000);
offscreen.fillRoundRect(OFFX + 88, OFFY + 18, 4, 4, 4, 4);
_fld0100.paint(offscreen);
FF.paint(offscreen);
if(F3 > 0)
F2.paint(offscreen, F3, OFFY + 46);
if(FC)
{
FC = false;
FB.paint(offscreen, FD, FE);
}
offscreen.setColor(32768);
int k = _fld0101 / 5;
offscreen.fillRect(4, OFFY + 4, 4, k);
k = _fld0102 / 5;
offscreen.fillRect(CanvasWidth - 8, OFFY + 4, 4, k);
g.drawImage(offimage, 0, 0, 20);
if(_fld0101 <= 0 || _fld0102 <= 0)
{
String s;
if(_fld0102 <= 0)
s = " You Win ";
else
s = " You Lose ";
int j1 = E3.stringWidth(s);
int k1 = (CanvasWidth - j1) / 2;
int l1 = (CanvasHeight - E3.getHeight()) / 2;
g.setColor(0x808080);
g.fillRect(k1, (OFFY + l1) - 2, j1, E3.getHeight() + 4);
g.setColor(0);
g.drawRect(k1, (OFFY + l1) - 2, j1, E3.getHeight() + 4);
g.drawString(s, CanvasWidth / 2, OFFY + l1 + E3.getHeight(), 33);
g.drawString(s, CanvasWidth / 2 + 1, OFFY + l1 + E3.getHeight(), 33);
still = true;
}
}
public void keyProc(int i)
{
Game.randomInt();
if(still)
return;
i = getGameAction(i);
if(i == 5)
FF.forward();
if(i == 2)
FF.backward();
if(i == 1)
FF.punch();
if(i == 6)
FF.kick();
if(i == 8)
FF.fire();
repaint();
}
public void keyPressed(int i)
{
keyProc(i);
}
public void keyRepeated(int i)
{
keyProc(i);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -