Processing G空战v1.0

记录和公布processing语言编程游戏的情况及全部代码。资源由PPT绘制,存放pde程序的同目录data文件夹中。



下面是全部代码:(有问题评论区@up主)

PImage flyplan1;
PImage flyplan2;
PImage flyplan3;
PImage boss;
PImage BG;
PImage planhp;
PImage boshp;
PImage losthp;
PImage bosatk;
PImage attack;
PImage effect;
PImage win;
PImage end;
int bxpos1 = 200;
int bxpos2 = 400;
int xpos = 0;
float attackd1;
float attackd2;
int count1;
float attackd3;
float attackd4;
float attackd5;
float attackd6;
float attackd7;
float attackd8;
int count2;
int ypos = 400;
int ypos1 = 10;
int X1 = 0;
int Y1 = 0;
boolean attackbool = false;
void setup(){
size(600,800,P2D);
flyplan1=loadImage("flyplan1.png");
flyplan2=loadImage("flyplan2.png");
flyplan3=loadImage("flyplan3.png");
boss=loadImage("boss.png");
BG=loadImage("BG.png");
planhp=loadImage("planhp.png");
boshp=loadImage("boshp.png");
losthp=loadImage("losthp.png");
bosatk=loadImage("bosatk.png");
attack=loadImage("attack.png");
effect=loadImage("effect.png");
win=loadImage("win.png");
end=loadImage("end.png");}
void draw(){
background(255,255,255);
imageMode(CORNER);
image(BG,0,0,600,800);
if(mouseX>300){xpos=300-mouseX;}
else xpos=mouseX-300;
ypos1=ypos1-10;
imageMode(CENTER);
image(boss,bxpos1,100-xpos/5,275,175);
image(boss,bxpos2,100+xpos/5,275,175);
image(bosatk,bxpos1+50,200-xpos/5-ypos1,25,25);
image(bosatk,bxpos2+50,200+xpos/5-ypos1,25,25);
image(bosatk,bxpos1,200-xpos/5-ypos1,30,30);
image(bosatk,bxpos2,200+xpos/5-ypos1,30,30);
image(bosatk,bxpos1-50,200-xpos/5-ypos1,25,25);
image(bosatk,bxpos2-50,200+xpos/5-ypos1,25,25);
if(200-xpos/5-ypos1>1000){ypos1=0;}
if(200+xpos/5-ypos1>1000){ypos1=0;}
bxpos1=bxpos1+4;
if(bxpos1>400){bxpos1=200;}
bxpos2=bxpos2-4;
if(bxpos2<200){bxpos2=400;}
if(mouseX>=200&&mouseX<=400)
{imageMode(CENTER);
image(flyplan1,mouseX,mouseY,120,120); }
if(mouseX>=0&&mouseX<=200)
{imageMode(CENTER);
image(flyplan2,mouseX,mouseY,120,125); }
if(mouseX>=400&&mouseX<=600)
{imageMode(CENTER);
image(flyplan3,mouseX,mouseY,120,125); }
image(attack,mouseX+40,mouseY-ypos-50,18,80);
image(attack,mouseX-40,mouseY-ypos-50,18,80);
attackd1=dist(mouseX+40,mouseY-ypos-50,bxpos1,100-xpos/5);
if(attackd1<50){image(effect,mouseX+40,mouseY-ypos-50,150,150);count1++;}
attackd2=dist(mouseX-40,mouseY-ypos-50,bxpos1,100+xpos/5);
if(attackd2<50){image(effect,mouseX-40,mouseY-ypos-50,150,150);count1++;}
attackd3=dist(bxpos1+50,200-xpos/5-ypos1,mouseX,mouseY);
if(attackd3<50){image(effect,mouseX,mouseY,100,100);count2++;}
attackd4=dist(bxpos1+50,200+xpos/5-ypos1,mouseX,mouseY);
if(attackd4<50){image(effect,mouseX,mouseY,100,100);count2++;}
attackd5=dist(bxpos1,200-xpos/5-ypos1,mouseX,mouseY);
if(attackd5<50){image(effect,mouseX,mouseY,100,100);count2++;}
attackd6=dist(bxpos1,200+xpos/5-ypos1,mouseX,mouseY);
if(attackd6<50){image(effect,mouseX,mouseY,100,100);count2++;}
attackd7=dist(bxpos1-50,200-xpos/5-ypos1,mouseX,mouseY);
if(attackd7<50){image(effect,mouseX,mouseY,100,100);count2++;}
attackd8=dist(bxpos1-50,200+xpos/5-ypos1,mouseX,mouseY);
if(attackd8<50){image(effect,mouseX,mouseY,100,100);count2++;}
ypos=ypos+12;
if(ypos>600){ypos=0;}
image(boshp,25,25,35,35);
image(planhp,540,740,35,35);
if(count2>=18){image(losthp,540,740,35,35);}
image(planhp,495,740,35,35);
if(count2>=36){image(losthp,495,740,35,35);}
image(planhp,445,740,35,35);
image(boshp,70,25,35,35);
if(count1>=20){image(losthp,70,25,35,35);}
image(boshp,115,25,35,35);
if(count1>=16){image(losthp,115,25,35,35);}
image(boshp,160,25,35,35);
if(count1>=12){image(losthp,160,25,35,35);}
image(boshp,205,25,35,35);
if(count1>=8){image(losthp,205,25,35,35);}
image(boshp,250,25,35,35);
if(count1>=4){image(losthp,250,25,35,35);}
if(count1>=24){image(losthp,25,25,35,35);
imageMode(CORNER);
image(win,0,0,600,800);count2=0;}
if(count2>=72){image(losthp,445,740,35,35);
imageMode(CORNER);
image(end,0,0,600,800);count1=0;}
}
