class DamageObject extends Entity { float damage; float atkspeed; DamageObject(Vector3D l, float s, int t, float dmg) { super(l, s, t); damage = dmg; } void run() { collision(); } void fire(Vector3D l, Vector3D d, float s, int t, float dmg) { // Do me please :'( } void collision() { for (int i = flock.boids.size() - 1; i >= 0; i--) { Boid other = (Boid) flock.boids.get(i); float d = loc.distance(loc,other.loc); if (d >= 0 && d <= r) { other.life -= damage; effectObject.add(new BulletImpact(new Vector3D(other.loc.x, other.loc.y), 4, 5, 100.0f)); gack.scorePoint += gack.maxspeed / 5.f; } } } float atkspeed(){ return this.atkspeed; } }; /*Bullet b(Vector3D l, Vector3D d, float s, int t, float dmg) { return new Bullet(l, 2.0f, t, dmg); }*/ class PsyFire extends DamageObject { int step; float nextStep; float lastTime; float speed; Vector3D dir; PsyFire(Vector3D l, Vector3D d, float s, int t, float dmg) { super(l, 20.0f, t, dmg); speed = s * 2.0f; dir = d.copy(); step = 0; nextStep = 50f; lastTime = millis(); } void run() { update(); render(); borders(); collision(); } void borders() { if (loc.x < -r) loc.x = width+r; if (loc.y < -r) loc.y = height+r; if (loc.x > width+r) loc.x = -r; if (loc.y > height+r) loc.y = -r; } void update() { nextStep -= millis() - lastTime; Vector3D tmp = dir.copy(); tmp.mult(speed); tmp.limit(speed); loc.add(tmp); if (nextStep <= 0) { step += 1; nextStep = 50f; if (step >= 14) { for (int i = dmgObject.size() - 1; i >= 0; i--) { if (this == dmgObject.get(i)) { bigSplash.add(new PsyExplode(loc, 55f, 5, 600f)); dmgObject.remove(i); break; } } } } lastTime = millis(); } void render() { fill(200); stroke(110, 60, 235); pushMatrix(); translate(loc.x,loc.y); imageMode(CENTER); PImage psy = (PImage)spriteList.get(21 + (step % 10)); image(psy, 0, 0); popMatrix(); stroke(255); } } class PsyLoad extends DamageObject { int step; float nextStep; float lastTime; PsyLoad(Vector3D l, Vector3D d, float s, int t, float dmg) { super(l, 20.0f, t, dmg); step = 0; nextStep = 50f; lastTime = millis(); } void run() { update(); render(); collision(); } void update() { loc = gack.loc; nextStep -= millis() - lastTime; if (nextStep <= 0) { step += 1; nextStep = 50f; if (step >= 9) { for (int i = dmgObject.size() - 1; i >= 0; i--) { if (this == dmgObject.get(i)) { dmgObject.remove(i); dmgObject.add(new PsyFire(gack.loc, gack.vel, 2.5f, 2, 10f)); break; } } } } lastTime = millis(); } void render() { fill(200); stroke(110, 60, 235); pushMatrix(); translate(loc.x,loc.y); imageMode(CENTER); PImage psy = (PImage)spriteList.get(11 + step); image(psy, 0, 0); popMatrix(); stroke(255); } } class Bullet extends DamageObject { float speed; Vector3D dir; void fire(Vector3D l, Vector3D d, float s, int t, float dmg) { dmgObject.add(new Bullet(l, d, s, t, dmg)); } Bullet(Vector3D l, Vector3D d, float s, int t, float dmg) { super(l, 4.0f, t, dmg); speed = s * 2.0f; atkspeed = 0.01f; dir = d.copy(); dir.x = dir.x - loc.x; dir.y = dir.y - loc.y; } void run() { update(); borders(); render(); collision(); } void update() { Vector3D tmp = dir.copy(); tmp.normalize(); tmp.mult(speed); loc.add(tmp); } void borders() { if (loc.x < 0 || loc.x > width || loc.y < 0 || loc.y > height) { for (int i = dmgObject.size() - 1; i >= 0; i--) if (this == dmgObject.get(i)) { dmgObject.remove(i); break; } } } void render() { fill(200); stroke(110, 60, 235); pushMatrix(); translate(loc.x,loc.y); ellipse(0, 0, r, r); popMatrix(); stroke(255); } } class BigBullet extends Bullet { BigBullet(Vector3D l, Vector3D d, float s, int t, float dmg) { super(l, d, s, t, dmg); atkspeed = 60.0f; dmg += 2; r += 10; } void fire(Vector3D l, Vector3D d, float s, int t, float dmg) { dmgObject.add(new BigBullet(l, d, s, t, dmg)); } } class HugeBullet extends BigBullet { HugeBullet(Vector3D l, Vector3D d, float s, int t, float dmg) { super(l, d, s, t, dmg); atkspeed = 110f; dmg += 2; r += 10; } void fire(Vector3D l, Vector3D d, float s, int t, float dmg) { dmgObject.add(new HugeBullet(l, d, s, t, dmg)); } } class WindBlast extends DamageObject { float lastTime; float speed; float rotate_dir; Vector3D dir; WindBlast(Vector3D l, Vector3D d, float s, int t, float dmg, float direction) { super(l, 20.0f, t, dmg); speed = s * 2.0f; dir = d.copy(); lastTime = millis(); rotate_dir = direction; r = 15; } void run() { update(); render(); borders(); collision(); } void borders() { if (loc.x < 0 || loc.x > width || loc.y < 0 || loc.y > height) { for (int i = dmgObject.size() - 1; i >= 0; i--) if (this == dmgObject.get(i)) { dmgObject.remove(i); break; } } } void update() { Vector3D tmp = dir.copy(); tmp.mult(speed); tmp.limit(speed); loc.add(tmp); lastTime = millis(); } void render() { fill(200); stroke(110, 60, 235); pushMatrix(); translate(loc.x,loc.y); rotate(rotate_dir); imageMode(CENTER); //PImage psy = (PImage)spriteList.get(21 + (step % 10)); PImage psy = (PImage)spriteList.get(33); image(psy, 0, 0); popMatrix(); } }