# Why aren't my ellipses spawning in the proper location?

**URL:** https://discourse.processing.org/t/why-arent-my-ellipses-spawning-in-the-proper-location/11972
**Category:** Coding Questions
**Created:** [June 10, 2019, 3:50pm UTC](https://discourse.processing.org/t/why-arent-my-ellipses-spawning-in-the-proper-location/11972 "2019-06-10T15:50:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![newone](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@newone](https://discourse.processing.org/u/newone)
#### Post date: [June 10, 2019, 3:50pm UTC](https://discourse.processing.org/t/why-arent-my-ellipses-spawning-in-the-proper-location/11972/1 "2019-06-10T15:50:07Z")

</div>

Hello Processing forum users,

I am currently having an issue with my Tank simulation program: there are a few tanks roaming around on my screen and they shoot bullets(ellipses) at each other. The `fire()` method adds a bullet to an ArrayList of bullets located in main, which draws and moves the bullets every 10 or so seconds.

```auto
public class AttackerTank extends TankType {
    Main main;
    // class variables..
    }

    public void draw() {
    xDest = Math.cos(turretAngle)*40+this.x; //draws turret
    yDest = Math.sin(turretAngle)*40+this.y;
    if(this.turretAngle > 2*PI) {
        this.turretAngle = 0;
    } else if (this.turretAngle < 0) {
        this.turretAngle = 2*PI;
    }
    displayTank();
    }

    public void displayTank() {

        if(Math.random() > 0.4) {
            moveHorizontal();
        }
        findTarget();

        main.rectMode(PConstants.CENTER);
        main.noFill();
        main.pushMatrix();
        rotateGradually();
        main.print(angle + "Angle? ");
        rotateBody(angle);
        main.strokeWeight(5);

        main.line(x, y, (float)xDest, (float)yDest);

        main.fill(this.team.color[0], this.team.color[1], this.team.color[2]);
        main.rect((float)x, (float)y, 20, 50); //draw rotated rect(body)

        main.fill(0);
        main.strokeWeight(10);

        main.popMatrix();

    }

    public void rotateBody(float baseAngle) {
        main.rectMode(PConstants.CENTER);
        main.translate(this.x/2, this.y/2); //rotate around center(?)

       // main.translate((float)x, (float)y);
        main.rotate(main.radians(baseAngle));

        main.translate(-this.x/2, -this.y/2);//return to proper location
    }

    public void moveHorizontal() {
        this.x += this.moveSpeed;
        if(this.x > main.WIDTH) {
            this.x = 0;
        }
        if(this.y > main.HEIGHT) {
            this.y = 0;
        }
    }

    public void rotateGradually() {
        if(this.bodyTargetAngle > this.angle) {
            this.angle++;
        }
    }

    public void findTarget() {
        if(this.target != null) {
            if (this.target.hitPoints <= 0) {
                this.target = null;
            }
        }
        for(AttackerTank at: main.tanks2) {
            if(inRange(at.x, at.y)) {
                this.target = at;
            }
        }
    }

    public boolean inRange(float otherX, float otherY) {
        return Math.sqrt((otherY - this.y) * (otherY - this.y) + (otherX - this.x) * (otherX - this.x)) < this.tankType.attackRange;
    }

    public void fire() {
        this.targetTurretAngle = Math.atan2(this.target.y - this.y, this.target.x - this.x);
        Projectile awesome = new Projectile(main, x, y, 20, (float)(8 * Math.cos(targetTurretAngle)), (float)(8 * Math.sin(targetTurretAngle)), this.team.color[0], this.team.color[1], this.team.color[2], this.target.name);
        main.projectiles.add(awesome);
        System.out.println(fireX + " my FireY: " + fireY);
    }
}

```

Yet, when my bullets are spawned, their spawn points gradually shift away from the tank. Could anyone provide some pointers?  
**Start**  
I cannot provide more than one picture, though the bullets spawn exactly where the end of the turret is.

**10 - 20 seconds later**

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b7066877a2d65b35412ef983845eec56a6a50f63.png)

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [June 12, 2019, 6:46pm UTC](https://discourse.processing.org/t/why-arent-my-ellipses-spawning-in-the-proper-location/11972/2 "2019-06-12T18:46:00Z")

</div>

If you want help with debugging, could you please include a minimal sketch that uses your tank class? This isn’t testable, so we can’t observe your problem.
