現在、C#言語を使用したXNAゲーム開発を検討しています。
メインのゲームハンドラーと「スプライト」クラスの2つのクラスがあります。以下は、いくつかの基本的な疑似コードで、問題を適切に説明していると思います。
Game.cs
class game {
  sprite the_sprite;
  void update(time) {
    var mouse = mouse.state
    if(mouse.clicked) { this.the_sprite.moveTo(mouse.x, mouse.y) }
    this.the_sprite.update(time)
    base.update(time)
  }
}
Sprite.cs
class sprite {
  vector2 location;
  vector2 move_to;
  void moveTo(x, y) { this.move_to = new vector2(x, y) }
  void update(time) {
    if(this.location.x > this.move_to.x /* (or less than) */) {
      // adjust location.x
    }
    if(this.location.y > this.move_to.y /* (or greater than) */) {
      // adjust location.y
    }
  }
}
基本的に:ユーザーがゲームウィンドウのどこかをクリックすると、マウスのx座標とy座標が取得され、ゲームオブジェクトは一定期間その位置に向かって移動します。
ええと...コードは機能しますが、見苦しく、オブジェクトはオブジェクトに向かって直接移動しません(代わりに、対角線上の動きとそれに続く1軸の動きです)。使用できる数学関数はいくつかあると思いますが、正直なところ、どこから始めればよいかわかりません。助言がありますか?