📄 numencanva.java
字号:
//主角状态常数 分两部分 字节低位大状态 高位字节小状态
private final int STATUS_MAIN = 0xF000;
private final int STATUS_MAIN_STAND = 0x0000;
private final int STATUS_MAIN_SQUAT = 0x1000;
private final int STATUS_MAIN_INAIR = 0x2000;
private final int STATUS_FIRE = 0xF00;
private final int STATUS_FIRE_NORMAL = 0x000;
private final int STATUS_FIRE_ATTACK = 0x100;
private final int STATUS_FIRE_SWORDS = 0x200;
private final int STATUS_FIRE_THROWS = 0x300;
private final int STATUS_FIRE_DEATHS = 0x400;
private final int STATUS_MOVE = 0xF0;
private final int STATUS_MOVE_REST = 0x00;
private final int STATUS_MOVE_MOVE = 0x10;
private final int STATUS_MOVE_RISE = 0x20;
private final int STATUS_MOVE_LEAP = 0x30;
private final int STATUS_MOVE_FALL = 0x40;
private final int STATUS_PORT = 0xF;
private final int STATUS_PORT_BASE = 0x0;
private final int STATUS_PORT_OVER = 0x1;
private final int STATUS_PORT_DOWN = 0x2;
//主角动作数据 第一维是表示动作索引 第二维表示帧索引 第三维帧定义
private int[][][] heroaction;
private final int HERO_ACTION_STANREST = 0;
private final int HERO_ACTION_STANMOVE = 1;
private final int HERO_ACTION_STANFALCHION = 2;
private final int HERO_ACTION_STANTOSSBOMB = 3;
private final int HERO_ACTION_STANFIREBASE = 4;
// private final int HERO_ACTION_STANFIREOVER = 5;
// private final int HERO_ACTION_STANPORTOVER = 6;
// private final int HERO_ACTION_MOVEFALCHION = 7;
// private final int HERO_ACTION_MOVETOSSBOMB = 8;
// private final int HERO_ACTION_MOVEFIREBASE = 9;
// private final int HERO_ACTION_MOVEFIREOVER = 10;
// private final int HERO_ACTION_MOVEPORTOVER = 11;
private final int HERO_ACTION_SQUAREST = 5;
private final int HERO_ACTION_SQUAMOVE = 6;
private final int HERO_ACTION_SQUAFALCHION = 7;
// private final int HERO_ACTION_SQUATOSSBOMB = 15;
// private final int HERO_ACTION_SQUAFIRE = 8;
private final int HERO_ACTION_JUMPRISE = 8;
private final int HERO_ACTION_RISEFALCHION = 9;
// private final int HERO_ACTION_RISETOSSBOMB = 19;
// private final int HERO_ACTION_RISEFIREBASE = 20;
// private final int HERO_ACTION_RISEFIREOVER = 21;
// private final int HERO_ACTION_RISEFIREDOWN = 22;
// private final int HERO_ACTION_RISEPORTOVER = 23;
// private final int HERO_ACTION_RISEPORTDOWN = 24;
private final int HERO_ACTION_JUMPLEAP = 10;
private final int HERO_ACTION_LEAPFALCHION = 9;
// private final int HERO_ACTION_LEAPTOSSBOMB = HERO_ACTION_RISETOSSBOMB;
// private final int HERO_ACTION_LEAPFIREBASE = HERO_ACTION_RISEFIREBASE;
// private final int HERO_ACTION_LEAPFIREOVER = HERO_ACTION_RISEFIREOVER;
// private final int HERO_ACTION_LEAPFIREDOWN = HERO_ACTION_RISEFIREDOWN;
// private final int HERO_ACTION_LEAPPORTOVER = HERO_ACTION_RISEPORTOVER;
// private final int HERO_ACTION_LEAPPORTDOWN = HERO_ACTION_RISEPORTDOWN;
private final int HERO_ACTION_JUMPFALL = 11;
private final int HERO_ACTION_FALLFALCHION = 9;
// private final int HERO_ACTION_FALLTOSSBOMB = HERO_ACTION_RISETOSSBOMB;
// private final int HERO_ACTION_FALLFIREBASE = HERO_ACTION_RISEFIREBASE;
// private final int HERO_ACTION_FALLFIREOVER = HERO_ACTION_RISEFIREOVER;
// private final int HERO_ACTION_FALLFIREDOWN = HERO_ACTION_RISEFIREDOWN;
// private final int HERO_ACTION_FALLPORTOVER = HERO_ACTION_RISEPORTOVER;
// private final int HERO_ACTION_FALLPORTDOWN = HERO_ACTION_RISEPORTDOWN;
private final int HERO_ACTION_SHOTDEAD = 12;
// private final int HERO_ACTION_BOMBDEAD = 42;
// private final int HERO_ACTION_VICTORY = 43;
// private final int HERO_ACTION_SCARPSIDE = 44;
//主角每一帧包括34个数据 前面6个是 帧的作用区和攻击区
//后面的数据每7个一组 每一组表示一个图块数据
private final int HERO_FRAME_COUNT = 27;
private final int HERO_FRAME_RECTW = 0;
private final int HERO_FRAME_RECTT = 1;
private final int HERO_FRAME_FIREX = 2;
private final int HERO_FRAME_FIREY = 3;
// private final int HERO_FRAME_FIREW = 4;
// private final int HERO_FRAME_FIREH = 5;
private final int HERO_FRAME_PARTSTART = 6;
private final int HERO_FRAME_PARTCOUNT = 7;
private final int HERO_FRAME_FRAML = 0;
private final int HERO_FRAME_FRAMT = 1;
private final int HERO_FRAME_FRAMR = 2;
private final int HERO_FRAME_FRAMB = 3;
private final int HERO_FRAME_FACEL = 4;
private final int HERO_FRAME_FACET = 5;
private final int HERO_FRAME_FACER = 6;
/**********************************************
* 装载主角数据
**********************************************/
private final void hero_loaddefine() {
InputStream in = stream_create("/" + (id + 1) + ".bin");
try {
byte[] gifdata = new byte[readWord(in)];
in.read(gifdata, 6, gifdata.length - 6);
System.arraycopy("GIF89a".getBytes(), 0, gifdata, 0, 6);
hero_face = Image.createImage(gifdata, 0, gifdata.length);
heroaction = new int[in.read()][][];
for (int i = 0; i < heroaction.length; i++) {
int framecount = in.read();
heroaction[i] = new int[framecount][HERO_FRAME_COUNT];
for (int j = 0; j < framecount; j++) {
for (int k = 0; k < 6; k++) {
heroaction[i][j][k] = (byte) in.read();
}
for (int k = 0; k < 3; k++) {
for (int l = 0; l < 7; l++) {
heroaction[i][j][6 + k * 7 + l] =
(l < 4) ? (byte) in.read() : in.read();
}
}
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
/**********************************************
* 设置主角当前状态
* @param status_id int 主角状态索引
**********************************************/
private final void hero_setmainstatus(int status_id) {
hero_status = (hero_status & ~STATUS_MAIN) | status_id;
}
private final void hero_setfirestatus(int status_id) {
hero_status = (hero_status & ~STATUS_FIRE) | status_id;
}
private final void hero_setmovestatus(int status_id) {
hero_status = (hero_status & ~STATUS_MOVE) | status_id;
}
private final void hero_setportstatus(int status_id) {
hero_status = (hero_status & ~STATUS_PORT) | status_id;
}
/**********************************************
* 设置主角当前的动作
* @param action_id int 主角动作的索引
**********************************************/
private final void hero_setaction(int action_id) {
if (hero_action == action_id) {
return;
}
hero_action = action_id;
hero_setcframe(0);
}
/**********************************************
* 设置主角当前帧
* @param cframe_id int 主角当前帧设置
**********************************************/
private final void hero_setcframe(int cframe_id) {
hero_cframe = cframe_id;
hero_frectw = heroaction[hero_action][hero_cframe][HERO_FRAME_RECTW];
hero_frectt = heroaction[hero_action][hero_cframe][HERO_FRAME_RECTT];
}
private final void hero_action_play() {
if ( ( (hero_status & STATUS_FIRE) == STATUS_FIRE_SWORDS) ||
( (hero_status & STATUS_FIRE) == STATUS_FIRE_THROWS)) {
if (hero_cframe < heroaction[hero_action].length - 1) {
hero_cframe++;
}
}
else {
hero_cframe = (hero_cframe < heroaction[hero_action].length - 1) ?
hero_cframe + 1 : 0;
}
}
private final boolean hero_action_finish() {
return hero_cframe == heroaction[hero_action].length - 1;
}
/**********************************************
* 移动主角位置 这个位置使用的是主角的直接坐标 不是网格坐标
* @param x int 主角在地图上的绝对位置X
* @param y int 主角在地图上的绝对位置Y
**********************************************/
private final void hero_move(int x, int y) {
hero_pos_x = x;
hero_pos_y = y;
adScreen();
}
/**********************************************
* 画出主角的动作的
**********************************************/
private final void hero_draw() {
int[] fram = heroaction[hero_action][hero_cframe];
if (hero_cflash > 0) {
hero_cflash--;
}
if ( (hero_cflash & 1) == 1) {
return;
}
int part_l, part_t, part_w, part_h, show_x, show_y;
int rotate = (hero_direct == -1) ? 0 : 0x2000;
// if(hero_action==HERO_ACTION_STANTOSSBOMB)
// {
// if(rotate==0)
// {
// rotate=0x2000;
//
// }
// else
// {
// rotate=0;
// }
// }
for (int i = 0; i < 3; i++) { //画3层
part_l = hero_pos_x - ( (hero_direct == -1) ?
fram[HERO_FRAME_PARTSTART +
i * HERO_FRAME_PARTCOUNT + HERO_FRAME_FRAML] :
fram[HERO_FRAME_PARTSTART +
i * HERO_FRAME_PARTCOUNT + HERO_FRAME_FRAMR]);
part_t = hero_pos_y - fram[HERO_FRAME_PARTSTART +
i * HERO_FRAME_PARTCOUNT + HERO_FRAME_FRAMT];
part_w = fram[HERO_FRAME_PARTSTART + i * HERO_FRAME_PARTCOUNT +
HERO_FRAME_FRAML] +
fram[HERO_FRAME_PARTSTART + i * HERO_FRAME_PARTCOUNT +
HERO_FRAME_FRAMR];
part_h = fram[HERO_FRAME_PARTSTART + i * HERO_FRAME_PARTCOUNT +
HERO_FRAME_FRAMT] +
fram[HERO_FRAME_PARTSTART + i * HERO_FRAME_PARTCOUNT +
HERO_FRAME_FRAMB];
show_x = hero_pos_x - ( (hero_direct == -1) ? fram[HERO_FRAME_PARTSTART +
i * HERO_FRAME_PARTCOUNT + HERO_FRAME_FACEL] :
fram[HERO_FRAME_PARTSTART +
i * HERO_FRAME_PARTCOUNT + HERO_FRAME_FACER]);
show_y = hero_pos_y - fram[HERO_FRAME_PARTSTART +
i * HERO_FRAME_PARTCOUNT + HERO_FRAME_FACET];
clipRect(part_l, part_t, part_w, part_h);
drawFace(hero_face, show_x, show_y, rotate);
}
}
/**********************************************
* 主角接近了怪物 用于主角是否7用刀来攻击
* @return boolean 当有怪物达到主角出到距离返回True
**********************************************/
private final boolean hero_near() { // w17, h11
int sword_l = hero_pos_x - ( (hero_direct == -1) ? 25 : 0);
int sword_r = hero_pos_x + ( (hero_direct == -1) ? 0 : 25);
int sword_t = hero_pos_y - 11;
int sword_b = hero_pos_y + 11;
boolean rt = false;
for (int i = ogres.size() - 1; i >= 0; i--) {
int[] ogre = (int[]) ogres.elementAt(i);
int[] defin = ogre_getdefin(ogre);
if ( (ogre[OGRE_DEATH] > 0) || (defin[OGRE_DEFIN_STYLE] == 1)) {
continue;
}
int[] frame = ogre_getframe(ogre);
if ( (ogre[OGRE_POS_X] - frame[OGRE_FRAME_RECTW] < sword_r) &&
(ogre[OGRE_POS_X] + frame[OGRE_FRAME_RECTW] > sword_l) &&
(ogre[OGRE_POS_Y] - frame[OGRE_FRAME_RECTT] < sword_b) &&
(ogre[OGRE_POS_Y] + 11 > sword_t)) {
rt = true;
break;
}
}
for (int i = pawns.size() - 1; i >= 0; i--) {
int[] pawn = (int[]) pawns.elementAt(i);
if ( (pawn[PAWN_POS_X] - PAWN_HALFW < sword_r) &&
(pawn[PAWN_POS_X] + PAWN_HALFW > sword_l) &&
(pawn[PAWN_POS_Y] - PAWN_HALFH < sword_b) &&
(pawn[PAWN_POS_Y] + PAWN_HALFH > sword_t) &&
(pawn[PAWN_STATE] == 0)) {
rt = true;
break;
}
}
return rt;
}
private final void hero_deadone() {
if (hero_being <= 0) {
hero_death = true;
return;
}
time_init();
//重新初始化主角参数
hero_cflash = 20;
hero_anima = 32;
hero_bombcount = 8;
hero_setfirestatus(STATUS_FIRE_NORMAL);
hero_death = false;
hero_being--;
hero_spd_y = 0;
//查找可以站立的位置
if (hero_old_x < position_x) {
for (int i = (position_x >> 3) + 1;
i < ( (position_x + screen_w) >> 3) - 3; i++) {
for (int j = position_y >> 3; j < (position_y + screen_h) >> 3; j++) {
if (grid_cellvalue(i, j) > 0) {
hero_pos_x = i << 3;
hero_pos_y = (j << 3) - 100;
return;
}
}
}
}
else {
hero_pos_x = hero_old_x;
hero_pos_y = hero_old_y - 100;
}
}
private final void hero_addscore(int score) {
if (hero_score / 10000 < (hero_score + score) / 10000) {
// sound_play(SOUND_GETBEING);
hero_being++;
}
if (score < 0) {
score = -score;
}
hero_score += score;
// System.out.println(score);
}
private final void hero_gainprop() {
for (int i = props.size() - 1; i >= 0; i--) {
int[] prop = (int[]) props.elementAt(i);
if ( (prop[PROP_POS_X] + (PROP_POS_W >> 1) > hero_pos_x - hero_frectw) &&
(prop[PROP_POS_Y] > hero_pos_y - hero_frectt) &&
(hero_pos_x + hero_frectw > prop[PROP_POS_X] - (PROP_POS_W >> 1)) &&
(hero_pos_y + 11 > prop[PROP_POS_Y] - PROP_POS_H)) {
switch (prop[PROP_INDEX]) {
case 0: //0 猪炸弹
hero_addscore(50);
break;
case 1: //1 屎分
hero_being++;
// info_create(hero_pos_x, hero_pos_y - 10, prop[PROP_TOTAL]);
break;
case 2: //2 蘑菇血
hero_anima = 32;
break;
case 3: //3 勋章生命
// onezidan = 50;
break;
case 4:
// twozidan = 80;
break;
case 5:
hero_addscore(100);
break;
// case 4: //4 鱼
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -