private void MazeForm_KeyDown(object sender, KeyEventArgs e) { timer1.Start(); int[] Xcoords = maze.XCoordsArray; int[] Ycoords = maze.YCoordsArray; switch (e.KeyCode) { case Keys.Right: { player.Move(Player.Direction.Right); checkWin(); for (int i = 0; i <= Xcoords.Length - 1; i++) { if (player.XPosition == Xcoords[i] && player.YPosition == Ycoords[i]) { player.XPosition = (player.XPosition - 14); break; } } break; } case Keys.Left: { player.Move(Player.Direction.Left); checkWin(); for (int i = 0; i <= Xcoords.Length - 1; i++) { if (player.XPosition == Xcoords[i] && player.YPosition == Ycoords[i]) { player.XPosition = (player.XPosition + 14); break; } } break; } case Keys.Up: { player.Move(Player.Direction.Up); checkWin(); for (int i = 0; i <= Xcoords.Length - 1; i++) { if (player.XPosition == Xcoords[i] && player.YPosition == Ycoords[i]) { player.YPosition = (player.YPosition + 14); break; } } break; } case Keys.Down: { player.Move(Player.Direction.Down); checkWin(); for (int i = 0; i <= Xcoords.Length - 1; i++) { if (player.XPosition == Xcoords[i] && player.YPosition == Ycoords[i]) { player.YPosition = (player.YPosition - 14); break; } } break; } } }