Combat RPG

Voici les codes d'un programme d'un combat RPG avec les images nécessaire à son bon accomplissement à la fin.


float histoire=1;

float combat=0;
float Boutique=0;
int ZoneS=0;
int centrex=600;
int centrey=400;
int Ttexte=30;
Float tour=0.0;
PImage image;
PImage[] retour=new PImage[2];
float Att=0;
float Mag=0;
float Def=0;
float Objet=0;
float Fuir=0;
int choix;
int degat;
String[] DetailCombat= new String[6];
Perso[] Tennemie= new Perso[5];
Perso[] Hero= new Perso[1];
boolean[] TennemieVivant= new boolean[5];
PImage[] Ennemie= new PImage[10];
int[] TennemieEffetfaiblesse= new int[5];
PImage[] TCompetence= new PImage[70];
PImage[] TchoixICompetence=new PImage[4];
PImage[] IObjet= new PImage[10];
PImage[] TIZone= new PImage[2];
String[] TnomCompetence= new String[18];
int Hero_Aug_PDef=0;
int Hero_Aug_MDef=0;
int Hero_Comp_Leveedebouclier=0;
void setup(){
size(centrex*2,centrey*2);
textSize(Ttexte-5);
Import();
for(int i=0; i<TennemieEffetfaiblesse.length; i++){
TennemieEffetfaiblesse[i]=0;}
for(int i=0; i<VObjet.length; i++){
VObjet[i]=false;}
for(int i=0; i<Tennemie.length-1;i++){
NFor=0;
NDex=0;
NCon=0;
NInt=0;
NSag=0;
NCha=0;
Tennemie[i] = new Perso(image=loadImage("Orque.png"));}
for(int i=0; i<6;i++){
DetailCombat[i]="";
}
Hero[0]= new Perso (image=TCompetence[0]);
}
void draw(){
textSize(Ttexte-5);
fill(255);
stroke(255);
background(0);
debut();
arbre_competence();
textSize(Ttexte-10);
Combat();
boutique();
Zone();
if(histoire>1){
Hero[0].Interface();}
Game_Over();
}
void Combat(){ Orque1();
if(tour==-1){
for(int i=0; i<4; i++){
Hero[0].NmbCompetence[i]=5;}
tour=0.1;}
for(int i=0; i<Tennemie.length-1; i++){
if(Tennemie[i].Vie<=0){
TennemieVivant[i]=false;}}
if(combat>=1){
if(mouseX>=0 && mouseX<=30 && mouseY>=centrey+centrey/2-55 && mouseY<=centrey+centrey/2-50+25){
image(retour[1],5,centrey+centrey/2-50,20,20);
if(mousePressed==true){
background(0);
Att=0;
Def=0;
Mag=0;
Objet=0;
Fuir=0;
tour=0.1;}}
image(retour[0],5,centrey+centrey/2-50,20,20);
fill(50);
stroke(255);
rect(0,centrey+centrey/2,centrex/4,centrey/2-1);
rect(centrex/4,centrey+centrey/2,centrex+centrex/1.5-centrex/4,centrey/2-1);
rect(centrex,centrey+centrey/2,centrex*2-(centrex/3+centrex),centrey/2-1);
fill(255);
text("Attaque",20, centrey+centrey/2+Ttexte*1.5);
text("Magie",20, centrey+centrey/2+Ttexte*2.5);
text("Défense",20, centrey+centrey/2+Ttexte*3.5);
text("Objet",20, centrey+centrey/2+Ttexte*4.5);
text("Fuire",20, centrey+centrey/2+Ttexte*5.5);
for(int i=0; i<6;i++){
text(DetailCombat[i],15,Ttexte*(i+1.5));
}
if(tour==0.1){
//augmentation de défence
if(Hero_Comp_Leveedebouclier==1){
Hero[0].PDef=Hero[0].PDef-4;}
if(Hero_Comp_Leveedebouclier>0){
Hero_Comp_Leveedebouclier=Hero_Comp_Leveedebouclier-1;}
//Physique
if(Hero_Aug_PDef==1){
Hero[0].PDef=Hero[0].PDef-2;}
if(Hero_Aug_PDef>0){
Hero_Aug_PDef=Hero_Aug_PDef-1;}
//Magique
if(Hero_Aug_MDef==1){
Hero[0].MDef=Hero[0].MDef-2;}
if(Hero_Aug_MDef>0){
Hero_Aug_MDef=Hero_Aug_MDef-1;}
//effet faiblesse
for(int i=0; i<4;i++){
if(TennemieEffetfaiblesse[i]==1){
Tennemie[i].For=Tennemie[i].For+1;
Tennemie[i].Con=Tennemie[i].Con+1;
Tennemie[i].Dex=Tennemie[i].Dex+1;
Tennemie[i].Int=Tennemie[i].Int+1;
Tennemie[i].Sag=Tennemie[i].Sag+1;
Tennemie[i].Cha=Tennemie[i].Cha+1;}
if(TennemieEffetfaiblesse[i]>0){
TennemieEffetfaiblesse[i]=TennemieEffetfaiblesse[i]-1;}}
tour=(float)(1);}
if(tour==1){
fill(0,0,150);
rect(0,centrey+centrey/2-30,centrex/4,30);
if(mouseX>=0 && mouseX<=centrex/4 && mouseY>=centrey+centrey/2+Ttexte*0.5 && mouseY<=centrey+centrey/2+Ttexte*1.5){
fill(200,200,0);
text("Attaque",20, centrey+centrey/2+Ttexte*1.5);
if(mousePressed==true){
tour=1.1;
Att=1;
}}
if(mouseX>=0 && mouseX<=centrex/4 && mouseY>=centrey+centrey/2+Ttexte*1.5 && mouseY<=centrey+centrey/2+Ttexte*2.5){
fill(200,200,0);
text("Magie",20, centrey+centrey/2+Ttexte*2.5);
if(mousePressed==true){
tour=1.1;
Mag=1;
}}
if(mouseX>=0 && mouseX<=centrex/4 && mouseY>=centrey+centrey/2+Ttexte*2.5 && mouseY<=centrey+centrey/2+Ttexte*3.5){
fill(200,200,0);
text("Défense",20, centrey+centrey/2+Ttexte*3.5);
if(mousePressed==true){
tour=1.1;
Def=1;
}}
if(mouseX>=0 && mouseX<=centrex/4 && mouseY>=centrey+centrey/2+Ttexte*3.5 && mouseY<=centrey+centrey/2+Ttexte*4.5){
fill(200,200,0);
text("Objet",20, centrey+centrey/2+Ttexte*4.5);
if(mousePressed==true){
tour=1.1;
Objet=1;
}}
if(mouseX>=0 && mouseX<=centrex/4 && mouseY>=centrey+centrey/2+Ttexte*4.5 && mouseY<=centrey+centrey/2+Ttexte*5.5){
fill(200,200,0);
text("Fuite",20, centrey+centrey/2+Ttexte*5.5);
if(mousePressed==true){
tour=1.1;
Fuir=1;
}}
}
for(int i=0; i<Tennemie.length-1; i++){
if(TennemieVivant[i]==true){
fill(255);
image(Tennemie[i].icon, 50+centrex/4*i, centrey-centrey/4, 200, 200);
text(Tennemie[i].Classe+" : "+Tennemie[i].Vie+"/"+Tennemie[i].Viemax,centrex+50,centrey+centrey/2+Ttexte*(i+1.5));
}
}
if(Att==1){
fill(0,0,150);
rect(centrex,centrey+centrey/2-30,centrex*2-(centrex/3+centrex),30);
fill(255);
for(int i=0; i<Tennemie.length-1; i++){
if(TennemieVivant[i]==true){
if(mouseX>=centrex+40 && mouseX<=centrex+300 && mouseY>=centrey+centrey/2+Ttexte*(i+0.5) && mouseY<=centrey+centrey/2+Ttexte*(i+1.5)){
fill(200,200,0);
text(Tennemie[i].Classe+" : "+Tennemie[i].Vie+"/"+Tennemie[i].Viemax,centrex+50,centrey+centrey/2+Ttexte*(i+1.5));
noFill();
stroke(175,0,0);
rect( 50+centrex/4*i, centrey-centrey/4, 200, 200);
if(mousePressed==true){
degat=(int)(Tennemie[i].PDef-(random(1,6)+Hero[0].For/4));
if(degat>=0){
degat=-1;}
Tennemie[i].Vie=Tennemie[i].Vie+degat;
DetailCombat[0]=Hero[0].Classe +" a infligé "+degat+" point de vie à "+Tennemie[i].Classe+".";
tour=2.1;
Att=0;}}}
}
}
if(Objet==1){
fill(0,0,150);
rect(centrex/4,centrey+centrey/2-30,centrex-centrex/4,30);
fill(255);
UtObjet();
}
if(Mag==1){
fill(0,0,150);
rect(centrex,centrey+centrey/2-30,centrex*2-(centrex/3+centrex),30);
stroke(255);
fill(255);
attaque_select();
}
attaque();
if(Def==1){
Hero[0].PDef=Hero[0].PDef+2;
Hero[0].MDef=Hero[0].MDef+2;
DetailCombat[0]=Hero[0].Classe+" augmente sa défence.";
Hero_Aug_PDef=1;
Hero_Aug_MDef=1;
tour=2.1;
mousePressed=false;
Def=0;
}
if(tour==2.1){
for(int i=0; i<Tennemie.length-1; i++){
if(TennemieVivant[i]==true){
Tennemie[i].action=(int)(random(1,3));
if(Tennemie[i].action==1){
degat=(int)(Hero[0].PDef-(random(1,6)+Tennemie[i].For/4));
if(degat>=0){
degat=-1;}
Hero[0].Vie=Hero[0].Vie+degat;
DetailCombat[i+1]=Tennemie[i].Classe +" a infligé "+degat+" point de vie à "+Hero[0].Classe+".";}
if(Tennemie[i].action==2){
DetailCombat[i+1]=" ";
}
}}
tour=0.1;}
if(TennemieVivant[0]==false){
if(TennemieVivant[1]==false){
if(TennemieVivant[2]==false){
if(TennemieVivant[3]==false){
if(TennemieVivant[4]==false){
textSize(55);
fill(255,255,0);
text("Victoire",centrex/2+100,centrey/1.5);
textSize(Ttexte-10);
fill(100,255,100);
text("Butin : ",centrex-150,centrey);
victoire();}}}}}
}
}void arbre_competence(){ if(choix_competence==1){
if(keyCode==ENTER){
tour=-1.0;
if(histoire==2){
combat=1;}
if(histoire>2){
ZoneS=1;}
choix_competence=0;
keyCode=0;}
noFill();
rect(100,30,centrex+centrex/1.5-100,centrey*2-30*2);
image(TCompetence[2],10,50,100,100);
image(TCompetence[23],10,50*4,100,100);
image(TCompetence[44],10,50*7,100,100);
image(TCompetence[0],10,50*10,100,100);
if(mouseX>=10 && mouseX<=110 && mouseY>=50 && mouseY<=50+100){
image(TCompetence[3],10,50,100,100);
if(mousePressed==true){
arbre=1;}}
if(mouseX>=10 && mouseX<=110 && mouseY>=50*4 && mouseY<=50*4+100){
image(TCompetence[24],10,50*4,100,100);
if(mousePressed==true){
arbre=2;}}
if(mouseX>=10 && mouseX<=110 && mouseY>=50*7 && mouseY<=50*7+100){
image(TCompetence[45],10,50*7,100,100);
if(mousePressed==true){
arbre=3;}}
if(mouseX>=10 && mouseX<=110 && mouseY>=50*10 && mouseY<=50*10+100){
image(TCompetence[1],10,50*10,100,100);
if(mousePressed==true){
arbre=4;}}
if(arbre==1){
fill(25);
rect(100,30,centrex+centrex/1.5-100,150);
rect(100,30+150*1,centrex+centrex/1.5-100,150);
rect(100,30+150*2,centrex+centrex/1.5-100,150);
rect(100,30+150*3,centrex+centrex/1.5-100,150);
rect(100,30+150*4,centrex+centrex/1.5-100,150);
fill(255);
image(TCompetence[4],10,50,100,100);
//
image(TCompetence[5],centrex/2.8*2,35,140,140);
if(Hero[0].TactiveCompetence[1]==true){
image(TCompetence[7],centrex/2.8*2,35,140,140);}
//
image(TCompetence[8],centrex/2.8,35+150,140,140);
if(Hero[0].TactiveCompetence[2]==true){
image(TCompetence[10],centrex/2.8,35+150,140,140);}
//
image(TCompetence[11],centrex/2.8*3,35+150,140,140);
if(Hero[0].TactiveCompetence[3]==true){
image(TCompetence[13],centrex/2.8*3,35+150,140,140);}
if(mouseX>=centrex/2.8*2 && mouseX<=centrex/2.8*2+140 && mouseY>=35 && mouseY<=35+140){
image(TCompetence[6],centrex/2.8*2,35,140,140);
if(mousePressed==true){
Hero[0].TactiveCompetence[1]=true;}}
if(mouseX>=centrex/2.8 && mouseX<=centrex/2.8+140 && mouseY>=35+150 && mouseY<=35+150+140){
image(TCompetence[9],centrex/2.8,35+150,140,140);
if(mousePressed==true){
Hero[0].TactiveCompetence[2]=true;}}
if(mouseX>=centrex/2.8*3 && mouseX<=centrex/2.8*3+140 && mouseY>=35+150 && mouseY<=35+150+140){
image(TCompetence[12],centrex/2.8*3,35+150,140,140);
if(mousePressed==true){
Hero[0].TactiveCompetence[3]=true;}}
}
if(arbre==2){
fill(25);
rect(100,30,centrex+centrex/1.5-100,150);
rect(100,30+150*1,centrex+centrex/1.5-100,150);
rect(100,30+150*2,centrex+centrex/1.5-100,150);
rect(100,30+150*3,centrex+centrex/1.5-100,150);
rect(100,30+150*4,centrex+centrex/1.5-100,150);
fill(255);
image(TCompetence[25],10,50*4,100,100);
image(TCompetence[26],centrex/2.8*2,35,140,140);
if(Hero[0].TactiveCompetence[7]==true){
image(TCompetence[28],centrex/2.8*2,35,140,140);}
image(TCompetence[29],centrex/2.8,35+150,140,140);
if(Hero[0].TactiveCompetence[8]==true){
image(TCompetence[31],centrex/2.8,35+150,140,140);}
image(TCompetence[32],centrex/2.8*3,35+150,140,140);
if(Hero[0].TactiveCompetence[9]==true){
image(TCompetence[34],centrex/2.8*3,35+150,140,140);}
if(mouseX>=centrex/2.8*2 && mouseX<=centrex/2.8*2+140 && mouseY>=35 && mouseY<=35+140){
image(TCompetence[27],centrex/2.8*2,35,140,140);
if(mousePressed==true){
Hero[0].TactiveCompetence[7]=true;}}
if(mouseX>=centrex/2.8 && mouseX<=centrex/2.8+140 && mouseY>=35+150 && mouseY<=35+150+140){
image(TCompetence[30],centrex/2.8,35+150,140,140);
if(mousePressed==true){
Hero[0].TactiveCompetence[8]=true;}}
if(mouseX>=centrex/2.8*3 && mouseX<=centrex/2.8*3+140 && mouseY>=35+150 && mouseY<=35+150+140){
image(TCompetence[33],centrex/2.8*3,35+150,140,140);
if(mousePressed==true){
Hero[0].TactiveCompetence[9]=true;}}
}
if(arbre==3){
fill(25);
rect(100,30,centrex+centrex/1.5-100,150);
rect(100,30+150*1,centrex+centrex/1.5-100,150);
rect(100,30+150*2,centrex+centrex/1.5-100,150);
rect(100,30+150*3,centrex+centrex/1.5-100,150);
rect(100,30+150*4,centrex+centrex/1.5-100,150);
fill(255);
image(TCompetence[46],10,50*7,100,100);
//
image(TCompetence[47],centrex/2.8*2,35,140,140);
if(Hero[0].TactiveCompetence[13]==true){
image(TCompetence[49],centrex/2.8*2,35,140,140);}
//
image(TCompetence[50],centrex/2.8,35+150,140,140);
if(Hero[0].TactiveCompetence[14]==true){
image(TCompetence[52],centrex/2.8,35+150,140,140);}
//
image(TCompetence[53],centrex/2.8*3,35+150,140,140);
if(Hero[0].TactiveCompetence[15]==true){
image(TCompetence[55],centrex/2.8*3,35+150,140,140);}
if(mouseX>=centrex/2.8*2 && mouseX<=centrex/2.8*2+140 && mouseY>=35 && mouseY<=35+140){
image(TCompetence[48],centrex/2.8*2,35,140,140);
if(mousePressed==true){
Hero[0].TactiveCompetence[13]=true;}}
if(mouseX>=centrex/2.8 && mouseX<=centrex/2.8+140 && mouseY>=35+150 && mouseY<=35+150+140){
image(TCompetence[51],centrex/2.8,35+150,140,140);
if(mousePressed==true){
Hero[0].TactiveCompetence[14]=true;}}
if(mouseX>=centrex/2.8*3 && mouseX<=centrex/2.8*3+140 && mouseY>=35+150 && mouseY<=35+150+140){
image(TCompetence[54],centrex/2.8*3,35+150,140,140);
if(mousePressed==true){
Hero[0].TactiveCompetence[15]=true;}}
}
if(arbre==4){
fill(25);
rect(100,30,centrex+centrex/1.5-100,centrey*2-30*2);
image(TCompetence[0],10,50*10,100,100);
image(TCompetence[0],200,200,400,400);
image(TchoixICompetence[0],215,400-50,100,100);
if(mouseX>=215 && mouseX<=215+100 && mouseY>=400-50 && mouseY<=400-50+100){
if(mousePressed==true){
choix=1;}}
image(TchoixICompetence[1],600-115,400-50,100,100);
if(mouseX>=600-115 && mouseX<=600-115+100 && mouseY>=400-50 && mouseY<=400-50+100){
if(mousePressed==true){
choix=2;}}
image(TchoixICompetence[2],400-50,215,100,100);
if(mouseX>=400-50 && mouseX<=400-50+100 && mouseY>=215 && mouseY<=215+100){
if(mousePressed==true){
choix=3;}}
image(TchoixICompetence[3],400-50,600-115,100,100);
if(mouseX>=400-50 && mouseX<=400-50+100 && mouseY>=600-115 && mouseY<=600-115+100){
if(mousePressed==true){
choix=4;}}
for(int c=1; c<Hero[0].TactiveCompetence.length; c++){
if(Hero[0].TactiveCompetence[c]==true){
for(int A=0; A<3;A++){
if(Hero[0].TactiveCompetence[A+1]==true){
image(TCompetence[5+3*A],700,30+100*A,100,100);
if(mouseX>=700 && mouseY<=700+100 && mouseY>=30+100*A && mouseY<=30+100*A+100){
image(TCompetence[6+3*A],700,30+100*A,100,100);
if(mousePressed==true){
if(choix==1){
TchoixICompetence[0]=TCompetence[5+3*A];
Hero[0].TvalideCompetence[0]=TnomCompetence[A+1];}
if(choix==2){
TchoixICompetence[1]=TCompetence[5+3*A];
Hero[0].TvalideCompetence[1]=TnomCompetence[A+1];}
if(choix==3){
TchoixICompetence[2]=TCompetence[5+3*A];
Hero[0].TvalideCompetence[2]=TnomCompetence[A+1];}
if(choix==4){
TchoixICompetence[3]=TCompetence[5+3*A];
Hero[0].TvalideCompetence[3]=TnomCompetence[A+1];}
}}}}
for(int A=0; A<3;A++){
if(Hero[0].TactiveCompetence[A+7]==true){
image(TCompetence[26+3*A],800,30+100*A,100,100);
if(mouseX>=800 && mouseY<=800+100 && mouseY>=30+100*A && mouseY<=30+100*A+100){
image(TCompetence[27+3*A],800,30+100*A,100,100);
if(mousePressed==true){
if(choix==1){
TchoixICompetence[0]=TCompetence[26+3*A];
Hero[0].TvalideCompetence[0]=TnomCompetence[A+7];}
if(choix==2){
TchoixICompetence[1]=TCompetence[26+3*A];
Hero[0].TvalideCompetence[1]=TnomCompetence[A+7];}
if(choix==3){
TchoixICompetence[2]=TCompetence[26+3*A];
Hero[0].TvalideCompetence[2]=TnomCompetence[A+7];}
if(choix==4){
TchoixICompetence[3]=TCompetence[26+3*A];
Hero[0].TvalideCompetence[3]=TnomCompetence[A+7];}
}}}}
for(int A=0; A<3;A++){
if(Hero[0].TactiveCompetence[A+13]==true){
image(TCompetence[47+3*A],900,30+100*A,100,100);
if(mouseX>=900 && mouseY<=900+100 && mouseY>=30+100*A && mouseY<=30+100*A+100){
image(TCompetence[48+3*A],900,30+100*A,100,100);
if(mousePressed==true){
if(choix==1){
TchoixICompetence[0]=TCompetence[47+3*A];
Hero[0].TvalideCompetence[0]=TnomCompetence[A+13];}
if(choix==2){
TchoixICompetence[1]=TCompetence[47+3*A];
Hero[0].TvalideCompetence[1]=TnomCompetence[A+13];}
if(choix==3){
TchoixICompetence[2]=TCompetence[47+3*A];
Hero[0].TvalideCompetence[2]=TnomCompetence[A+13];}
if(choix==4){
TchoixICompetence[3]=TCompetence[47+3*A];
Hero[0].TvalideCompetence[3]=TnomCompetence[A+13];}
}}}}
}}
}
}
}

void debut(){ if(histoire==1){
textSize(Ttexte-10);
text("Bien le bonjour cher aventurier,",15,Ttexte*1.5);
text("Vous êtes ici pour la gloire et le combat j'imagine,",15,Ttexte*2.5);
text("Bien que vous êtes impatient de partir au combat il me faut quelques infos à votre sujet",15,Ttexte*3.5);
text("Jet de Dé : "+point,40,Ttexte*5);
image(retour[0],170,Ttexte*4.5-2,18,18);
if(mouseX>=170 && mouseX<=188 && mouseY>=Ttexte*4.5-5 && mouseY<=Ttexte*4.5+16){
image(retour[1],170,Ttexte*4.5-2,18,18);
if(mousePressed==true){
point=(int)(random(1,7)+random(1,7));
NFor=5;
NDex=5;
NCon=5;
NInt=5;
NSag=5;
NCha=5;
mousePressed=false;}}
text("Force :",60,Ttexte*6);
text("Dextérité :",60,Ttexte*7);
text("Constitution :",60,Ttexte*8);
text("Intelligence :",60,Ttexte*9);
text("Sagesse :",60,Ttexte*10);
text("Charisme :",60,Ttexte*11);
fill(175,175,200);
for(int i=6; i<12;i++){
text("+",200,Ttexte*i);
text("-",245,Ttexte*i);}
text(NFor,220,Ttexte*6);
text(NDex,220,Ttexte*7);
text(NCon,220,Ttexte*8);
text(NInt,220,Ttexte*9);
text(NSag,220,Ttexte*10);
text(NCha,220,Ttexte*11);
//Force
if(mouseX>=190 && mouseX<=210 && mouseY>=Ttexte*5 && mouseY<=Ttexte*6){
fill(200,200,0);
text("+",200,Ttexte*6);
if(point>=1 && NFor<15){
if(mousePressed==true){
NFor=NFor+1;
point=point-1;
mousePressed=false;}}}
if(mouseX>=230 && mouseX<=250 && mouseY>=Ttexte*5 && mouseY<=Ttexte*6){
fill(200,200,0);
text("-",245,Ttexte*6);
if(point>=0 && NFor>5){
if(mousePressed==true){
NFor=NFor-1;
point=point+1;
mousePressed=false;}}}
//Dextérité
if(mouseX>=190 && mouseX<=210 && mouseY>=Ttexte*6 && mouseY<=Ttexte*7){
fill(200,200,0);
text("+",200,Ttexte*7);
if(point>=1 && NDex<15){
if(mousePressed==true){
NDex=NDex+1;
point=point-1;
mousePressed=false;}}}
if(mouseX>=230 && mouseX<=250 && mouseY>=Ttexte*6 && mouseY<=Ttexte*7){
fill(200,200,0);
text("-",245,Ttexte*7);
if(point>=0 && NDex>5){
if(mousePressed==true){
NDex=NDex-1;
point=point+1;
mousePressed=false;}}}
//Constitution
if(mouseX>=190 && mouseX<=210 && mouseY>=Ttexte*7 && mouseY<=Ttexte*8){
fill(200,200,0);
text("+",200,Ttexte*8);
if(point>=1 && NCon<15){
if(mousePressed==true){
NCon=NCon+1;
point=point-1;
mousePressed=false;}}}
if(mouseX>=230 && mouseX<=250 && mouseY>=Ttexte*7 && mouseY<=Ttexte*8){
fill(200,200,0);
text("-",245,Ttexte*8);
if(point>=0 && NCon>5){
if(mousePressed==true){
NCon=NCon-1;
point=point+1;
mousePressed=false;}}}
//Intelligence
if(mouseX>=190 && mouseX<=210 && mouseY>=Ttexte*8 && mouseY<=Ttexte*9){
fill(200,200,0);
text("+",200,Ttexte*9);
if(point>=1 && NInt<15){
if(mousePressed==true){
NInt=NInt+1;
point=point-1;
mousePressed=false;}}}
if(mouseX>=230 && mouseX<=250 && mouseY>=Ttexte*8 && mouseY<=Ttexte*9){
fill(200,200,0);
text("-",245,Ttexte*9);
if(point>=0 && NInt>5){
if(mousePressed==true){
NInt=NInt-1;
point=point+1;
mousePressed=false;}}}
//Sagesse
if(mouseX>=190 && mouseX<=210 && mouseY>=Ttexte*9 && mouseY<=Ttexte*10){
fill(200,200,0);
text("+",200,Ttexte*10);
if(point>=1 && NSag<15){
if(mousePressed==true){
NSag=NSag+1;
point=point-1;
mousePressed=false;}}}
if(mouseX>=230 && mouseX<=250 && mouseY>=Ttexte*9 && mouseY<=Ttexte*10){
fill(200,200,0);
text("-",245,Ttexte*10);
if(point>=0 && NSag>5){
if(mousePressed==true){
NSag=NSag-1;
point=point+1;
mousePressed=false;}}}
//Charisme
if(mouseX>=190 && mouseX<=210 && mouseY>=Ttexte*10 && mouseY<=Ttexte*11){
fill(200,200,0);
text("+",200,Ttexte*11);
if(point>=1 && NCha<15){
if(mousePressed==true){
NCha=NCha+1;
point=point-1;
mousePressed=false;}}}
if(mouseX>=230 && mouseX<=250 && mouseY>=Ttexte*10 && mouseY<=Ttexte*11){
fill(200,200,0);
text("-",245,Ttexte*11);
if(point>=0 && NCha>5){
if(mousePressed==true){
NCha=NCha-1;
point=point+1;
mousePressed=false;}}}
//valide
if(keyCode==ENTER){
histoire=2;
Hero[0]= new Perso(image=TCompetence[0]);
keyCode=0;
choix_competence=1;
}
}
}

int ennemie;
void Orque1(){
if(combat==1){
NFor=3;
NDex=3;
NCon=8;
NInt=2;
NSag=2;
NCha=2;
NClasse="Slime";
for(int i=0; i<2 ;i++){
Tennemie[i] = new Perso(image=Ennemie[0]);
TennemieVivant[i] = true;}
combat=1.1;}
if(combat>=2 && combat<=4){
ennemie=int(random(2,5));
NFor=2;
NDex=3;
NCon=8;
NInt=2;
NSag=2;
NCha=2;
NClasse="Slime";
for(int i=0; i<ennemie ;i++){
Tennemie[i] = new Perso(image=Ennemie[0]);
TennemieVivant[i] = true;}
combat=4.1;}
if(combat==5){
ennemie=int(random(2,3));
NFor=8;
NDex=5;
NCon=8;
NInt=3;
NSag=3;
NCha=2;
NClasse="Orque ouvrier";
for(int i=0; i<ennemie ;i++){
Tennemie[i] = new Perso(image=Ennemie[1]);
TennemieVivant[i] = true;}
combat=5.1;}
if(combat>=6 && combat<=8){
ennemie=int(random(2,4));
NFor=8;
NDex=5;
NCon=5;
NInt=3;
NSag=3;
NCha=2;
NClasse="Squellete";
for(int i=0; i<ennemie ;i++){
Tennemie[i] = new Perso(image=Ennemie[2]);
TennemieVivant[i] = true;}
combat=8.1;}
if(combat>=9 && combat<=10){
ennemie=2;
NFor=10;
NDex=5;
NCon=10;
NInt=8;
NSag=8;
NCha=2;
NClasse="Mage Squellete";
for(int i=0; i<ennemie ;i++){
Tennemie[i] = new Perso(image=Ennemie[2]);
TennemieVivant[i] = true;}
combat=10.1;}
if(combat>=11){
ennemie=1;
NFor=13;
NDex=13;
NCon=13;
NInt=13;
NSag=13;
NCha=13;
NClasse="Faucheur";
for(int i=0; i<ennemie ;i++){
Tennemie[i] = new Perso(image=Ennemie[2]);
TennemieVivant[i] = true;}
combat=11.1;}
}


void Game_Over(){ if(Hero[0].Vie<=0){
background(0);
fill(150,0,0);
textSize(100);
text("Game Over", centrex/2,centrey-25);}
}


void Import(){
for(int i=0; i<TchoixICompetence.length; i++){
TchoixICompetence[i]=loadImage("Vide.png");}
//ennemie
Ennemie[0]=loadImage("Slime 2.png");
Ennemie[1]=loadImage("Orque.png");
Ennemie[2]=loadImage("Squellete 1.png");
Ennemie[3]=loadImage("mage squ.png");
Ennemie[4]=loadImage("faucheur.png");
//objet
IObjet[0]=loadImage("Potion de soin mineur.png");
PrixObjet[0]=20;
NomObjet[0]="Potion de soin mineur";
DescObjet[0]="rend 2d8 de point de vie. Valeur : 20.";
IObjet[1]=loadImage("Potion de mana mineur.png");
PrixObjet[1]=20;
NomObjet[1]="Potion de mana mineur";
DescObjet[1]="rend 1d10 de point de mana. Valeur : 20.";
IObjet[2]=loadImage("Etoile.png");
PrixObjet[2]=50;
NomObjet[2]="Bonus aléatoire de compétence";
DescObjet[2]="octroi un point de caractéristique de façon aléatoire. Valeur : 50.";
retour[0]=loadImage("Flèche retour.png");
retour[1]=loadImage("Flèche retour souris.png");
//arbre de competence
TCompetence[0]=loadImage("joystick.png");
TCompetence[1]=loadImage("joystick souris.png");
//arbre 1
TCompetence[2]=loadImage("Sang.png");
TCompetence[3]=loadImage("Sang souris.png");
TCompetence[4]=loadImage("Sang acquis.png");
TCompetence[5]=loadImage("Sang.png");
TCompetence[6]=loadImage("Sang souris.png");
TCompetence[7]=loadImage("Sang acquis.png");
TCompetence[8]=loadImage("Crâne.png");
TCompetence[9]=loadImage("Crâne souris.png");
TCompetence[10]=loadImage("Crâne acquis.png");
TCompetence[11]=loadImage("Sang.png");
TCompetence[12]=loadImage("Sang souris.png");
TCompetence[13]=loadImage("Sang acquis.png");
/*TCompetence[14]=loadImage("Sang.png");
TCompetence[15]=loadImage("Sang souris.png");
TCompetence[16]=loadImage("Sang acquis.png");
TCompetence[17]=loadImage("Sang.png");
TCompetence[18]=loadImage("Sang souris.png");
TCompetence[19]=loadImage("Sang acquis.png");
TCompetence[20]=loadImage("Sang.png");
TCompetence[21]=loadImage("Sang souris.png");
TCompetence[22]=loadImage("Sang acquis.png");*/
//arbre 2
TCompetence[23]=loadImage("épée.png");
TCompetence[24]=loadImage("épée souris.png");
TCompetence[25]=loadImage("épée acquis.png");
TCompetence[26]=loadImage("épée.png");
TCompetence[27]=loadImage("épée souris.png");
TCompetence[28]=loadImage("épée acquis.png");
TCompetence[29]=loadImage("bouclier.png");
TCompetence[30]=loadImage("bouclier souris.png");
TCompetence[31]=loadImage("bouclier acquis.png");
TCompetence[32]=loadImage("épée.png");
TCompetence[33]=loadImage("épée souris.png");
TCompetence[34]=loadImage("épée acquis.png");
/*TCompetence[35]=loadImage("épée.png");
TCompetence[36]=loadImage("épée souris.png");
TCompetence[37]=loadImage("épée acquis.png");
TCompetence[38]=loadImage("épée.png");
TCompetence[39]=loadImage("épée souris.png");
TCompetence[40]=loadImage("épée acquis.png");
TCompetence[41]=loadImage("épée.png");
TCompetence[42]=loadImage("épée souris.png");
TCompetence[43]=loadImage("épée acquis.png");*/
//arbre 3
TCompetence[44]=loadImage("Flèche.png");
TCompetence[45]=loadImage("Flèche souris.png");
TCompetence[46]=loadImage("Flèche acquis.png");
TCompetence[47]=loadImage("Flèche.png");
TCompetence[48]=loadImage("Flèche souris.png");
TCompetence[49]=loadImage("Flèche acquis.png");
TCompetence[50]=loadImage("Soin.png");
TCompetence[51]=loadImage("Soin souris.png");
TCompetence[52]=loadImage("Soin acquis.png");
TCompetence[53]=loadImage("Flèche.png");
TCompetence[54]=loadImage("Flèche souris.png");
TCompetence[55]=loadImage("Flèche acquis.png");
/*TCompetence[56]=loadImage("Flèche.png");
TCompetence[57]=loadImage("Flèche souris.png");
TCompetence[58]=loadImage("Flèche acquis.png");
TCompetence[59]=loadImage("Flèche.png");
TCompetence[60]=loadImage("Flèche souris.png");
TCompetence[61]=loadImage("Flèche acquis.png");
TCompetence[62]=loadImage("Flèche.png");
TCompetence[63]=loadImage("Flèche souris.png");
TCompetence[67]=loadImage("Flèche acquis.png");*/
//nom Compétence
TnomCompetence[1]="Absortion mineure";
TnomCompetence[2]="Faiblesse";
TnomCompetence[3]="test1";
TnomCompetence[7]="Coup féroce";
TnomCompetence[8]="Levée de bouclier";
TnomCompetence[9]="test2";
TnomCompetence[13]="Coup précis";
TnomCompetence[14]="Premier secour";
TnomCompetence[15]="test3";
TIZone[0]=loadImage("Plain.png");
TIZone[1]=loadImage("SF_Horror.png");
}


int NFor=5;int NDex=5;
int NCon=5;
int NInt=5;
int NSag=5;
int NCha=5;
String NClasse="Héro";
int choix_competence;
int arbre=0;
int point=0;
int Or=0;
int Exp=0;
class Perso{
int Viemax;
int Vie;
int Manamax;
int Mana;
int For;
int Dex;
int Con;
int Int;
int Sag;
int Cha;
int PDef;
int MDef;
String Classe;
PImage icon;
int action;
PImage Cchoix;
boolean[] TactiveCompetence= new boolean[6*3];
String[] TvalideCompetence= new String[4];
int[] NmbCompetence= new int[4];
//equipement
String Casque;
String Amulette;
String Plastron;
String Gant;
String BagueD;
String BagueG;
String Ceinture;
String Botte;
String MainG;
String MainD;
Perso(PImage image){
For=NFor;
Dex=NDex;
Con=NCon;
Int=NInt;
Sag=NSag;
Cha=NCha;
Classe=NClasse;
Viemax=Con+5;
Vie=Viemax;
Manamax=Int+Sag+5;
Mana=Manamax;
icon= image;
PDef=int(Con/6+For/6)+1;
MDef=int(Int/6+Sag/6)+1;
}
void Interface(){
Viemax=Con+5;
Manamax=Int+Sag+5;
noFill();
stroke(255);
rect(centrex+centrex/1.5,1,centrex/3-1,centrey*2-2);
fill(255);
text("Perso : "+Classe,centrex+centrex/1.5+10, Ttexte*1.5);
text("Stats : ",centrex+centrex/1.5+10, Ttexte*2.5);
textSize(Ttexte-10);
text("Vie :",centrex+centrex/1.5+35, Ttexte*3.5-5);
text("Mana :",centrex+centrex/1.5+35, Ttexte*4.5-15);
text("Force :",centrex+centrex/1.5+35, Ttexte*5.5-25);
text("Dext:",centrex+centrex/1.5+35, Ttexte*6.5-35);
text("Cons :",centrex+centrex/1.5+35, Ttexte*7.5-45);
text("Int :",centrex+centrex/1.5+35, Ttexte*8.5-55);
text("Sag :",centrex+centrex/1.5+35, Ttexte*9.5-65);
text("Cha :",centrex+centrex/1.5+35, Ttexte*10.5-75);
text(Vie+"/"+Viemax,centrex+centrex/1.5+100, Ttexte*3.5-5);
text(Mana+"/"+Manamax,centrex+centrex/1.5+100, Ttexte*4.5-15);
text(For,centrex+centrex/1.5+115, Ttexte*5.5-25);
text(Dex,centrex+centrex/1.5+115, Ttexte*6.5-35);
text(Con,centrex+centrex/1.5+115, Ttexte*7.5-45);
text(Int,centrex+centrex/1.5+115, Ttexte*8.5-55);
text(Sag,centrex+centrex/1.5+115, Ttexte*9.5-65);
text(Cha,centrex+centrex/1.5+115, Ttexte*10.5-75);
text("Exp :"+Exp,centrex+centrex/1.5+10, Ttexte*9);
text("Or : "+Or, centrex+centrex/1.5+10, Ttexte*10);
textSize(Ttexte-5);
}
}

