- PImage bulletIm, playerIm;
- class Entity {
- int x, y, w, h;
- PImage im;
- boolean ally;
- Entity(int x, int y, PImage im, boolean ally) {
- this.x = x;
- this.y = y;
- this.w = im.width;
- this.h = im.height;
- this.im = im;
- this.ally = ally;
- }
- boolean isCollinding(Entity e) {
- return !(x+w<e.x || x>e.x+e.w || y+h<e.y || y>e.y+e.h);
- }
- void update() {
- }
- void render() {
- image(im, x, y)
- }
- void destroy() { //sera exécuté lorsque l'objet sera détruit
- }
- }
- class Vaisseau extends Entity {
- int delay;
- Vaiseau(int x, int y, PImage im, boolean player) {
- super(x, y, im);
- this.ally = player;
- }
- void update() {
- delay ++;
- }
- void tir() {
- if(delay < 10)
- return;
- delay = 0;
- bullets.add(new Bullet(x+(ally ? w : -bulletIm.width), y+h/2-bulletIm.height));
- }
- }