internal void CaptureKey(object sender, KeyEventArgs e) { ModelInterface m = Engine.GetInstance()._model; int key = e.KeyValue; if (key == Engine.GetInstance()._configuration.Keys.GetKey("left")) { Vector2D newPos = m.GetShipPosition() - m.GetShipSpeed(); m.SetShipPosition((newPos.X > 0) ? newPos : new Vector2D(0, newPos.Y)); } else if (key == Engine.GetInstance()._configuration.Keys.GetKey("right")) { Vector2D newPos = m.GetShipPosition() + m.GetShipSpeed(); int maxX = (int)m.GetMapDimensions().X; int width = (int)m.GetShipDimensions().X; m.SetShipPosition((newPos.X < maxX - width) ? newPos : new Vector2D(maxX - width, newPos.Y)); } else if (key == Engine.GetInstance()._configuration.Keys.GetKey("esc")) { m.SetExited(true); } }