?? main.java
字號:
return true;
}
return false;
}
boolean getState(int index)
{
return ((Boolean)vState.elementAt(index)).booleanValue();
}
static Frame gf(String name)
{
try
{
str = gp(name);
if (str != null)
{
v = parse(str);
img_index = ((Integer)v.elementAt(0)).intValue();
str = gp("i" + img_index);
if (str != null)
{
if (img_names[img_index] == null)
{
img_names[img_index] = str + ".png";
}
w1 = w2 = ((Integer)v.elementAt(3)).intValue();
h1 = h2 = ((Integer)v.elementAt(4)).intValue();
if (v.size() > 5) w2 = ((Integer)v.elementAt(5)).intValue();
if (v.size() > 6) h2 = ((Integer)v.elementAt(6)).intValue();
frm = new Frame(img_index,((Integer)v.elementAt(1)).intValue(),((Integer)v.elementAt(2)).intValue(),w1,h1,w2,h2);
return frm;
}
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
return null;
}
void init()
{
initOK = false;
isBonus = false;
try
{
if (state == 100)
{
LOGO_TIME = 2000;
img_names[intro_index] = "in" + (s_w <= 96 ? 1 : 2) + ".png";
if (isLogo2) img_names[intro2_index] = "moj.png";
loadImages();
if (img[intro2_index] != null)
{
w1 = img[intro2_index].getWidth();
h1 = img[intro2_index].getHeight();
fLogo2 = new Frame(intro2_index,0,0,w1,h1,w1,h1);
}
if (img[intro_index] != null)
{
w1 = img[intro_index].getWidth();
h1 = img[intro_index].getHeight();
fLogo = new Frame(intro_index,0,0,w1,h1,w1,h1);
}
}
else
if (state == 99)
{
LOGO_TIME = 2000;
img_names[logo_index] = "logo.png";
loadImages();
if (img[logo_index] != null)
{
w1 = img[logo_index].getWidth();
h1 = img[logo_index].getHeight();
fLogo = new Frame(logo_index,0,0,w1,h1,w1,h1);
}
if (enqueue_abc()) loadImages();
}
else
if (state == 98)
{
LOGO_TIME = 5;
if (enqueue_abc()) loadImages();
}
else
if (state == 101)
{
LOGO_TIME = 50;
}
else
{
ld = true;
out("** " + c_lvl);
release();
rand = new Random(System.currentTimeMillis());
dumpTime = 100;
nextLevel = gp("n" + (c_lvl + 1));
hAnims = new Hashtable();
hi = new Hashtable();
man = null;
platform_count = 0;
// System.gc();
// loading animations
readAnimation("an_m");
readAnimation("an_fire");
readAnimation("an_fb");
System.gc();
for (i = 0; i < 10; i++) readAnimation("an_al" + i);
for (i = 0; i < 21; i++) readAnimation("an_bo" + i);
for (i = 0; i < 10; i++) readAnimation("an_st" + i);
for (i = 0; i < 10; i++) readAnimation("an_tr" + i);
System.gc();
obj2 = null;
try
{
c_st = c_dyn = 0;
for (i2 = 0; i2 < 2; i2++)
{
in = new DataInputStream(midlet.getClass().getResourceAsStream("/Res/l.map"));
for (k = 0; k < c_lvl; k++)
{
len = in.readShort();
in.skip(len);
}
len = in.readShort() - 4;
len -= 4;
a_w = in.readShort();
a_h = in.readShort();
if (a_w > 220) a_w = 220;
if (a_h > 220) a_h = 220;
if (i2 != 0)
{
aObj = new CObject[c_st];
dyn = new Dynamic[c_dyn];
c_st = c_dyn = 0;
}
for (k = 0; k < len;)
{
obj = null;
type = in.read();
subtype = in.read();
switch (type)
{
case C_P:
x1 = in.readShort();
y1 = in.readShort();
x2 = in.readShort();
y2 = in.readShort();
k += 10;
if (x1 != x2)
{
if (i2 == 0) c_st++;
else
{
platform_count++;
if (fB[subtype * 6] == null)
for (i = 0, j = subtype * 6; i < 6; i++, j++) fB[j] = gf("b" + j);
obj = new CObject(type,subtype,x1,y1,x2,y2);
obj.init();
aObj[c_st++] = obj;
}
}
break;
case C_S:
x1 = x2 = in.readShort();
y1 = in.readShort();
y2 = in.readShort();
k += 8;
if (i2 == 0) c_st++;
else
{
if (fS[subtype << 1] == null)
{
fS[subtype << 1] = gf("s" + subtype + ".0");
fS[subtype + subtype + 1] = gf("s" + subtype + ".1");
}
obj = new CObject(type,subtype,x1,y1,x2,y2);
obj.init();
aObj[c_st++] = obj;
}
break;
case C_M:
x1 = in.readShort();
y1 = in.readShort();
x2 = in.readShort();
y2 = in.readShort();
k += 10;
if (i2 == 0) c_st++;
else
{
if (fM[subtype] == null) fM[subtype] = gf("mv" + subtype);
obj = new CObject(type,subtype,x1,y1,x2,y2);
obj.init();
aObj[c_st++] = obj;
}
break;
case C_Sucker:
x1 = in.readShort();
y1 = in.readShort();
x2 = in.readShort();
y2 = in.readShort();
k += 10;
if (i2 == 0) c_st++;
else
{
if (fSu[subtype * 6] == null)
for (i = 0, j = subtype * 6; i < 6; i++, j++) fSu[j] = gf("su" + subtype + "." + j);
obj = new CObject(type,subtype,x1,y1,x2,y2);
obj.init();
aObj[c_st++] = obj;
}
break;
case C_Slope:
x1 = in.readShort();
y1 = in.readShort();
x2 = in.readShort();
y2 = in.readShort();
k += 10;
if (i2 == 0) c_st++;
else
{
if (fSl[subtype * 7] == null)
for (i = 0, j = subtype * 7; i < 7; i++, j++) fSl[j] = gf("sl" + subtype + "." + j);
obj = new CObject(type,subtype,x1,y1,x2,y2);
obj.init();
aObj[c_st++] = obj;
}
break;
case C_Press:
x1 = x2 = in.readShort();
y1 = in.readShort();
y2 = in.readShort();
k += 8;
if (i2 == 0) c_st++;
else
{
if (fPr[subtype << 1] == null)
{
fPr[subtype << 1] = gf("pr" + subtype + ".0");
fPr[subtype + subtype + 1] = gf("pr" + subtype + ".1");
}
obj = new CObject(type,subtype,x1,y1,x2,y2);
obj.fw = fPr[subtype << 1].w;
obj.fh = fPr[subtype << 1].h;
obj.init();
aObj[c_st++] = obj;
}
break;
case C_Lift:
x1 = x2 = in.readShort();
y1 = in.readShort();
y2 = in.readShort();
k += 8;
if (i2 == 0) c_st++;
else
{
if (fLi[subtype << 1] == null)
{
fLi[subtype << 1] = gf("li" + subtype + ".0");
fLi[subtype + subtype + 1] = gf("li" + subtype + ".1");
}
obj = new CObject(type,subtype,x1,y1,x2,y2);
obj.fw = fLi[subtype << 1].w;
obj.fh = fLi[subtype << 1].h;
obj.init();
aObj[c_st++] = obj;
}
break;
case C_Wall:
x1 = x2 = in.readShort();
y1 = in.readShort();
y2 = in.readShort();
k += 8;
if (i2 == 0) c_st++;
else
{
if (fW[subtype << 1] == null)
{
fW[subtype << 1] = gf("w" + subtype + ".0");
fW[subtype + subtype + 1] = gf("w" + subtype + ".1");
}
obj = new CObject(type,subtype,x1,y1,x2,y2);
obj.init();
aObj[c_st++] = obj;
}
break;
case C_Teleport:
if (i2 == 0) c_st++;
else
{
x1 = in.readShort();
y1 = in.readShort();
k += 6;
if (fTr[subtype + subtype] == null)
{
fTr[subtype + subtype] = gf("te" + subtype + ".0");
fTr[subtype + subtype + 1] = gf("te" + subtype + ".1");
}
obj = new CObject(type,subtype,x1,y1,x1,y1);
obj.init();
aObj[c_st++] = obj;
if (obj2 == null) obj2 = obj;
}
break;
case C_Trap:
x1 = in.readShort();
y1 = in.readShort();
k += 6;
if (i2 == 0) c_dyn++;
else
{
cur = new Dynamic(Dynamic.T_T,subtype,x1,y1,null,gf("tr" + subtype),"an_tr" + subtype);
cur.delay_range = Integer.parseInt(gp("trd" + subtype));
dyn[c_dyn++] = cur;
}
break;
case C_Alien:
x1 = in.readShort();
y1 = in.readShort();
k += 6;
if (i2 == 0) c_dyn++;
else
{
dyn[c_dyn++] = new Dynamic(Dynamic.T_A,subtype,x1,y1,null,gf("a" + subtype),"an_al" + subtype);
}
break;
case C_Bonus:
x1 = in.readShort();
y1 = in.readShort();
k += 6;
if (i2 == 0) c_dyn++;
else
{
dyn[c_dyn++] = new Dynamic(Dynamic.T_B,subtype,x1,y1,null,gf("bo" + subtype),"an_bo" + subtype);
if ((subtype == 2) && (dBonus == null))
{
dBonus = new Dynamic(Dynamic.T_B,0,0,0,null,gf("fb"),"an_fb");
}
}
break;
case C_Static:
x1 = in.readShort();
y1 = in.readShort();
k += 6;
if (i2 == 0) c_dyn++;
else
{
dyn[c_dyn++] = new Dynamic(Dynamic.T_D,subtype,x1,y1,null,gf("st" + subtype),"an_st" + subtype);
}
break;
case C_Man:
x1 = in.readShort();
y1 = in.readShort();
k += 6;
if (i2 != 0)
{
man = new Dynamic(Dynamic.T_M,0,x1,y1,null,gf("man"),"an_m");
}
break;
default:
break;
}
}
in = null;
System.gc();
}
}
catch(Exception ioex){ioex.printStackTrace();}
System.gc();
fire = new Dynamic(Dynamic.T_D,0,0,0,null,gf("fire"),"an_fire");
fire.visible = false;
hAnims.clear();
hAnims = null;
hi.clear();
hi = null;
System.gc();
panel_x = panel_dx = 0;
// from vector to array...
for (i = aObj.length - 1; i >= 0; i--)
{
obj = aObj[i];
if (obj.type == C_Teleport)
{
obj.nextObj = obj2; // remember next step object
obj2 = obj;
}
}
fHead = gf("head");
fPanel0 = gf("panel0");
fPanel1 = gf("panel1");
fPanel2 = gf("panel2");
panel_width = s_w;
panel_height = fPanel0.fh;
if (hp != null) hp.clear();
hp = null;
System.gc();
///////////////////////////////////////////////////////////////////////////////////
disp_x_range = a_w - s_w;
disp_y_range = a_h - s_h;
if (disp_x_range < 0) disp_x_range /= 2;
if (disp_y_range < 0) disp_y_range = 0;
x_bound = s_w / 2;
y_bound = s_h / 2;
locateMan();
levelTime = 300;
leaveTime = -1;
if (midlet.cheats) lifes = 3;
start_closed_blocks = 0;
damaged = 0;
enqueue_abc();
img_names[back_index] = "bg.png";
loadImages();
System.gc();
createBuffer();
}
p_num = -1;
start_closed_blocks = 0;
if (state == 0)
{
num = 0;
h1 = s_h - a_h;
if (h1 < 0) h1 = 0;
drawType(C_Wall);
drawType(C_Slope);
drawType(C_Sucker);
drawType(C_Teleport);
drawType(C_S);
drawType(C_P);
drawType(C_Sl2);
drawType(C_S2);
for (i = 0; i < fB.length; i += 6)
{
if (fB[i + 3] != null) img[fB[i + 3].index] = null;
if (fB[i + 4] != null) img[fB[i + 4].index] = null;
if (fB[i + 5] != null) img[fB[i + 5].index] = null;
fB[i + 3] = null;
fB[i + 4] = null;
fB[i + 5] = null;
}
for (i = 0; i < fW.length; i++)
{
if (fW[i] != null) img[fW[i].index] = null;
fW[i] = null;
}
for (i = 0; i < fSu.length; i++)
{
if (fSu[i] != null) img[fSu[i].index] = null;
fSu[i] = null;
}
vM.removeAllElements();
closed_blocks = start_closed_blocks;
startTime = System.currentTimeMillis();
}
System.gc();
initOK = running = true;
action = -15;
lifeDelay = 20;
tsum = tcnt = 0;
panel_y = panel_dy = 0;
memorySize = (int)(Runtime.getRuntime().freeMemory());
out("After: " + memorySize);
}
catch(Exception ex)
{
ex.printStackTrace();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -