📄 worldcanvas.java
字号:
}
else if(CharOP.ifrecordis(height)){
CharOP.clear();
i+=2;
st=4;
key=true;
}
else if(CharOP.ifrecordis(step)){
CharOP.clear();
i+=2;
st=5;
key=true;
}
else if(CharOP.ifrecordis(speed)){
CharOP.clear();
i+=2;
st=6;
key=true;
}
else if(CharOP.ifrecordis(jumpspeed)){
CharOP.clear();
i+=2;
st=7;
key=true;
}
else if(CharOP.ifrecordis(life)){
CharOP.clear();
i+=2;
st=8;
key=true;
}
else if(CharOP.ifrecordis(damage)){
CharOP.clear();
i+=2;
st=9;
key=true;
}
else if(CharOP.ifrecordis(skill1)){
CharOP.clear();
i+=2;
st=10;
key=true;
}
else if(CharOP.ifrecordis(skill2)){
CharOP.clear();
i+=2;
st=11;
key=true;
}
else if(CharOP.ifrecordis(skill3)){
CharOP.clear();
i+=2;
st=12;
key=true;
}
}
}
protected Creature ctemp=null;
protected Creature cparent=null;
protected void addCreature(Creature ctu){
int tilenum=ctu.x/groundspace;
if(Creatures[tilenum]==null){
Creatures[tilenum]=ctu;
}
else{
ctemp=Creatures[tilenum];
Creatures[tilenum]=ctu;
ctu.next=ctemp;
}
}
protected Creature removeCreature(int i,Creature ctu){
if(Creatures[i]==ctu){
Creatures[i]=Creatures[i].next;
ctu.next=null;
return null;
}
else{
cparent=null;
ctemp=null;
cparent=Creatures[i];
ctemp=cparent.next;
while(ctemp!=ctu){
cparent=ctemp;
ctemp=cparent.next;
}
cparent.next=ctemp.next;
ctemp.next=null;
return cparent.next;
}
}
Ground gtptr=null;
Ground gpptr=null;
protected void addGround(Ground grd){
int tilenum=grd.x/groundspace;
if(Grounds[tilenum]==null){
Grounds[tilenum]=grd;
}
else{
gtptr=Grounds[tilenum];
Grounds[tilenum]=grd;
grd.next=gtptr;
}
}
protected Ground removeGround(int i,Ground grd){
if(Grounds[i]==grd){
Grounds[i]=Grounds[i].next;
grd.next=null;
return null;
}
else{
gpptr=null;
gtptr=null;
gpptr=Grounds[i];
gtptr=gpptr.next;
while(gtptr!=grd){
gpptr=gtptr;
gtptr=gpptr.next;
}
gpptr.next=gtptr.next;
gtptr.next=null;
return gpptr.next;
}
}
// TODO damage
protected static DamageInfo damageinfos[]=null;
protected static DamageInfo damages[]=null;
protected static byte totalDnum=40;
protected void perpare_Damages(){
if(damages==null){
damages=new DamageInfo[totalDnum];
for(int i=0;i<totalDnum;++i){
damages[i]=new DamageInfo();
}
for(int i=0;i<20;++i){
damshow[i]=new StringBuffer();
}
}
else{
for(int i=0;i<totalDnum;++i){
damages[i].release();
}
for(int i=0;i<20;++i){
damshow[i].delete(0,10);
timecount[i]=0;
}
return;
}
String Cname="[";
String range="远程";
String maps="图示";
String xmod="偏移X";
String ymod="偏移Y";
String width="长";
String height="宽";
String speedx="速度X";
String speedy="速度Y";
String griv="重力";
String area="范围";
String dammul="伤害比例";
String contime="持续时间";
String spatime="作用间隔";
String cooldown="冷却时间";
int st=0;
int count=-1;
boolean key=false;
boolean minekey=true;
int i=12;
char cha=0;
Btemp=readFile(objectpath,"damageinfo");
CharOP.clear();
cha=CharOP.readUnicode(Btemp[i],Btemp[i+1]);
while(true){
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
i+=4;
break;
}
i+=2;
CharOP.record(cha);
cha=CharOP.readUnicode(Btemp[i],Btemp[i+1]);
}
int num=CharOP.getInt();
damageinfos=new DamageInfo[num];
while(minekey){
if(key==true){
cha=CharOP.readUnicode(Btemp[i],Btemp[i+1]);
switch(st){
case 1:
if(cha==']'){
damageinfos[count]=new DamageInfo();
CharOP.getChars();
i+=6;
key=false;
}
break;
case 2:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].range=(byte)CharOP.getInt();
i+=4;
key=false;
}
break;
case 3:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].mapid=CharOP.getInt();
i+=4;
key=false;
}
break;
case 4:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].xmod=(byte)CharOP.getInt();
i+=4;
key=false;
}
break;
case 5:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].ymod=(byte)CharOP.getInt();
i+=4;
key=false;
}
break;
case 6:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].width=(byte)CharOP.getInt();
i+=4;
key=false;
}
break;
case 7:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].height=(byte)CharOP.getInt();
i+=4;
key=false;
}
break;
case 8:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].speed_x=CharOP.getInt();
i+=4;
key=false;
}
break;
case 9:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].speed_y=CharOP.getInt();
i+=4;
key=false;
}
break;
case 10:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].griv=(byte)CharOP.getInt();
i+=4;
key=false;
}
break;
case 11:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].area=(byte)CharOP.getInt();
i+=4;
key=false;
}
break;
case 12:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].dammul=(byte)CharOP.getInt();
i+=4;
key=false;
}
break;
case 13:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].contime=CharOP.getInt();
i+=4;
key=false;
}
break;
case 14:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].sptime=CharOP.getInt();
i+=4;
key=false;
}
break;
case 15:
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
damageinfos[count].cooldown=CharOP.getInt();
i+=4;
key=false;
}
break;
}
if(key==true){
CharOP.record(cha);
i+=2;
}
}
else{
cha=CharOP.readUnicode(Btemp[i],Btemp[i+1]);
if(cha=='#'){
minekey=false;
break;
}
if(i<Btemp.length-1&&cha==13&&CharOP.readUnicode(Btemp[i+2],Btemp[i+3])==10){
i+=4;
continue;
}
else{
CharOP.record(cha);
}
i+=2;
}
if(CharOP.ifrecordis(Cname)){
CharOP.clear();
count++;
st=1;
key=true;
}
else if(CharOP.ifrecordis(range)){
CharOP.clear();
i+=2;
st=2;
key=true;
}
else if(CharOP.ifrecordis(maps)){
CharOP.clear();
i+=2;
st=3;
key=true;
}
else if(CharOP.ifrecordis(xmod)){
CharOP.clear();
i+=2;
st=4;
key=true;
}
else if(CharOP.ifrecordis(ymod)){
CharOP.clear();
i+=2;
st=5;
key=true;
}
else if(CharOP.ifrecordis(width)){
CharOP.clear();
i+=2;
st=6;
key=true;
}
else if(CharOP.ifrecordis(height)){
CharOP.clear();
i+=2;
st=7;
key=true;
}
else if(CharOP.ifrecordis(speedx)){
CharOP.clear();
i+=2;
st=8;
key=true;
}
else if(CharOP.ifrecordis(speedy)){
CharOP.clear();
i+=2;
st=9;
key=true;
}
else if(CharOP.ifrecordis(griv)){
CharOP.clear();
i+=2;
st=10;
key=true;
}
else if(CharOP.ifrecordis(area)){
CharOP.clear();
i+=2;
st=11;
key=true;
}
else if(CharOP.ifrecordis(dammul)){
CharOP.clear();
i+=2;
st=12;
key=true;
}
else if(CharOP.ifrecordis(contime)){
CharOP.clear();
i+=2;
st=13;
key=true;
}
else if(CharOP.ifrecordis(spatime)){
CharOP.clear();
i+=2;
st=14;
key=true;
}
else if(CharOP.ifrecordis(cooldown)){
CharOP.clear();
i+=2;
st=15;
key=true;
}
}
Btemp=null;
}
public static DamageInfo getFreeD(){
for(int i=0;i<totalDnum;++i){
if(damages[i].free){
return damages[i];
}
}
System.out.println("max damages");
return null;
}
public static void Create(DamageInfo di,int i,Creature cre,int delay){
if(di!=null&&i<damageinfos.length){
di.setValue(damageinfos[i],cre,delay);
}
}
public static void createDamage(int type,Creature cre,int delay){
Create(getFreeD(),type,cre,delay);
}
public void damageProcess(){
for(int i=0;i<totalDnum;++i){
if(!damages[i].free){
if(damages[i].x<screenx-20||damages[i].y>screenx+screen_width+20){
damages[i].release();
continue;
}
if(damages[i].griv==1){
damages[i].increaseFallSpeed(50);
}
drawgame(damages[i].getMapID(),damages[i].x,damages[i].y);
//TODO test
//
//
//
GIB.setClip(0,0,176,208);
GIB.setColor(255,0,0);
GIB.drawRect(damages[i].x-damages[i].width/2-screenx,damages[i].y-damages[i].height,damages[i].width,damages[i].height);
damages[i].run(Grounds,Creatures);
}
}
}
public static int lasttime=500;
public static StringBuffer damshow[]=new StringBuffer[20];
public static int damx[]=new int [20];
public static int damy[]=new int [20];
public static int timecount[]=new int [20];
public static void damSet(Creature cre,int dam){
int n=0;
int num=0;
for(int i=0;i<20;++i){
if(timecount[i]==0){
n=i;
damx[n]=cre.x-6;
damy[n]=cre.y-cre.height-14;
if(dam<0){
timecount[n]=1;
damshow[n].append('-');
}
else{
timecount[n]=2;
damshow[n].append('+');
}
dam=Math.abs(dam);
num=dam/1000;
dam-=num*1000;
if(num!=0){
damshow[n].append((char)(num+48));
}
num=dam/100;
dam-=num*100;
if(num!=0){
damshow[n].append((char)(num+48));
}
num=dam/10;
dam-=num*10;
if(num!=0){
damshow[n].append((char)(num+48));
}
num=dam;
damshow[n].append((char)(num+48));
break;
}
}
}
public void showDam(){
GIB.setClip(0,0,176,208);
for(int i=0;i<20;++i){
if(timecount[i]==0){
continue;
}
else if(timecount[i]==1){
GIB.setColor(255,0,0);
}
else if(timecount[i]==2){
GIB.setColor(0,255,0);
}
else if(timecount[i]>lasttime){
timecount[i]=0;
damx[i]=0;
damy[i]=0;
damshow[i].delete(0,10);
continue;
}
GIB.drawString(damshow[i].toString(),damx[i]-screenx,damy[i]+screeny,0);
timecount[i]+=getdelay();
damy[i]-=1;
}
}
// TODO screen
protected int screenx;
protected int screeny;
protected int screen_width=176;
protected int screen_height=208;
protected void perpare_Screen(){
screenx=player_x-screen_width/2;
if(screenx<back_Block){
screenx=back_Block;
}
if(screenx+screen_width>front_Block){
screenx=front_Block-screen_width;
}
}
// TODO background
protected int mapid[]={3,4,5};
protected int back_1x;
protected int back_2x=176;
protected int back_speed=1;
protected void prepare_background(){
back_1x=0;
back_2x=176;
}
protected void settitle(final String str){
title=new String(str);
tcount=0;
}
protected void perform_background(){
if((player_x>=screenx+screen_width/2+10)&&(screenx+screen_width+back_speed<front_Block)){
back_moveright();
}
if((player_x<=screenx+screen_width/2-10)&&(screenx-back_speed>back_Block)){
back_moveleft();
}
GIB.setClip(0,0,176,208);
GIB.drawImage(background,back_1x,20,0);
GIB.drawImage(background,back_2x,20,0);
}
protected void back_moveleft(){
back_1x+=back_speed;
back_2x+=back_speed;
screenx-=player_step;
if(back_1x>=screen_width){
back_1x=back_1x-2*screen_width;
}
if(back_2x>=screen_width){
back_2x=back_2x-2*screen_width;
}
}
protected void back_moveright(){
back_1x-=back_speed;
back_2x-=back_speed;
screenx+=player_step;
if(back_1x<=-screen_width){
back_1x=2*screen_width+back_1x;
}
if(back_2x<=-screen_width){
back_2x=2*screen_width+back_2x;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -