📄 mscreen.java~5~
字号:
if ( (bg3 >= 0) && (bg3 < platres.length)) {
background3_face_index = bg3;
background3_face_y = bg3_top;
background3_face_w = platres[bg3].getWidth();
background3_position_x = 0;
background3_speed = bg3_spd;
}
else background3_face_index = -1;
}
/**********************************************
* 画背景
**********************************************/
private final void back_draw() {
int x, y;
g.setClip(0, 0, screen_w, screen_h);
if (background1_face_index >= 0) {
y = -position_y % background1_face_h;
while (y < screen_h) {
x = -position_x % background1_face_w;
while (x < screen_w) {
g.drawImage(platres[background1_face_index], x, y, 0);
x += background1_face_w;
}
y += background1_face_h;
}
}
else {
if (background3_face_index >= 0) {
x = -background3_position_x % background3_face_w;
while (x < screen_w) {
g.drawImage(platres[background3_face_index], x, background3_face_y, 0);
x += background3_face_w;
}
}
if (background2_face_index >= 0) {
x = -background2_position_x % background2_face_w;
while (x < screen_w) {
g.drawImage(platres[background2_face_index], x, background2_face_y, 0);
x += background2_face_w;
}
}
}
}
/**********************************************
* 运行背景
**********************************************/
private final void back_run(){
if (background3_face_index >= 0) {
if (background3_speed != 0)
background3_position_x += background3_speed;
else
background3_position_x = position_x >> 3;
}
if (background2_face_index >= 0) {
if (background2_speed != 0)
background2_position_x += background2_speed;
else
background2_position_x = position_x >> 2;
}
}
//****************************************************************************
/** @todo: 道具 */
//****************************************************************************
private Vector props = new Vector();
private final int PROP_POS_W = 18;
private final int PROP_POS_H = 16;
private final int PROP_COUNT = 4;
private final int PROP_POS_X = 0;
private final int PROP_POS_Y = 1;
private final int PROP_INDEX = 2;
private final int PROP_TOTAL = 3;
private final void prop_create(int pos_x, int pos_y, int prop_index, int prop_total){
int[] prop = new int[PROP_COUNT];
prop[PROP_POS_X] = pos_x;
prop[PROP_POS_Y] = pos_y;
prop[PROP_INDEX] = prop_index;
prop[PROP_TOTAL] = prop_total;
props.addElement(prop);
}
private final void prop_run() {
for (int i = props.size() - 1; i >= 0; i--) {
int[] prop = (int[]) props.elementAt(i);
int v = grid_cellvalue(prop[PROP_POS_X] >> 3, prop[PROP_POS_Y] >> 3);
if ( (v == 1) || (v == 2))
prop[PROP_POS_Y] = (prop[PROP_POS_Y] >> 3) << 3;
else
prop[PROP_POS_Y] += 4;
}
}
private final void prop_draw() {
for (int i = props.size() - 1; i >= 0; i--) {
int[] prop = (int[]) props.elementAt(i);
clipRect(prop[PROP_POS_X] - (PROP_POS_W >> 1),
prop[PROP_POS_Y] - PROP_POS_H,
PROP_POS_W, prop[PROP_POS_Y]);
drawFace(faceres[FACE_PROP_ICON],
prop[PROP_POS_X] - prop[PROP_INDEX] * PROP_POS_W - (PROP_POS_W >> 1),
prop[PROP_POS_Y] - PROP_POS_H, 0);
}
}
//****************************************************************************
/** @todo:俘虏 */
//****************************************************************************
private final int PAWN_FACEW = 25;
private final int PAWN_FACEH = 28;
private final int PAWN_HALFW = 12;
private final int PAWN_HALFH = 14;
private Vector pawns = new Vector();
private final int PAWN_COUNT = 10;
private final int PAWN_RESID = 0;
private final int PAWN_POS_X = 1;
private final int PAWN_POS_Y = 2;
private final int PAWN_INDEX = 3; //携带的道具的索引
private final int PAWN_TOTAL = 4; //道具数目 对于加分道具这个是分数 对于弹药这个是弹药数量
private final int PAWN_STATE = 5; //俘虏当前的状态
private final int PAWN_DIREC = 6;
private final int PAWN_FRAME = 7;
private final int PAWN_FLASH = 8;
private final int PAWN_TALLY = 9;
private final int PAWN_STATE_HOLD = 0; //绑缚状态
private final int PAWN_STATE_STAN = 1; //站立状态
private final int PAWN_STATE_FADE = 2; //消失状态
private final void pawn_rescue(int[] pawn){
if(pawn[PAWN_STATE] == 0){
pawn[PAWN_STATE] = 1;
pawn[PAWN_FRAME] = 1;
}
}
private final void pawn_load(InputStream in) throws IOException{
for (int i = in.read() - 1; i >= 0; i--){
int[] pawn = new int[PAWN_COUNT];
pawn[PAWN_RESID] = in.read();
pawn[PAWN_POS_X] = readByte(in) * 8;
pawn[PAWN_POS_Y] = readByte(in) * 8;
pawn[PAWN_INDEX] = in.read();
pawn[PAWN_TOTAL] = in.read();
pawn[PAWN_STATE] = 0;
pawn[PAWN_DIREC] = -1;
pawn[PAWN_FRAME] = 0;
pawn[PAWN_FLASH] = 0;
pawn[PAWN_TALLY] = 0;
pawns.addElement(pawn);
}
}
private final void pawn_run(){
int v;
for(int i = pawns.size() - 1; i >= 0; i--){
int[] pawn = (int[])pawns.elementAt(i);
switch(pawn[PAWN_STATE]){
case PAWN_STATE_HOLD:
v = grid_cellvalue(pawn[PAWN_POS_X] >> 3, (pawn[PAWN_POS_Y] + PAWN_HALFH) >> 3);
if((v != 1) && (v != 2)) pawn[PAWN_POS_Y] += 4;
pawn[PAWN_DIREC] = (pawn[PAWN_POS_X] > hero_pos_x) ? -1: 1;
break;
case PAWN_STATE_STAN:
if(pawn[PAWN_FRAME] < 2){
if (pawn[PAWN_TALLY]++ > 2){
pawn[PAWN_FRAME]++;
pawn[PAWN_TALLY] = 0;
prop_create(pawn[PAWN_POS_X] , pawn[PAWN_POS_Y], pawn[PAWN_INDEX], pawn[PAWN_TOTAL]);
}
}else
pawn[PAWN_STATE] ++;
break;
case PAWN_STATE_FADE:
if(pawn[PAWN_FLASH] ++ > 20){
pawns.removeElementAt(i);
}
break;
}
}
}
private final void pawn_draw(){
for(int i = pawns.size() - 1; i >= 0; i--){
int[] pawn = (int[])pawns.elementAt(i);
if((pawn[PAWN_STATE] == PAWN_STATE_FADE) && ((pawn[PAWN_FLASH] & 2) == 2)) continue;
clipRect(pawn[PAWN_POS_X] - PAWN_HALFW, pawn[PAWN_POS_Y] - PAWN_HALFH, PAWN_FACEW, PAWN_FACEH);
switch(pawn[PAWN_DIREC]){
case -1:drawFace(platres[pawn[PAWN_RESID]],
pawn[PAWN_POS_X] - PAWN_HALFW - pawn[PAWN_FRAME] * PAWN_FACEW,
pawn[PAWN_POS_Y] - PAWN_HALFH, 0); break;
case 1:drawFace(platres[pawn[PAWN_RESID]],
pawn[PAWN_POS_X] + PAWN_HALFW + pawn[PAWN_FRAME] * PAWN_FACEW - 3 * PAWN_FACEW,
pawn[PAWN_POS_Y] - PAWN_HALFH, 0x2000); break;
}
}
}
//****************************************************************************
/** @todo:箱子 */
//****************************************************************************
private Vector chest = new Vector();
private final int CHEST_COUNT = 9;
private final int CHEST_RESID = 0;
private final int CHEST_POS_X = 1;
private final int CHEST_POS_Y = 2;
private final int CHEST_POS_W = 3;
private final int CHEST_POS_H = 4;
private final int CHEST_BLAST = 5; //爆炸效果
private final int CHEST_PROPS = 6; //道具的类型
private final int CHEST_TOTAL = 7; //道具加的分 或者 子弹个数
private final int CHEST_ANIMA = 8; //箱子的类型
private final boolean chet_include(int[] chet, int x, int y){
return
(x >= chet[CHEST_POS_X]) &&
(y >= chet[CHEST_POS_Y]) &&
(x <= chet[CHEST_POS_X] + chet[CHEST_POS_W]) &&
(y <= chet[CHEST_POS_Y] + chet[CHEST_POS_H]);
}
private final void chet_load(InputStream in) throws IOException {
int size_chet = in.read();
for(int i = 0; i < size_chet; i++){
int[] chet = new int[CHEST_COUNT];
chet[CHEST_RESID] = in.read();
chet[CHEST_POS_X] = readByte(in) * 8;
chet[CHEST_POS_Y] = readByte(in) * 8;
chet[CHEST_ANIMA] = in.read();
chet[CHEST_PROPS] = readByte(in);
chet[CHEST_TOTAL] = in.read();
chet[CHEST_BLAST] = readByte(in);
chet[CHEST_POS_W] = platres[chet[CHEST_RESID]].getWidth();
chet[CHEST_POS_H] = platres[chet[CHEST_RESID]].getHeight();
chest.addElement(chet);
}
}
private final void chet_run(){
boolean touch = false;
for(int i = chest.size() - 1; i >= 0; i--){
touch = false;
int[] chet = (int[])chest.elementAt(i);
int chet_l = chet[CHEST_POS_X] + 3;
int chet_r = chet[CHEST_POS_X] + chet[CHEST_POS_W] - 3;
int chet_y = chet[CHEST_POS_Y] + chet[CHEST_POS_H] + 4;
int v1 = grid_cellvalue(chet_l >> 3, chet_y >> 3);
int v2 = grid_cellvalue(chet_r >> 3, chet_y >> 3);
if((v1 == 1) || (v2 == 1) || (v1 == 2) || (v2 == 2)){
chet[CHEST_POS_Y] = ((chet_y >> 3) << 3) - chet[CHEST_POS_H];
continue;
}
for(int j = chest.size() - 1; j >= 0; j --){
if(i == j) continue;
int[] chet_v = (int[])chest.elementAt(j);
if(chet_include(chet_v, chet_l, chet_y) ||
chet_include(chet_v, chet_r, chet_y) ||
chet_include(chet_v, (chet_l + chet_r) >> 1, chet_y)){
chet[CHEST_POS_Y] = chet_v[CHEST_POS_Y] - chet[CHEST_POS_H];
touch = true;
}
}
if(!touch)
chet[CHEST_POS_Y] += 4;
}
}
private final void chet_hitted(int[] chet, int attack){
chet[CHEST_ANIMA] -= attack;
int center_x = ((chet[CHEST_POS_X] << 1) + chet[CHEST_POS_W])>>1;
int center_y = ((chet[CHEST_POS_Y] << 1) + chet[CHEST_POS_H])>>1;
if(chet[CHEST_ANIMA] > 0) return;
if(chet[CHEST_BLAST] >= 0)
movi_create(chet[CHEST_BLAST], center_x, center_y, 0, 0, 0, 0, -1, MOVI_DEATH_ONCE);
if(chet[CHEST_PROPS] >= 0)
prop_create(center_x, center_y, chet[CHEST_PROPS], chet[CHEST_TOTAL]);
chest.removeElement(chet);
}
private final void chet_draw(){
g.setClip(0, 0, screen_w, screen_h);
for(int i = chest.size() - 1; i >= 0; i--){
int[] chet = (int[])chest.elementAt(i);
int x = chet[CHEST_POS_X];
int y = chet[CHEST_POS_Y];
if(visible(x, y, x + chet[CHEST_POS_W], y + chet[CHEST_POS_H]))
drawFace(platres[chet[CHEST_RESID]], chet[CHEST_POS_X], chet[CHEST_POS_Y], 0);
}
}
//****************************************************************************
/** @todo:动画 */
//****************************************************************************
private Vector movis = new Vector(); //动画元件数据
private int[][] movis_defin;
private Image[] movis_image;
private final int MOVI_DEFIN_COUNT = 5;
private final int MOVI_DEFIN_FRAME = 0;
private final int MOVI_DEFIN_LINKX = 1;
private final int MOVI_DEFIN_LINKY = 2;
private final int MOVI_DEFIN_FRAMW = 3;
private final int MOVI_DEFIN_FRAMH = 4;
private final int MOVI_COUNT = 18;
private final int MOVI_DEFID = 0;//图形索引
private final int MOVI_POS_X = 1;//动画位置X
private final int MOVI_POS_Y = 2;//动画位置Y
private final int MOVI_FRAML = 3;//连接点到帧左边的距离
private final int MOVI_FRAMT = 4;//连接点到帧上边的距离
private final int MOVI_FRAMR = 5;//连接点到帧右边的距离
private final int MOVI_FRAMB = 6;//连接点到帧下边的距离
private final int MOVI_FACEW = 7;
private final int MOVI_FRAMH = 8;
private final int MOVI_FRAMW = 9;
private final int MOVI_FRAME = 10; //动画帧数
private final int MOVI_INDEX = 11;//当前帧索引
private final int MOVI_SPD_X = 12;
private final int MOVI_SPD_Y = 13;
private final int MOVI_ACCEX = 14;
private final int MOVI_ACCEY = 15;
private final int MOVI_DIREC = 16;
private final int MOVI_DEATH = 17;
private final int MOVI_DEATH_ONCE = 0;
private final int MOVI_DEATH_EVER = 1;
private final int MOVI_DEATH_SIDE = 2;
private final void movi_loaddefine(){
InputStream in = stream_create("/movi.bin");
try{
movis_defin = new int[in.read()][MOVI_DEFIN_COUNT];
movis_image = new Image[movis_defin.length];
for (int i = 0; i < movis_defin.length; i++) {
movis_image[i] = platres[in.read()];
movis_defin[i][MOVI_DEFIN_FRAME] = in.read();
movis_defin[i][MOVI_DEFIN_LINKX] = in.read();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -