1. abstract class Entity {
  2. int vie;
  3. float x, y, w, h;
  4. PImage im, masque;
  5. boolean ally;
  6. Entity(int vie, float x, float y, PImage im, PImage masque, boolean ally)
  7. {
  8. this.x = x;
  9. this.y = y;
  10. this.w = im.width;
  11. this.h = im.height;
  12. this.im = im;
  13. this.masque = masque;
  14. this.ally = ally;
  15. this.vie = vie;
  16. }
  17. void update()
  18. {
  19. }
  20. void display()
  21. {
  22. image(im, x, y);
  23. }
  24. void destroy() //sera exécuté lorsque l'objet sera détruit
  25. {
  26. }
  27. }
  28. class Vaisseau extends Entity {
  29. double delay;
  30. double delayTir;
  31. Vaisseau(int vie, float x, float y, PImage im, PImage masque, boolean player)
  32. {
  33. super(vie, x, y, im, masque, player);
  34. this.ally = player;
  35. delayTir = ally ? 10 : random(200, 250);
  36. delay = (ally ? delayTir : delayTir/2) * dTime ;
  37. }
  38. void update()
  39. {
  40. }
  41. void tir()
  42. {
  43. if (delay > delayTir)
  44. {
  45. entities.add(new Bullet(ally ? x+70 : x-im.height/2, ally ? y+32 : y+im.width/2, ally));
  46. delay = 0;
  47. }
  48. delay += dTime;
  49. }
  50. }