📄 role.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: Role.java
package game;
import javax.microedition.lcdui.*;
// Referenced classes of package game:
// Bomb
public class Role extends Canvas
{
public static class Point
{
static final int LEFT_UP = 0;
static final int RIGHT_UP = 1;
static final int RIGHT_DOWN = 2;
static final int LEFT_DOWN = 3;
int x;
int y;
int row;
int col;
Point()
{
x = 0;
y = 0;
row = 0;
col = 0;
}
}
public Bomb bomb;
public static final int PLAYER = 0;
public static final int COMPUTTER = 1;
public static final int COMPUTTER_2 = 2;
public int RoleType;
public static int iKey = 0;
public static final int UP_WAY = 0;
public static final int RIGHT_WAY = 1;
public static final int DOWN_WAY = 2;
public static final int LEFT_WAY = 3;
public static boolean isDirectMove = false;
public int NOW_WAY;
public int OLD_WAY;
int nCurrentMsg;
public int WI_TOTAL_FRAME;
public int WI_TOTAL_MOVE_FRAME;
public int width;
public int height;
public int iTouchHeight;
public int iTouchWidth;
public int iTileHeight;
public int iTileWidth;
String sDeathImgPath;
Image imgDeath;
public static int nDeathRunTime = 0;
public static boolean bIsDead = false;
int nDeathImgHeight;
int nDeathImgWidth;
public byte btDeathCurrentIndex;
public byte btDeathCurrentFrame[] = {
-1
};
final byte btDeathTotalFrame;
byte btDeathTotalCol;
byte btDeathTotalRow;
static final byte arr_btDeathAnimationFrame[] = {
0, 1, 2, 3, 4
};
public int xStartPosit;
public int yStartPosit;
public int x;
public int y;
public int xEnd;
public int yEnd;
public int velocity;
public byte byAtScrRows;
public byte byAtScrCols;
public static final int MSG_NOTHING = -1;
public static final int MSG_UP_MOVE = 0;
public static final int MSG_LEFT_MOVE = 1;
public static final int MSG_DOWN_MOVE = 2;
public static final int MSG_RIGHT_MOVE = 3;
public static final int MSG_DEAD = 4;
public static final int MSG_END = 5;
protected Point touchPoint[] = {
new Point(), new Point(), new Point(), new Point()
};
protected Point imagePoint[] = {
new Point(), new Point(), new Point(), new Point()
};
public Image imgWalkRole;
public Image imgFight;
String sImgWalkPath;
public int WI_CURRENT_FRAME;
public int WI_CURRENT_SEQUENCE_FRAME;
public final int WI_nTOTALCOLS;
public final int WI_nTOTALROWS;
public int WI_nCurrentCols;
public int WI_nCurrentRows;
int UpMoveSequence[] = {
12, 13, 14, 15
};
int LeftMoveSequence[] = {
8, 9, 10, 11
};
int DownMoveSequence[] = {
0, 1, 2, 3
};
int RightMoveSequence[] = {
4, 5, 6, 7
};
int ixBackup;
int iyBackup;
int byOldWayBackup;
int byCurrentFrameBackup;
protected Point touchPointBackup[] = {
new Point(), new Point(), new Point(), new Point()
};
protected Point imagePointBackup[] = {
new Point(), new Point(), new Point(), new Point()
};
public void BackupData()
{
ixBackup = x;
iyBackup = y;
byOldWayBackup = NOW_WAY;
byCurrentFrameBackup = WI_CURRENT_FRAME;
equalToPoint(imagePointBackup, imagePoint);
equalToPoint(touchPointBackup, touchPoint);
}
public void RecoverData()
{
x = ixBackup;
y = iyBackup;
equalToPoint(touchPoint, touchPointBackup);
equalToPoint(imagePoint, imagePointBackup);
}
public Role()
{
RoleType = 1;
NOW_WAY = 2;
OLD_WAY = NOW_WAY;
nCurrentMsg = -1;
WI_TOTAL_FRAME = 12;
WI_TOTAL_MOVE_FRAME = 4;
width = 16;
height = 19;
iTouchHeight = 8;
iTouchWidth = 16;
iTileHeight = 16;
iTileWidth = 16;
nDeathImgHeight = 16;
nDeathImgWidth = 16;
btDeathCurrentIndex = 0;
btDeathTotalFrame = 5;
btDeathTotalCol = 1;
btDeathTotalRow = 7;
xStartPosit = 50;
yStartPosit = 60;
x = xStartPosit;
y = yStartPosit;
xEnd = x + width;
yEnd = y + height;
velocity = 4;
byAtScrRows = 0;
byAtScrCols = 0;
WI_CURRENT_FRAME = 0;
WI_CURRENT_SEQUENCE_FRAME = 0;
WI_nTOTALCOLS = 4;
WI_nTOTALROWS = 4;
WI_nCurrentCols = -1;
WI_nCurrentRows = -1;
}
public Role(String s, String s2)
{
RoleType = 1;
NOW_WAY = 2;
OLD_WAY = NOW_WAY;
nCurrentMsg = -1;
WI_TOTAL_FRAME = 12;
WI_TOTAL_MOVE_FRAME = 4;
width = 16;
height = 19;
iTouchHeight = 8;
iTouchWidth = 16;
iTileHeight = 16;
iTileWidth = 16;
nDeathImgHeight = 16;
nDeathImgWidth = 16;
btDeathCurrentIndex = 0;
btDeathTotalFrame = 5;
btDeathTotalCol = 1;
btDeathTotalRow = 7;
xStartPosit = 50;
yStartPosit = 60;
x = xStartPosit;
y = yStartPosit;
xEnd = x + width;
yEnd = y + height;
velocity = 4;
byAtScrRows = 0;
byAtScrCols = 0;
WI_CURRENT_FRAME = 0;
WI_CURRENT_SEQUENCE_FRAME = 0;
WI_nTOTALCOLS = 4;
WI_nTOTALROWS = 4;
WI_nCurrentCols = -1;
WI_nCurrentRows = -1;
sImgWalkPath = s;
sDeathImgPath = s2;
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void UpMove()
{
BackupData();
NOW_WAY = 0;
if(NOW_WAY != OLD_WAY || ++WI_CURRENT_SEQUENCE_FRAME >= WI_TOTAL_MOVE_FRAME)
WI_CURRENT_SEQUENCE_FRAME = 0;
WI_CURRENT_FRAME = UpMoveSequence[WI_CURRENT_SEQUENCE_FRAME];
if(OLD_WAY == NOW_WAY || isDirectMove)
{
y = y - velocity;
UpdataAll();
}
OLD_WAY = NOW_WAY;
}
public void LeftMove()
{
BackupData();
NOW_WAY = 3;
if(NOW_WAY != OLD_WAY || ++WI_CURRENT_SEQUENCE_FRAME >= WI_TOTAL_MOVE_FRAME)
WI_CURRENT_SEQUENCE_FRAME = 0;
WI_CURRENT_FRAME = LeftMoveSequence[WI_CURRENT_SEQUENCE_FRAME];
if(OLD_WAY == NOW_WAY || isDirectMove)
{
x = x - velocity;
UpdataAll();
}
OLD_WAY = NOW_WAY;
}
public void DownMove()
{
BackupData();
NOW_WAY = 2;
if(NOW_WAY != OLD_WAY || ++WI_CURRENT_SEQUENCE_FRAME >= WI_TOTAL_MOVE_FRAME)
WI_CURRENT_SEQUENCE_FRAME = 0;
WI_CURRENT_FRAME = DownMoveSequence[WI_CURRENT_SEQUENCE_FRAME];
if(OLD_WAY == NOW_WAY || isDirectMove)
{
y = y + velocity;
UpdataAll();
}
OLD_WAY = NOW_WAY;
}
public void RightMove()
{
BackupData();
NOW_WAY = 1;
if(NOW_WAY != OLD_WAY || ++WI_CURRENT_SEQUENCE_FRAME >= WI_TOTAL_MOVE_FRAME)
WI_CURRENT_SEQUENCE_FRAME = 0;
WI_CURRENT_FRAME = RightMoveSequence[WI_CURRENT_SEQUENCE_FRAME];
if(OLD_WAY == NOW_WAY || isDirectMove)
{
x = x + velocity;
UpdataAll();
}
OLD_WAY = NOW_WAY;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
private void jbInit()
throws Exception
{
imgWalkRole = Image.createImage(sImgWalkPath);
imgDeath = Image.createImage(sDeathImgPath);
}
public void paint(Graphics g)
{
g.setColor(0, 0, 0);
getClass();
WI_nCurrentCols = WI_CURRENT_FRAME % 4;
getClass();
WI_nCurrentRows = WI_CURRENT_FRAME / 4;
g.setClip(x, y - height, width, height);
g.drawImage(imgWalkRole, x - WI_nCurrentCols * width, y - WI_nCurrentRows * height - height, 0);
g.setClip(0, 0, getWidth(), getHeight());
}
public int getTouchCurrentRow()
{
int row1 = touchPoint[0].y / iTileHeight;
int row2 = touchPoint[3].y / iTileHeight;
if(row1 == row2)
return row1;
else
return -row1;
}
public int getTouchCurrentCol()
{
int col1 = touchPoint[0].x / iTileWidth;
int col2 = touchPoint[1].x / iTileWidth;
if(col1 == col2)
return col1;
else
return -col1;
}
public void getTouchCurrentRow2()
{
touchPoint[0].row = touchPoint[0].y / iTileHeight;
touchPoint[1].row = touchPoint[0].row;
touchPoint[3].row = touchPoint[3].y / iTileHeight;
touchPoint[2].row = touchPoint[3].row;
}
public void getTouchCurrentCol2()
{
touchPoint[0].col = touchPoint[0].x / iTileWidth;
touchPoint[3].col = touchPoint[0].col;
touchPoint[1].col = touchPoint[1].x / iTileWidth;
touchPoint[2].col = touchPoint[1].col;
}
public int getImageCurrentCol()
{
int col1 = x / iTileWidth + 2;
int col2 = (x + width) / iTileWidth + 2;
if(col1 == col2)
return col1;
else
return -col1;
}
public int getImageCurrentRow()
{
int row1 = y / iTileHeight + 2;
int row2 = (y - height) / iTileHeight + 2;
if(row1 == row2)
return row2;
else
return -row2;
}
public void UpdateImagePoint()
{
imagePoint[0].x = x;
imagePoint[0].y = y - height;
imagePoint[1].x = x + width;
imagePoint[1].y = y - height;
imagePoint[2].x = x + width;
imagePoint[2].y = y;
imagePoint[3].x = x;
imagePoint[3].y = y;
imagePoint[0].col = imagePoint[0].x / iTileWidth + 1;
imagePoint[1].col = imagePoint[1].x / iTileWidth + 1;
imagePoint[3].col = imagePoint[0].col;
imagePoint[2].col = imagePoint[1].col;
imagePoint[0].row = imagePoint[0].y / iTileHeight + 1;
imagePoint[3].row = imagePoint[3].y / iTileHeight + 1;
if(imagePoint[0].row < 0)
imagePoint[0].row = 0;
imagePoint[1].row = imagePoint[0].row;
imagePoint[2].row = imagePoint[3].row;
}
public void UpdateTouchPoint()
{
int w = 4;
int h = 2;
touchPoint[0].x = x + w;
touchPoint[0].y = (y - iTouchHeight) + 2 * h;
touchPoint[1].x = (x + iTouchWidth) - 2 * w;
touchPoint[1].y = (y - iTouchHeight) + 2 * h;
touchPoint[2].x = (x + iTouchWidth) - 2 * w;
touchPoint[2].y = y - h;
touchPoint[3].x = x + w;
touchPoint[3].y = y - h;
touchPoint[0].col = touchPoint[0].x / iTileWidth + 1;
touchPoint[1].col = touchPoint[1].x / iTileWidth + 1;
if(touchPoint[0].x < 0)
{
touchPoint[0].col = 0;
touchPoint[1].col = 0;
}
touchPoint[3].col = touchPoint[0].col;
touchPoint[2].col = touchPoint[1].col;
touchPoint[0].row = touchPoint[0].y / iTileHeight + 1;
touchPoint[3].row = touchPoint[3].y / iTileHeight + 1;
if(touchPoint[0].y < 0)
{
touchPoint[3].row = 0;
touchPoint[0].row = 0;
}
touchPoint[1].row = touchPoint[0].row;
touchPoint[2].row = touchPoint[3].row;
}
public void UpdataAll()
{
UpdateImagePoint();
UpdateTouchPoint();
}
public void equalToPoint(Point p1[], Point p2[])
{
int i = 1;
for(i = 0; i < 4; i++)
{
p1[i].x = p2[i].x;
p1[i].y = p2[i].y;
p1[i].row = p2[i].row;
p1[i].col = p2[i].col;
}
}
public byte nextFrame(byte btTotFrame, byte btCurFrame[], byte arr_btBombAnimation[])
{
if(++btCurFrame[0] >= btTotFrame)
btCurFrame[0] = 0;
byte btCurIndex = arr_btBombAnimation[btCurFrame[0]];
return btCurIndex;
}
public void paintImage(Graphics g, int x, int y, Image img, int row, int col, int index)
{
int h = 0;
try
{
h = img.getHeight() / row;
}
catch(Exception e)
{
e.printStackTrace();
}
int w = img.getWidth() / col;
int c = index % col;
int r = index / col;
g.setClip(x, y - h, w, h);
g.drawImage(img, x - c * w, y - r * h - h, 0);
g.setClip(0, 0, getWidth(), getHeight());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -