- image(joueur, vaisseau_X, vaisseau_Y, box_joueur.w, box_joueur.h); // in a class player
- image(ennemi, box1.x, box1.y, box1.w, box1.h); //in a class ennemy
- boolean collision()
- {
- int x1 = vaisseau_X;
- int y1 = vaisseau_Y;
- int h1 = box_joueur.h;//50
- int w1 = box_joueur.w;//100
- int x2 = box1.x;//800
- int y2 = box1.y;//250
- int h2 = box1.h;//100
- int w2 = box1.w;//100
- if ((x2 >= x1 + w1) || (x2 + w2 <= x1) || (y2 >= y1 + h1) || (y2 + h2 <= y1))
- {
- return false;
- } else {
- return true;
- }
- }
- if (player.collision())
- {
- } else
- {
- player.draw();
- }
- if (enemy.collision())
- {
- } else
- {
- enemy.draw();
- }