enemy movement

It’s better let the movement to be handled by our Enemies class, like this:

Game class


public class Game()
{
    ............
    public class loop()
    {
              enemy.move(delta);
    }
}

Enemy class


public class Enemy()
{
     public void move(long delta)
     {
          oldX = this.getX();
          oldY= this.getY();

          //movement

          this.setX(........);
          this.setY(........);
     }
}

or put some control on the loop in the main class like this:


public class Game
{
     .......
     public void loop()
     {
            oldX = enemy.getX();
            oldY = enemy.getY();
            enemy.move(delta,oldX,oldY);
            enemy.setX(......);
            enemy.setY(......);
     }
}

Enemy class:


public class Enemy
{
      public class move(long delta,float x,float y)
      {
                //movement
      }
}

I’d go for the first option - Encapsulation FTW!
The behaviour of a class should be, as much as possible, contained within the class.

Ok Thanks!!

So i’ll write the first option!

I copy that, first method.