📄 worldcanvas.java
字号:
if(State_Engine!=S_Game){
return;
}
if(scopy==Start_Game){
KeyModule=MULT;
}
State_Game=scopy;
scopy=0;
}
public void Pause_Show(){
GIB.setClip(0,0,176,208);
GIB.setColor(160,160,147);
GIB.fillRect(0,0,176,208);
GIB.setColor(222,222,222);
GIB.fillRect(40,43,95,113);
switch(cp){
case 0:GIB.setColor(80,80,80);GIB.fillRect(49,80,10,10);GIB.fillRect(118,80,10,10);break;
case 1:GIB.setColor(80,80,80);GIB.fillRect(49,116,10,10);GIB.fillRect(118,116,10,10);break;
}
Font_big(GIB,80,80,80);
GIB.drawString(getString(10),61,75,0);
Font_big(GIB,80,80,80);
GIB.drawString(getString(6),61,111,0);
}
public void Pause_Control(int i){
if(keyIs(i,UP_G)){
cp--;
if(cp<0){
cp=0;
}
}
if(keyIs(i,DOWN_G)){
cp++;
if(cp>1){
cp=1;
}
}
if(keyIs(i,FIRE_G)){
switch(cp){
case 0:
pressed_Button(8,0);
break;
case 1:
pressed_Button(9,0);
break;
}
}
}
//TODO LogoGame
protected int wait_Logo=0;
protected int last_Logo;
protected int num_Logo;
protected void perform_Logo(){
last_Logo+=getdelay();
if(last_Logo>=wait_Logo){
num_Logo++;
last_Logo=0;
}
switch(num_Logo){
case 0:
GIB.drawImage(logo1,0,0,0);
break;
case 1:
GIB.drawImage(logo2,0,0,0);
break;
case 2:
break;
case 3:
pressed_Button(3,0);
break;
}
}
protected void control_Logo(int i){
}
//TODO MineMenu
public int totalbutton=3;
public int selectedbutton=0;
protected void perform_MineMenu(){
GIB.setColor(128,128,128);
GIB.fillRect(0,0,176,208);
//GIB.drawImage(menu,0,40,0);
Font_big(GIB,227,227,227);
GIB.drawString(getString(12),57,23,0);
switch(selectedbutton){
case 0:GIB.setColor(192,192,192);GIB.fillRect(55,131,6,6);GIB.fillRect(108,131,6,6);break;
case 1:GIB.setColor(80,80,80);GIB.fillRect(55,145,6,6);GIB.fillRect(108,145,6,6);break;
case 2:GIB.setColor(192,192,192);GIB.fillRect(55,159,6,6);GIB.fillRect(108,159,6,6);break;
case 3:GIB.setColor(80,80,80);GIB.fillRect(55,173,6,6);GIB.fillRect(108,173,6,6);break;
}
Font_middle(GIB,227,227,227);
GIB.drawString(getString(3),63,126,0);
Font_middle(GIB,227,227,227);
GIB.drawString(getString(4),63,140,0);
Font_middle(GIB,227,227,227);
GIB.drawString(getString(5),63,154,0);
Font_middle(GIB,227,227,227);
GIB.drawString(getString(6),63,168,0);
}
protected void control_MineMenu(int i){
if(keyIs(i,UP_G)){
--selectedbutton;
if(selectedbutton<0){
selectedbutton=0;
}
}
else if(keyIs(i,DOWN_G)){
++selectedbutton;
if(selectedbutton>totalbutton){
selectedbutton=totalbutton;
}
}
else if(keyIs(i,FIRE_G)){
switch(selectedbutton){
case 0:
pressed_Button(4,0);
break;
case 1:
break;
case 2:
break;
case 3:
pressed_Button(9,0);
break;
}
}
}
// TODO Load
protected char storys[]=null;
protected String caption="";
protected byte storynum=100;
protected void perpare_Load(){
State_Game=Load_Game;
step_Load=0;
if(storys==null){
storys=new char[storynum];
}
else{
for(int i=0;i<storynum;++i){
storys[i]=0;
}
}
}
protected int step_Load=0;
protected void LoadStory(int num){
int i=0;
int count=0;
int step=0;
boolean key=false;
boolean door=true;
char cha=0;
byte temp[]=readFile(respath,"story");
CharOP.clear();
while(door){
cha=CharOP.readUnicode(temp[i],temp[i+1]);
if(key){
switch(step){
case 0:
if(cha==13&&CharOP.readUnicode(temp[i+2],temp[i+3])==10){
int test=CharOP.getInt();
if(test==num){
i+=22;
step=1;
}
else{
CharOP.clear();
key=false;
}
}
else{
CharOP.record(cha);
}
break;
case 1:
if(cha==13&&CharOP.readUnicode(temp[i+2],temp[i+3])==10){
caption=new String(CharOP.getChars());
settitle(caption);
i+=18;
step=2;
}
else{
CharOP.record(cha);
}
break;
case 2:
if(cha==13&&CharOP.readUnicode(temp[i+2],temp[i+3])==10){
i+=2;
}
else if(cha=='['){
door=false;
key=false;
}
else{
if(count<storynum){
storys[count++]=cha;
}
else{
door=false;
key=false;
}
}
break;
}
}
if(cha=='='){
key=true;
step=0;
}
else if(cha=='#'){
door=false;
key=false;
}
i+=2;
}
}
protected void PrintWord(Graphics g,final char cha[],int sx,int sy,int length,int wspace,int hspace){
int i=0;
int col=0;
int row=0;
int x=0;
int y=0;
while(i<cha.length&&cha[i]!=0){
x=sx+row*wspace;
y=sy+col*hspace;
g.drawChar(cha[i],x,y,0);
row++;
if(row>=length){
row=0;
col++;
}
i++;
}
}
protected void LoadGame(){
GIB.setClip(0,0,screen_width,screen_height);
GIB.setColor(160,160,147);
GIB.fillRect(0,0,176,208);
if(step_Load>9){
Font_middle(GIB,222,222,222);
GIB.drawString(getString(9),54,170,0);
}
GIB.setColor(222,222,222);
GIB.fillRect(38,15,100,20);
GIB.fillRect(20,45,134,120);
Font_big(GIB,60,60,60);
GIB.drawString(caption,38,15,0);
Font_middle(GIB,60,60,60);
PrintWord(GIB,storys,25,46,10,12,12);
GIB.setColor(255,255,255);
GIB.fillRect(32,185,110,6);
GIB.setColor(109,173,231);
GIB.setClip(32,185,(step_Load*110)/10,6);
GIB.fillRect(32,185,110,10);
Loading();
}
protected void control_LoadGame(int i){
if(step_Load>9&&i!=0){
pressed_Button(5,0);
}
}
protected void Loading(){
switch(step_Load){
case 0:
LoadStory(Level);
prepare_background();
break;
case 1:
LoadCreatureImage();
break;
case 2:
LoadGroundImage();
break;
case 3:
LoadGameAction();
break;
case 4:
perpare_Damages();
break;
case 5:
LoadMap();
break;
case 6:
// prepare_AI();
break;
case 7:
perpare_player();
break;
case 8:
// perpare_Judge();
break;
case 9:
perpare_Screen();
break;
}
if(step_Load<=9){
++step_Load;
}
}
// TODO Player
protected String title=null;
protected int ttime=4000;
protected int tcount=0;
protected int back_Block=20;
protected int front_Block=2620;
protected Creature aim=null;
protected Creature player=null;
public int player_x=0;
public int player_y=0;
public int player_step=0;
public int totalhp=0;
protected void perpare_player(){
setCreToPlayer(findCreature(0));
}
public void setCreToPlayer(Creature cre){
if(cre!=null){
player=cre;
player_x=player.x;
player_y=player.y;
player_step=player.step;
totalhp=cre.hp;
}
}
protected void gameface(){
if(tcount<ttime){
GIB.setClip(0,0,176,208);
GIB.setColor(222,222,222);
GIB.fillRect(38,55,100,20);
Font_big(GIB,62,62,62);
GIB.drawString(title,40,56,0);
tcount+=getdelay();
}
drawsys(300000,10,18);
GIB.setClip(0,0,176,208);
GIB.setColor(222,222,222);
GIB.fillRect(22,6,60,8);
GIB.fillRect(0,180,176,28);
if(player!=null){
int set=player.hp*10/totalhp;
if(set>7){
GIB.setColor(0,255,0);
}
else if(3<=set&&set<=7){
GIB.setColor(255,255,0);
}
else if(set<3){
GIB.setColor(255,0,0);
}
GIB.fillRect(22,6,player.hp*60/totalhp,8);
}
}
protected void perform_player(){
gameface();
if(player!=null&&player.hp>0){
player_x=player.x;
player_y=player.y;
player_step=player.step;
}
else{
pressed_Button(10,0);
}
}
protected void control_player(int i){
if(keyIs(i,RSB_G)){
pressed_Button(10,0);
}
if(player!=null&&player.hp>0){
if(keyIs(i,UP_G)){
player.jump();
}
if(keyIs(i,DOWN_G)){
}
if(keyIs(i,LEFT_G)){
player.moveback();
}
else if(keyIs(i,RIGHT_G)){
player.movefront();
}
else{
player.stopMove();
}
if(keyIs(i,FIRE_G)){
player.UseSkill(1);
}
if(keyIs(i,JUMP_G)){
}
}
}
// TODO Object
public static int aispace=200;
public int aicount=aispace;
public static int groundspace=88;
public static int groundtotal=2640;
public static Ground Grounds[]=new Ground[groundtotal/groundspace];
public static Creature Creatures[]=new Creature[groundtotal/groundspace];
protected void release_Object(){
for(int i=0;i<groundtotal/groundspace;++i){
Grounds[i]=null;
Creatures[i]=null;
}
}
protected Creature findCreature(int id){
Creature ptr=null;
for(int i=0;i<groundtotal/groundspace;++i){
ptr=Creatures[i];
while(ptr!=null){
if(ptr.sysid==id){
return ptr;
}
ptr=ptr.next;
}
}
System.out.println("Creature not found");
return null;
}
//BUG
protected void perform_Object(){
int i=player.x/groundspace;
checkObject(i,5);
objLife(i,5);
objAI(i,5);
drawObject(i,5);
}
protected void objAI(int i,int n){
aicount+=getdelay();
if(aicount>=aispace){
aicount=0;
int s=i-(n-1)/2;
int num=s+n;
for(;s<num;s++){
if(0<=s&&s<groundtotal/groundspace){
GroundAI(s);
CreatureAI(s);
}
}
}
}
protected void GroundAI(int num){
Ground ptr=null;
ptr=Grounds[num];
while(ptr!=null){
if(ptr.ai!=null){
ptr.ai.run();
}
ptr=ptr.next;
}
}
protected void CreatureAI(int num){
Creature ptr=null;
ptr=Creatures[num];
while(ptr!=null){
if(ptr.ai!=null){
ptr.ai.run();
}
ptr=ptr.next;
}
}
protected void checkObject(int i,int n){
int s=i-(n-1)/2;
int num=s+n;
for(;s<num;s++){
if(0<=s&&s<groundtotal/groundspace){
checkSpaceGround(s);
checkSpaceCreature(s);
}
}
}
protected void drawObject(int i,int n){
int s=i-(n-1)/2;
int num=s+n;
for(;s<num;s++){
if(0<=s&&s<groundtotal/groundspace){
drawSpaceGround(s);
}
GIB.setColor(255,0,0);
GIB.fillRect(s*groundspace-screenx,0,1,208);
}
s=i-(n-1)/2;
num=s+n;
for(;s<num;s++){
if(0<=s&&s<groundtotal/groundspace){
drawSpaceCreature(s);
}
}
}
public void objLife(int i,int n){
int s=i-(n-1)/2;
int num=s+n;
for(;s<num;s++){
if(0<=s&&s<groundtotal/groundspace){
GroundLife(s);
CreatureLife(s);
}
}
}
public void GroundLife(int num){
Ground ptr=null;
ptr=Grounds[num];
while(ptr!=null){
ptr.lifeCycle();
ptr=ptr.next;
}
}
public void CreatureLife(int num){
Creature ptr=null;
ptr=Creatures[num];
while(ptr!=null){
ptr.lifeCycle(back_Block,front_Block);
ptr=ptr.next;
}
}
protected void checkSpaceGround(int num){
Ground ptr=null;
ptr=Grounds[num];
while(ptr!=null){
if(ptr.objLive==false){
ptr=removeGround(num,ptr);
}
else{
int newnum=ptr.x/groundspace;
if(newnum!=num){
if(0<=newnum&&newnum<groundtotal/groundspace){
Ground temp=ptr;
ptr=removeGround(num,ptr);
addGround(temp);
}
else{
removeGround(num,ptr);
}
}
else{
ptr=ptr.next;
}
}
}
}
Creature temp=null;
protected void checkSpaceCreature(int num){
Creature ptr=null;
ptr=Creatures[num];
while(ptr!=null){
if(ptr.objLive==false){
ptr=removeCreature(num,ptr);
}
else{
int newnum=ptr.x/groundspace;
if(newnum!=num){
if(0<=newnum&&newnum<groundtotal/groundspace){
temp=ptr;
ptr=removeCreature(num,ptr);
addCreature(temp);
checkMoveState(temp,3);
}
else{
ptr=removeCreature(num,ptr);
}
}
else{
checkMoveState(ptr,3);
ptr=ptr.next;
}
}
}
}
protected void checkMoveState(final Creature cre,int n){
int s=cre.x/groundspace-(n-1)/2;
int num=s+n;
int y=0;
Ground ptr=null;
boolean GroundTouch=false;
boolean leftTouch=false;
boolean rightTouch=false;
for(;s<num;s++){
if(0<=s&&s<groundtotal/groundspace){
ptr=Grounds[s];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -