116 lines
5.5 KiB
Plaintext
116 lines
5.5 KiB
Plaintext
//ici il faut faire un enemie qui bouge
|
|
|
|
class Alien2 {
|
|
|
|
int blob, blob2;
|
|
int x,y;
|
|
int enemypv;
|
|
boolean show;
|
|
int randomy,randomx;
|
|
int NUMEROXEPLO = 0;
|
|
PImage enemy_explo;
|
|
|
|
Alien2(int xt,int yt,int pv, String imgEenemyt){
|
|
x = xt;
|
|
y = yt;
|
|
enemy_explo = loadImage("data/images/" + imgEenemyt);
|
|
show = true;
|
|
enemypv = pv;
|
|
}
|
|
|
|
|
|
void alea_bouge(){
|
|
|
|
randomy = (int) random(0,900);
|
|
randomx = (int) random(0,1600);
|
|
//frameRate(100);
|
|
if (frameCount % (60 * 5) == 0) {
|
|
x = randomx;
|
|
y = randomy;
|
|
println ("random = "+randomy);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void apparaitre() {
|
|
|
|
//affiche l'anime de explosion :
|
|
if ( !show && NUMEROXEPLO<50 ) {
|
|
// Ou Methode avec un if :
|
|
if ( String.valueOf(NUMEROXEPLO).length()==1 ) enemy_explo = loadImage("data/images/explosion/explosion000"+NUMEROXEPLO+".png");
|
|
else enemy_explo = loadImage("data/images/explosion/explosion00"+NUMEROXEPLO+".png");
|
|
NUMEROXEPLO += 1;
|
|
}
|
|
|
|
if (NUMEROXEPLO == 1 && son) {
|
|
sonExposion.play();
|
|
}
|
|
|
|
if (NUMEROXEPLO == 1) nombreEnemiReste -= 1;
|
|
|
|
//Affiche le mechant ou explosion s'il n'est pas détruis (l'anime de explosion est pas finie)
|
|
if (NUMEROXEPLO < 50) image(enemy_explo, x, y);
|
|
|
|
}
|
|
|
|
void verifiercollisions() {
|
|
|
|
// Avec le missile
|
|
if ( show && dist(xm, ym, x, y) < 80) {
|
|
|
|
// on luis enleve un point de vie
|
|
enemypv = enemypv - 1;
|
|
y = y - 50;
|
|
|
|
//suprime le missile
|
|
lancermisile = false;
|
|
}
|
|
|
|
// Avec le ship
|
|
// DEBUG : Affiche x et y dans la console
|
|
//println(dist(ship.x, ship.y, x, y) + "ship.x : " + ship.x + " < " + (x-75) + " : > " + (x+75) + " ship.y : " + ship.y + " <> " +y);
|
|
if ( dist(ship.x, ship.y, x, y) < 130 && show) {
|
|
// Averti le vaiseau de la collision
|
|
ship.collision = true;
|
|
|
|
// on luis enleve un point de vie
|
|
enemypv = enemypv - 1;
|
|
y = y - 20;
|
|
}
|
|
|
|
//le mechant disparait si il a plus de vie :
|
|
if ( enemypv == 0 ) {
|
|
show = false;
|
|
}
|
|
}
|
|
|
|
//public int random(){
|
|
// random = (int) Math.random()*(10-4);
|
|
// return random;
|
|
//}
|
|
|
|
//int cooldown_fonce = (int)random(10);
|
|
|
|
/*
|
|
//le if doit etre dans une fonction ou une class ou void ...
|
|
void setup() {
|
|
mechant2 = loadImage("data/images/mechant_tres_mechant150x150.png");
|
|
}
|
|
|
|
void draw() {
|
|
image(mechant2, 0, 0);
|
|
}
|
|
*/
|
|
|
|
void affiche_et_mets_a_jour_les_mechants() {
|
|
//println("affiche_et_mets_a_jour_les_mechants :");
|
|
if (show) {
|
|
verifiercollisions();
|
|
alea_bouge();
|
|
}
|
|
apparaitre();
|
|
}
|
|
|
|
}
|