public MainForm(Game game) { _game = game; InitializeComponent(); _labyrinthView.Attach(game.Labyrinth); _mouseRunner = new MouseRunner(game.Labyrinth) {MouseSpeed = game.MouseSpeed}; _mouseRunner.RequestUpdated += MouseRunnerOnRequestUpdated; _mouseRunner.MouseCompleted += MouseRunnerOnMouseCompleted; UpdateUI(); }
protected override void DoScheduledMovementEvents() { //setup some temps var x = 0f; var y = 0f; var joysticState = new Vector2(EndPosition.X - StartPosition.X, EndPosition.Y - StartPosition.Y); //determine raw input for this update loop if (Math.Abs(joysticState.X) >= DEAD_ZONE_X) { x = joysticState.X * LOOP_WAIT_TIME * MovementScale; } if (Math.Abs(joysticState.Y) >= DEAD_ZONE_Y) { y = joysticState.Y * LOOP_WAIT_TIME * MovementScale; } //add previous carryover x += XCarry; y += YCarry; //round to ints var moveX = (int)Math.Round(x); var moveY = (int)Math.Round(y); //set carryover XCarry = x - (float)moveX; YCarry = y - (float)moveY; //make sure we're even moving if (Math.Abs(moveX) + Math.Abs(moveY) > 0) { MouseRunner.DoEvent(MouseEventArgs.Move(moveX, moveY)); } }