@Override public void render(Graphics g) { super.render(g); if (target != null) { turret.setRotation(Utils.getAngle(this.getPos(), target.getPos())); g.setColor(Color.green); // g.fillOval(target.getX()-10, target.getY()-10, target.getWidth()+20, // target.getHeight()+20); } g.drawImage(turret, getX(), getY()); }
@Override public void update(int delta) { super.update(delta); t += delta; if ((firing && t > burstFireRate || t > getFireRate()) && target != null) { if (!firing) { firing = true; } t = 0; currentVolley++; if (currentVolley >= volleys) { currentVolley = 0; firing = false; } MainGame.instance.root.addChild( new BulletPulse( getCenterPos(), this, Utils.getAngle(this.getCenterPos(), target.getCenterPos()), getWidth() / 2)); } if (target != null) { target.isTarget--; } target = getTarget(); if (target != null) { target.isTarget++; } }