title: how to create a bullet class to get starting position as it is drawn? seems like a simple fix
body: <p>i have a game class that im doing all the creations and drawing, but i have no idea how to get the starting point(x,y) of when the bullet is spawned.  because the x y is always changing.  I had the idea to create a bullet class but i have no idea how to change mygame around to fit it . All i need is the simple x,y coordiante of the spawned bullet any way to save it?  heres what i think my bullet class should maybe look like:</p>
  
  <pre><code>    public class Bullet {
  private Circle circle;
  private int startX;
  private int startY;
  
  public Bullet(int startX, int startY){
      circle = //create circle from startX and startY
      this.startX = startX;
      this.startY = startY;
  }
  //getters and setters here...
    }
  </code></pre>
  
  <p>here is my game class</p>
  
  <pre><code>                        public class MyGame extends ApplicationAdapter {
  SpriteBatch batch;
  Texture ballImage, bulletImage;
  OrthographicCamera cam;
  Circle ball;
  Array &lt;Circle&gt; bullets;
  //long lastShot;
  
  @Override
  public void create ()
  {
      System.out.println("game created");
      ballImage = new Texture(Gdx.files.internal("ball.png"));
      bulletImage = new Texture(Gdx.files.internal("bullet.png"));
  
      cam = new OrthographicCamera();
      cam.setToOrtho(true,320,480);//true starts top left false starts bottom left
  
      batch = new SpriteBatch();  
  
      ball = new Circle();
      ball.radius=20;
      ball.x=320/2-ball.radius; // half screen size - half image
      ball.y=480/2-ball.radius;
  
      bullets = new Array&lt;Circle&gt;();
      spawnBullet();      
  }
  
  public void spawnBullet()
  {
      Circle bullet = new Circle();
      bullet.radius=8;
      bullet.x=bullet.radius; // half screen size - half image
      bullet.y=MathUtils.random(0, 480-bullet.radius);
      bullets.add(bullet);
      System.out.println("x: "+bullet.x+" Y: "+bullet.y);     
  }
  
  @Override
  public void render ()
  {
      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
      cam.update();
      batch.setProjectionMatrix(cam.combined);
      batch.begin();
      batch.draw(ballImage,ball.x-ball.radius,ball.y-ball.radius);
      for(Circle bullet: bullets)
      {
          batch.draw(bulletImage, bullet.x-bullet.radius, bullet.y-bullet.radius);
      }
      batch.end(); 
  
      if(Gdx.input.isTouched())
      {           
          Vector3 pos = new Vector3();
          pos.set(Gdx.input.getX(), Gdx.input.getY(),0);
          cam.unproject(pos); 
          ball.y = pos.y ;    
      }
  
  
      if(ball.y&lt;0+ball.radius)ball.y=ball.radius;
      if(ball.y&gt;480-ball.radius)ball.y=480-ball.radius;
  
      Iterator&lt;Circle&gt; i = bullets.iterator();    
  
       while(i.hasNext())
      {
  
          Circle bullet = i.next();   
          //System.out.println("x2: "+bullet.x+" Y2: "+bullet.y);
  
  
          if(bullet.y&gt;240){
          bullet.x++;
          bullet.y--;}
  
          bullet.x++;
  
          //right border collision
          if(bullet.x&gt;320)
          {
              i.remove();
              spawnBullet();
          }
           //circle collision
              if(ball.overlaps(bullet))
              {
              i.remove();
              spawnBullet();
              }   
      } 
  
  
  
  }   
   }
  </code></pre>