Skip to main content
2 of 3
added 1010 characters in body
House
  • 73.3k
  • 17
  • 185
  • 273

Change the raven's hunt method to hunt the mouse pointer instead of the nearest sparrow. Something like:

private void Hunt()
{
    offSet += mouse.Position - position;
}

This will have the raven hunting the mouse pointer, and therefore following the mouse instead of a sparrow. Wa-la, player controller raven.

Setting the ravens position directly to that of the mouse pointer will work, but you'll get a raven that can move across the screen very, very fast.

Keyboard control is a bit more complicated if you want more natural looking flight. A simpler way to do keyboard control would be to use the keyboard to position a target for the raven to fly towards, similar to the mouse control. But that's not very intuitive for the player. So instead I would do as JHocking suggests, use the arrow keys to increment the offset value:

if (left arrow) {
    offset.x = -1;
} else if (right arrow) {
    offset.x = 1;
} else {
    offset.x = 0;
}
if (up arrow) {
    offset.y = 1;
} else if (down arrow) {
    offset.y = -1;
} else {
    offset.y = 0;
}

That will probably give you some ugly flight, but it will give you a start. You should probably implement some better steering for your raven.

House
  • 73.3k
  • 17
  • 185
  • 273