void UtObjet(){
for(int i=0; i<NomObjet.length; i++){
if(VObjet[i]==true){
fill(255);
text(NomObjet[i]+" x"+NmbObjet[i], centrex/4+50,centrey+centrey/2+Ttexte*(i+1.5));
if(mouseX>=centrex/4+50 && mouseX<=centrex/4+50+200 && mouseY>=centrey+centrey/2+Ttexte*(i+1.5) && mouseY<=centrey+centrey/2+Ttexte*(i+2.5)){
fill(200,200,0);
text(NomObjet[i]+" x"+NmbObjet[i], centrex/4+50,centrey+centrey/2+Ttexte*(i+1.5));
if(NmbObjet[i]>0){
if(mousePressed==true){
NmbObjet[i]=NmbObjet[i]-1;
//Potion de soin
if(i==0){
Hero[0].Vie=Hero[0].Vie+int(random(1,8)+random(1,8));
if(Hero[0].Vie>Hero[0].Viemax){
Hero[0].Vie=Hero[0].Viemax;}}
//Potion de mana
if(i==1){
Hero[0].Mana=Hero[0].Mana+int(random(1,10));
if(Hero[0].Mana>Hero[0].Manamax){
Hero[0].Mana=Hero[0].Manamax;}}
//Point compétence
if(i==2){
int hasar=int(random(1,6));
if(hasar==1){Hero[0].For=Hero[0].For+1;}
if(hasar==2){Hero[0].Dex=Hero[0].Dex+1;}
if(hasar==3){Hero[0].Con=Hero[0].Con+1;}
if(hasar==4){Hero[0].Int=Hero[0].Int+1;}
if(hasar==5){Hero[0].Sag=Hero[0].Sag+1;}
if(hasar==6){Hero[0].Cha=Hero[0].Cha+1;}
}
//Fin
Objet=0;
tour=2.1;
}
}
}
}
}
}


void victoire(){ Hero[0].Vie=Hero[0].Viemax;
Hero[0].Mana=Hero[0].Manamax;
//Slime 1
if(combat==1.1){
histoire=3;
Or=Or+10;
Exp=Exp+10;
combat=1.2;
VObjet[0]=true;
VObjet[1]=true;
VObjet[2]=true;
}
if(combat==1.2){
fill(100,255,100);
text("-Or : +10",centrex-125,centrey+Ttexte);
text("-Exp : +10",centrex-125,centrey+Ttexte*2);
}
//Slime 2
if(combat==4.1){
Or=Or+ennemie*5;
Exp=Exp+ennemie*5;
combat=4.2;
}
if(combat==4.2){
fill(100,255,100);
text("-Or : "+ennemie*5,centrex-125,centrey+Ttexte);
text("-Exp : "+ennemie*5,centrex-125,centrey+Ttexte*2);
}
//Orque 1
if(combat==5.1){
Or=Or+ennemie*20;
Exp=Exp+ennemie*20;
combat=5.2;
}
if(combat==5.2){
fill(100,255,100);
text("-Or : "+ennemie*20,centrex-125,centrey+Ttexte);
text("-Exp : "+ennemie*20,centrex-125,centrey+Ttexte*2);
}
//Squellet 1
if(combat==8.1){
Or=Or+ennemie*25;
Exp=Exp+ennemie*25;
combat=8.2;
}
if(combat==8.2){
fill(100,255,100);
text("-Or : "+ennemie*25,centrex-125,centrey+Ttexte);
text("-Exp : "+ennemie*25,centrex-125,centrey+Ttexte*2);
}
//mage
if(combat==10.1){
Or=Or+ennemie*40;
Exp=Exp+ennemie*40;
combat=10.2;
}
if(combat==10.2){
fill(100,255,100);
text("-Or : "+ennemie*40,centrex-125,centrey+Ttexte);
text("-Exp : "+ennemie*40,centrex-125,centrey+Ttexte*2);
}
//Faucheur
if(combat==11.1){
Or=Or+ennemie*100;
Exp=Exp+ennemie*100;
combat=11.2;
}
if(combat==11.2){
fill(100,255,100);
text("-Or : "+ennemie*100,centrex-125,centrey+Ttexte);
text("-Exp : "+ennemie*100,centrex-125,centrey+Ttexte*2);
}
if(keyCode==ENTER){
combat=0;
Boutique=1;
keyCode=0;}
}

void Zone(){ if(ZoneS==1){
background(0);
fill(50);
rect(10,10,350,400);
rect(370,10,350,400);
image(TIZone[0],10,10,348,350);
image(TIZone[1],371,10,348,350);
fill(255);
text("Plaine",350/2-12,400);
text("Manoir",350/2+350,400);
if(mouseX>=10 && mouseX<=360 && mouseY>=10 && mouseY<=400){
fill(200,200,0);
text("Plaine",350/2-12,400);
if(mousePressed==true){
combat=int(random(2,6));
ZoneS=ZoneS-1;}}
if(mouseX>=370 && mouseX<=720 && mouseY>=10 && mouseY<=400){
fill(200,200,0);
text("Manoir",350/2+350,400);
if(mousePressed==true){
combat=int(random(6,12));
ZoneS=ZoneS-1;}}
}
}

int cible;void attaque_select(){
for(int i=0; i<Tennemie.length-1; i++){
if(TennemieVivant[i]==true){
if(mouseX>=centrex+40 && mouseX<=centrex+300 && mouseY>=centrey+centrey/2+Ttexte*(i+0.5) && mouseY<=centrey+centrey/2+Ttexte*(i+1.5)){
fill(200,200,0);
text(Tennemie[i].Classe+" : "+Tennemie[i].Vie+"/"+Tennemie[i].Viemax,centrex+50,centrey+centrey/2+Ttexte*(i+1.5));
noFill();
stroke(175,0,0);
rect( 50+centrex/4*i, centrey-centrey/4, 200, 200);
if(mousePressed==true){
cible=i;
Mag=2;
}
}
}
}
}
void attaque(){
if(Mag==2){
fill(0,0,150);
rect(centrex/4,centrey+centrey/2-30,centrex-centrex/4,30);
fill(255);
for(int i=0; i<Tennemie.length-1; i++){
if(cible==i){
for(int k=0; k<4; k++){
if(Hero[0].NmbCompetence[k]>0){
fill(255);
text(Hero[0].TvalideCompetence[k]+" "+Hero[0].NmbCompetence[k]+"/5", centrex/4+50,centrey+centrey/2+Ttexte*(k+1.5));
if(mouseX>=centrex/4+50 && mouseX<=centrex/4+50+260 && mouseY>=centrey+centrey/2+Ttexte*(k+0.5) && mouseY<=centrey+centrey/2+Ttexte*(k+1.5)){
fill(200,200,0);
text(Hero[0].TvalideCompetence[k]+" "+Hero[0].NmbCompetence[k]+"/5",centrex/4+50,centrey+centrey/2+Ttexte*(k+1.5));
if(Hero[0].NmbCompetence[k]>0){
if(mousePressed==true){
//Absortion mineure
if(Hero[0].TvalideCompetence[k]==TnomCompetence[1]){
degat=(int)(-(random(1,6)+Hero[0].Int/6));
if(degat>0){
degat=0;}
Tennemie[i].Vie=Tennemie[i].Vie+degat;
Hero[0].Vie=Hero[0].Vie-degat/2;
DetailCombat[0]=Hero[0].Classe +" a infligé "+degat+" point de vie à "+Tennemie[i].Classe+" et a absorbé "+-degat/2+" point de vie.";
Hero[0].NmbCompetence[k]=Hero[0].NmbCompetence[k]-1;
Mag=0;
tour=2.1;}
//Faiblesse
if(Hero[0].TvalideCompetence[k]==TnomCompetence[2]){
Tennemie[i].For=Tennemie[i].For-1;
Tennemie[i].Con=Tennemie[i].Con-1;
Tennemie[i].Dex=Tennemie[i].Dex-1;
Tennemie[i].Int=Tennemie[i].Int-1;
Tennemie[i].Sag=Tennemie[i].Sag-1;
Tennemie[i].Cha=Tennemie[i].Cha-1;
TennemieEffetfaiblesse[i]=2;
Hero[0].NmbCompetence[k]=Hero[0].NmbCompetence[k]-1;
Mag=0;
tour=2.1;}
//Coup féroce
if(Hero[0].TvalideCompetence[k]==TnomCompetence[7]){
degat=(int)(Tennemie[i].PDef-(random(1,6)+random(1,4)+Hero[0].For/4));;
if(degat>0){
degat=-1;}
Tennemie[i].Vie=Tennemie[i].Vie+degat;
DetailCombat[0]=Hero[0].Classe +" a infligé "+degat+" point de vie à "+Tennemie[i].Classe+".";
Hero[0].NmbCompetence[k]=Hero[0].NmbCompetence[k]-1;
Mag=0;
tour=2.1;}
//Levée de bouclier
if(Hero[0].TvalideCompetence[k]==TnomCompetence[8]){
Hero[0].PDef=Hero[0].PDef+4;
Hero_Comp_Leveedebouclier=1;
DetailCombat[0]=Hero[0].Classe+" augmente sa défence.";
Hero[0].NmbCompetence[k]=Hero[0].NmbCompetence[k]-1;
Mag=0;
tour=2.1;}
//Coup précis
if(Hero[0].TvalideCompetence[k]==TnomCompetence[13]){
degat=(int)(Tennemie[i].PDef-(random(1,6)+random(1,4)+Hero[0].Dex/4));;
if(degat>0){
degat=-1;}
Tennemie[i].Vie=Tennemie[i].Vie+degat;
DetailCombat[0]=Hero[0].Classe +" a infligé "+degat+" point de vie à "+Tennemie[i].Classe+".";
Hero[0].NmbCompetence[k]=Hero[0].NmbCompetence[k]-1;
Mag=0;
tour=2.1;}
//Premier secour
if(Hero[0].TvalideCompetence[k]==TnomCompetence[14]){
Hero[0].Vie=Hero[0].Vie+int(random(0,5)+Hero[0].Sag);
DetailCombat[0]=Hero[0].Classe+" se soigne et gagne 5 point de vie.";
if(Hero[0].Vie>Hero[0].Viemax){
Hero[0].Vie=Hero[0].Viemax;}
Hero[0].NmbCompetence[k]=Hero[0].NmbCompetence[k]-1;
Mag=0;
tour=2.1;}
}
}
}
}
}
}
}
}
}


String[] DescObjet= new String[10];String[] NomObjet= new String[3];
int[] NmbObjet= new int[3];
int[] PrixObjet= new int[3];
boolean[]VObjet=new boolean[10];
void boutique(){
if(Boutique==1){
for(int i=0; i<IObjet.length; i++){
if(VObjet[i]==true){
image(IObjet[i],15,10+i*155,150,150);
text(NmbObjet[i],18,27+i*155);
if(mouseX>=15 && mouseX<=165 && mouseY>=10+i*155 && mouseY<=10+i*155+150){
text(DescObjet[i],170,10+i*155+150/2);
if(mousePressed==true){
if(Or>=PrixObjet[i]){
NmbObjet[i]=NmbObjet[i]+1;
Or=Or-PrixObjet[i];
mousePressed=false;
}
}
}
}
}
}
if(keyCode==ENTER){
choix_competence=1;
Boutique=0;
keyCode=0;}
}


Et pour ce qui ont une bonne connexion voici les image

Créez votre site web gratuitement ! Ce site internet a été réalisé avec Webnode. Créez le votre gratuitement aujourd'hui ! Commencer